detecting location of wayland-scanner binary
[profile/ivi/wayland-ivi-extension.git] / weston-ivi-shell / CMakeLists.txt
1 ############################################################################
2 #
3 # Copyright (C) 2013 DENSO CORPORATION
4 #
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #               http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 ############################################################################
19
20 cmake_minimum_required (VERSION 2.6)
21
22 project(ivi-controller)
23 project_type(CORE)
24
25 find_package(PkgConfig REQUIRED)
26 pkg_check_modules(WAYLAND_SERVER wayland-server REQUIRED)
27 pkg_check_modules(CAIRO cairo REQUIRED)
28 pkg_check_modules(WESTON weston REQUIRED)
29 pkg_check_modules(PIXMAN pixman-1 REQUIRED)
30
31 find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
32
33 add_custom_command(
34     OUTPUT ivi-application-server-protocol.h
35     COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header <${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml> ${CMAKE_SOURCE_DIR}/weston-ivi-shell/include/ivi-application-server-protocol.h
36 )
37
38 add_custom_command(
39     OUTPUT ivi-application-protocol.c
40     COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code <${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml> ${CMAKE_SOURCE_DIR}/weston-ivi-shell/src/ivi-application-protocol.c
41 )
42
43 add_custom_command(
44     OUTPUT ivi-controller-server-protocol.h
45     COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header <${CMAKE_SOURCE_DIR}/protocol/ivi-controller.xml> ${CMAKE_SOURCE_DIR}/weston-ivi-shell/include/ivi-controller-server-protocol.h
46 )
47
48 add_custom_command(
49     OUTPUT ivi-controller-protocol.c
50     COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code <${CMAKE_SOURCE_DIR}/protocol/ivi-controller.xml> ${CMAKE_SOURCE_DIR}/weston-ivi-shell/src/ivi-controller-protocol.c
51 )
52
53 add_custom_target(
54     generate_wayland_protocol_codes_for_server
55     DEPENDS ivi-application-server-protocol.h ivi-application-protocol.c ivi-controller-server-protocol.h ivi-controller-protocol.c
56 )
57
58 include_directories(
59     "include"
60     ${WAYLAND_SERVER_INCLUDE_DIRS}
61     ${CAIRO_INCLUDE_DIRS}
62     ${WESTON_INCLUDE_DIRS}
63     ${PIXMAN_INCLUDE_DIRS}
64 )
65
66
67 add_library(${PROJECT_NAME} MODULE
68     src/ivi-controller.c
69     src/ivi-controller-protocol.c
70 )
71
72 set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
73
74 add_dependencies(${PROJECT_NAME}
75     generate_wayland_protocol_codes_for_server
76     ${WAYLAND_SERVER_LIBRARIES}
77     ${CAIRO_LIBRARIES}
78     ${PIXMAN_LIBRARIES}
79     ${WESTON_LIBRARIES}
80 )
81
82 set(LIBS
83     ${LIBS}
84     rt
85     dl
86     ${WAYLAND_SERVER_LIBRARIES}
87     ${CAIRO_LIBRARIES}
88     ${WESTON_LIBRARIES}
89 )
90
91 target_link_libraries(${PROJECT_NAME} ${LIBS} -ldl)
92
93 install (
94     TARGETS             ${PROJECT_NAME}
95     LIBRARY DESTINATION lib/weston
96 )