1############################################################################ 2# 3# Copyright 2012 BMW Car IT GmbH 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 20project (simple-weston-client) 21 22find_package(PkgConfig) 23pkg_check_modules(WAYLAND_CLIENT wayland-client REQUIRED) 24pkg_check_modules(WAYLAND_CURSOR wayland-cursor REQUIRED) 25pkg_check_modules(LIBWESTON_PROTOCOLS libweston-6-protocols QUIET) 26 27if(${LIBWESTON_PROTOCOLS_FOUND}) 28 #check for DLT 29 pkg_check_modules(DLT automotive-dlt REQUIRED) 30 31 #import the pkgdatadir from libweston-protocols pkgconfig file 32 execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir libweston-6-protocols 33 OUTPUT_VARIABLE WestonProtocols_PKGDATADIR) 34 string(REGEX REPLACE "[\r\n]" "" WestonProtocols_PKGDATADIR "${WestonProtocols_PKGDATADIR}") 35 SET(LIBWESTON_PROTOCOLS_PKGDATADIR ${WestonProtocols_PKGDATADIR}) 36endif(${LIBWESTON_PROTOCOLS_FOUND}) 37 38find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) 39 40add_custom_command( 41 OUTPUT ivi-application-client-protocol.h 42 COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header 43 < ${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml 44 > ${CMAKE_CURRENT_BINARY_DIR}/ivi-application-client-protocol.h 45 DEPENDS ${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml 46) 47 48add_custom_command( 49 OUTPUT ivi-application-protocol.c 50 COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code 51 < ${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml 52 > ${CMAKE_CURRENT_BINARY_DIR}/ivi-application-protocol.c 53 DEPENDS ${CMAKE_SOURCE_DIR}/protocol/ivi-application.xml 54) 55 56if(${LIBWESTON_PROTOCOLS_FOUND}) 57 add_custom_command( 58 OUTPUT weston-debug-client-protocol.h 59 COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header 60 < ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 61 > ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-client-protocol.h 62 DEPENDS ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 63 ) 64 65 add_custom_command( 66 OUTPUT weston-debug-server-protocol.h 67 COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header 68 < ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 69 > ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-server-protocol.h 70 DEPENDS ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 71 ) 72 73 add_custom_command( 74 OUTPUT weston-debug-protocol.c 75 COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code 76 < ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 77 > ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-protocol.c 78 DEPENDS ${LIBWESTON_PROTOCOLS_PKGDATADIR}/weston-debug.xml 79 ) 80endif(${LIBWESTON_PROTOCOLS_FOUND}) 81 82include_directories( 83 ${WAYLAND_CLIENT_INCLUDE_DIR} 84 ${WAYLAND_CURSOR_INCLUDE_DIR} 85 ${CMAKE_CURRENT_BINARY_DIR} 86 ${DLT_INCLUDE_DIR} 87) 88 89link_directories( 90 ${WAYLAND_CLIENT_LIBRARY_DIRS} 91 ${WAYLAND_CURSOR_LIBRARY_DIRS} 92 ${DLT_LIBRARY_DIRS} 93) 94 95SET(LIBS 96 ${WAYLAND_CLIENT_LIBRARIES} 97 ${WAYLAND_CURSOR_LIBRARIES} 98 ${DLT_LIBRARIES} 99) 100 101SET(SRC_FILES 102 src/simple-weston-client.c 103 ivi-application-protocol.c 104 ivi-application-client-protocol.h 105) 106 107if(${LIBWESTON_PROTOCOLS_FOUND}) 108 SET(WESTON_DEBUG_SRC_FILES 109 ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-protocol.c 110 ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-client-protocol.h 111 ${CMAKE_CURRENT_BINARY_DIR}/weston-debug-server-protocol.h 112) 113endif(${LIBWESTON_PROTOCOLS_FOUND}) 114 115add_executable(${PROJECT_NAME} ${SRC_FILES} ${WESTON_DEBUG_SRC_FILES}) 116 117add_dependencies(${PROJECT_NAME} ${LIBS}) 118 119add_definitions(${DLT_CFLAGS}) 120 121if(${LIBWESTON_PROTOCOLS_FOUND}) 122 add_definitions(-DLIBWESTON_DEBUG_PROTOCOL) 123endif(${LIBWESTON_PROTOCOLS_FOUND}) 124 125target_link_libraries(${PROJECT_NAME} ${LIBS}) 126 127install (TARGETS ${PROJECT_NAME} DESTINATION bin) 128