1 # Copyright (C) 2012, GENIVI Alliance, Inc.
2 # Copyright (C) 2012, BMW AG
4 # This file is part of GENIVI Project AudioManager.
6 # Contributions are licensed to the GENIVI Alliance under one or more
7 # Contribution License Agreements.
10 # This Source Code Form is subject to the terms of the
11 # Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 # this file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 # author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16 # For further information see http://www.genivi.org/.
20 cmake_minimum_required(VERSION 2.6)
22 execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
23 OUTPUT_VARIABLE DAEMONVERSION
24 OUTPUT_STRIP_TRAILING_WHITESPACE)
27 SET( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" )
29 STRING(REGEX REPLACE "(-)[^-]+$" "" DAEMONVERSION ${DAEMONVERSION})
30 STRING(REGEX REPLACE "-" "." DAEMONVERSION ${DAEMONVERSION})
33 message(STATUS "Build Version ${DAEMONVERSION}")
35 execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
36 OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)
38 PROJECT(AudioManagerDeamon)
40 FIND_PACKAGE(PkgConfig)
42 OPTION( WITH_DBUS_WRAPPER
43 "Enable Dbus Wrapper Support" ON )
46 "Enable automotive-DLT Support" ON )
49 "Build together with all available unitTest" ON )
51 OPTION( WITH_DOCUMENTATION
52 "Build together with Doxygen Documentation" OFF )
54 OPTION( WITH_PLUGIN_COMMAND
55 "Build command pluings" ON)
57 OPTION( WITH_PLUGIN_CONTROL
58 "Build control pluing" ON)
60 OPTION( WITH_PLUGIN_ROUTING
61 "Build routing pluings" ON)
64 "Build with daemon" ON)
67 "libc supports ppoll" ON)
70 "build with Telnetserver (can only work with SocketHandler)" ON)
72 OPTION ( USE_BUILD_LIBS
73 "build with default library path = build path" ON)
75 OPTION ( GLIB_DBUS_TYPES_TOLERANT
76 "build dbus with tolerance towards glib 16bit/32bit handling" ON)
78 #Can be changed via passing -DDBUS_SERVICE_PREFIX="XXX" to cmake
79 IF(NOT DEFINED DBUS_SERVICE_PREFIX)
80 SET( DBUS_SERVICE_PREFIX "org.genivi.audiomanager\0" )
81 ENDIF(NOT DEFINED DBUS_SERVICE_PREFIX)
83 #Can be changed via passing -DDBUS_SERVICE_OBJECT_PATH="XXX" to cmake
84 IF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
85 SET( DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager\0" )
86 ENDIF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
88 #Can be changed via passing -DDEFAULT_TELNETPORT="XXX" to cmake
89 IF(NOT DEFINED DEFAULT_TELNETPORT)
90 SET( DEFAULT_TELNETPORT 6060 )
91 ENDIF(NOT DEFINED DEFAULT_TELNETPORT)
93 #Can be changed via passing -DMAX_TELNETCONNECTIONS="XXX" to cmake
94 IF(NOT DEFINED MAX_TELNETCONNECTIONS)
95 SET( MAX_TELNETCONNECTIONS 3 )
96 ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS)
98 SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
99 SET(LIB_INSTALL_SUFFIX "audioManager")
102 SET(DEFAULT_PLUGIN_COMMAND_DIR "${PLUGINS_OUTPUT_PATH}/command")
103 SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
104 SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
106 SET(DEFAULT_PLUGIN_COMMAND_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/command")
107 SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
108 SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
109 endif(USE_BUILD_LIBS)
111 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
112 SET(AUDIO_include_FOLDER ${CMAKE_SOURCE_DIR}/include)
113 SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
114 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
115 SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
116 SET(DOXY_PROTOTYPE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
117 SET(DOXY_FILE ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile)
119 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h )
120 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile )
124 pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0) #this is due to BUGFIX [GDLT-41]
128 IF(WITH_DOCUMENTATION)
129 find_package(Doxygen)
130 configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Doxyfile @ONLY IMMEDIATE)
131 add_custom_target (AudioManangerDoku ALL
132 COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
133 SOURCES ${CMAKE_SOURCE_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
135 ENDIF(WITH_DOCUMENTATION)
137 ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
138 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE -pedantic -Wno-variadic-macros")
139 #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")
141 if(WITH_PLUGIN_COMMAND)
142 add_subdirectory (PluginCommandInterfaceDbus)
143 endif(WITH_PLUGIN_COMMAND)
145 if(WITH_PLUGIN_ROUTING)
146 add_subdirectory (PluginRoutingInterfaceDbus)
147 add_subdirectory (PluginRoutingInterfaceAsync)
148 endif(WITH_PLUGIN_ROUTING)
150 if(WITH_PLUGIN_CONTROL)
151 add_subdirectory (PluginControlInterface)
152 endif(WITH_PLUGIN_CONTROL)
155 add_subdirectory (AudioManagerDaemon)
160 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
161 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
164 add_custom_target(uninstall
165 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
167 # Here starts package creation
168 SET(CPACK_SET_DESTDIR ON)
169 SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
170 SET(CPACK_GENERATOR "DEB")
171 SET(CPACK_PACKAGE_NAME "AudioManager")
172 SET(CPACK_PACKAGE_VENDOR "GENIVI")
173 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
174 SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
175 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
176 SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
177 SET(CPACK_PACKAGE_CONTACT "Christian Mueller (BMW) christian.ei.mueller@bmw.de")
178 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
179 SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
180 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
181 SET(CPACK_STRIP_FILES TRUE)
182 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
183 SET(CPACK_SOURCE_GENERATOR "TGZ")
184 SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" ".project" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h")
186 #evaluate the properties
188 get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
189 list(REMOVE_DUPLICATES ADD_DEPEND)
190 set(ALL_DEPEND ${ADD_DEPEND})
191 FOREACH (dep ${ADD_DEPEND})
192 SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
194 STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
197 if(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
198 get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
199 list(REMOVE_DUPLICATES ADD_DEPEND)
200 list(APPEND ALL_DEPEND ${ADD_DEPEND})
201 FOREACH (dep ${ADD_DEPEND})
202 SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
204 STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
205 endif(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
208 get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
209 list(REMOVE_DUPLICATES ADD_DEPEND)
210 list(APPEND ALL_DEPEND ${ADD_DEPEND})
211 FOREACH (dep ${ADD_DEPEND})
212 SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
214 STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
217 get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
218 list(REMOVE_DUPLICATES ADD_DEPEND)
219 list(APPEND ALL_DEPEND ${ADD_DEPEND})
220 FOREACH (dep ${ADD_DEPEND})
221 SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
223 STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})
225 list(REMOVE_DUPLICATES ALL_DEPEND)
226 list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
227 FOREACH (dep ${ALL_DEPEND})
228 SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
230 STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
231 execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})
233 #component based dep package generation is only supported above 2.8.5
234 IF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
236 SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
237 SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
238 SET(CPACK_DEB_COMPONENT_INSTALL ON)
239 ADD_CUSTOM_TARGET(genivi_package
240 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
242 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
243 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
244 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
245 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
247 ELSE (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
248 IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
249 ADD_CUSTOM_TARGET(genivi_package
250 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
252 COMMAND ${CMAKE_CURRENT_BINARY_DIR}A logical block opening on t/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
254 ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
255 ADD_CUSTOM_TARGET(genivi_package
256 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
258 COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
259 COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
260 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
262 ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
263 ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)