2 # Copyright (C) 2011, BMW AG
9 # @author: Christian Müller (christian.ei.mueller@bmw.de)
12 cmake_minimum_required(VERSION 2.6)
14 execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
15 OUTPUT_VARIABLE DAEMONVERSION
16 OUTPUT_STRIP_TRAILING_WHITESPACE)
19 SET( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" )
22 message(STATUS "Build Version ${DAEMONVERSION}")
24 execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
25 OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)
27 PROJECT(AudioManagerDeamon)
29 OPTION( WITH_DBUS_WRAPPER
30 "Enable Dbus Wrapper Support" ON )
32 OPTION( WITH_SOCKETHANDLER_LOOP
33 "Enable SocketHandler Support (cannot work with SimpleDBusLoop)" ON )
35 OPTION( WITH_SIMPLEDBUS_LOOP
36 "Enable SimpleDBusLoop (requires DBus_Wrapper,cannot work with SocketHandler)" OFF )
39 "Build together with all available unitTest" ON )
41 OPTION( WITH_DOCUMENTATION
42 "Build together with Doxygen Documentation" OFF )
44 OPTION( WITH_PLUGIN_COMMAND
45 "Build command pluings" ON)
47 OPTION( WITH_PLUGIN_CONTROL
48 "Build control pluing" ON)
50 OPTION( WITH_PLUGIN_ROUTING
51 "Build routing pluings" ON)
53 OPTION( USE_BUILD_LIBS
54 "Sets the default path to the libs that are compiled with the AudioManager together. If turned off, the default location will be the one of the install path" OFF)
57 "Build with daemon" ON)
60 "libc supports ppoll" ON)
63 "build with Telnetserver" OFF)
65 OPTION ( USE_BUILD_LIBS
66 "build with default library path = build path" ON)
68 OPTION ( GLIB_DBUS_TYPES_TOLERANT
69 "build dbus with tolerance towards glib 16bit/32bit handling" ON)
71 #Can be changed via passing -DDBUS_SERVICE_PREFIX="XXX" to cmake
72 IF(NOT DEFINED DBUS_SERVICE_PREFIX)
73 SET( DBUS_SERVICE_PREFIX "org.genivi.audiomanager\0" )
74 ENDIF(NOT DEFINED DBUS_SERVICE_PREFIX)
76 #Can be changed via passing -DDBUS_SERVICE_OBJECT_PATH="XXX" to cmake
77 IF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
78 SET( DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager\0" )
79 ENDIF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
81 #Can be changed via passing -DDEFAULT_TELNETPORT="XXX" to cmake
82 IF(NOT DEFINED DEFAULT_TELNETPORT)
83 SET( DEFAULT_TELNETPORT 6060 )
84 ENDIF(NOT DEFINED DEFAULT_TELNETPORT)
86 #Can be changed via passing -DMAX_TELNETCONNECTIONS="XXX" to cmake
87 IF(NOT DEFINED MAX_TELNETCONNECTIONS)
88 SET( MAX_TELNETCONNECTIONS 3 )
89 ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS)
91 SET(DLT_CONTEXT AudioManager)
92 SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
93 SET(LIB_INSTALL_SUFFIX "audioManager")
96 SET(DEFAULT_PLUGIN_COMMAND_DIR "${PLUGINS_OUTPUT_PATH}/command")
97 SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
98 SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
100 SET(DEFAULT_PLUGIN_COMMAND_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/command")
101 SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
102 SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
103 endif(USE_BUILD_LIBS)
105 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
106 SET(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/includes)
107 SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
108 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
109 SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
110 SET(DOXY_FILE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
111 SET(INTROSPECTION_COMMAND_XML_FILE "${AUDIO_INCLUDES_FOLDER}/dbus/CommandInterface.xml")
113 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/includes/config.h )
115 FIND_PACKAGE(PkgConfig)
116 pkg_check_modules(DLT REQUIRED automotive-dlt)
118 IF(WITH_DOCUMENTATION)
119 find_package(Doxygen)
120 file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH}/Interfaces)
121 configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Interfaces/Doxyfile @ONLY IMMEDIATE)
122 add_custom_target (Interfaces ALL
123 COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Interfaces/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}/Interfaces
124 SOURCES ${AUDIO_INCLUDES_FOLDER} ${DOC_OUTPUT_PATH}/Interfaces/Doxyfile
126 ENDIF(WITH_DOCUMENTATION)
128 ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
129 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")
131 if(WITH_PLUGIN_COMMAND)
132 add_subdirectory (PluginCommandInterfaceDbus)
133 endif(WITH_PLUGIN_COMMAND)
135 if(WITH_PLUGIN_ROUTING)
136 add_subdirectory (PluginRoutingInterfaceDbus)
137 add_subdirectory (PluginRoutingInterfaceAsync)
138 endif(WITH_PLUGIN_ROUTING)
140 if(WITH_PLUGIN_CONTROL)
141 add_subdirectory (PluginControlInterface)
142 endif(WITH_PLUGIN_CONTROL)
145 add_subdirectory (AudioManagerDaemon)
150 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
151 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
154 add_custom_target(uninstall
155 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
157 # Here starts package creation
158 SET(CPACK_SET_DESTDIR ON)
159 SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
160 SET(CPACK_GENERATOR "DEB")
161 SET(CPACK_PACKAGE_NAME "AudioManager")
162 SET(CPACK_PACKAGE_VENDOR "GENIVI")
163 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
164 SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
165 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
166 SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
167 SET(CPACK_PACKAGE_CONTACT "Christian Mueller (BMW) christian.ei.mueller@bmw.de")
168 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
169 SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
170 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
171 SET(CPACK_STRIP_FILES TRUE)
172 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
173 SET(CPACK_SOURCE_GENERATOR "TGZ")
174 SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" ".project" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h")
176 #evaluate the properties
178 get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
179 list(REMOVE_DUPLICATES ADD_DEPEND)
180 set(ALL_DEPEND ${ADD_DEPEND})
181 FOREACH (dep ${ADD_DEPEND})
182 SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
184 STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
187 get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
188 list(REMOVE_DUPLICATES ADD_DEPEND)
189 list(APPEND ALL_DEPEND ${ADD_DEPEND})
190 FOREACH (dep ${ADD_DEPEND})
191 SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
193 STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
196 get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
197 list(REMOVE_DUPLICATES ADD_DEPEND)
198 list(APPEND ALL_DEPEND ${ADD_DEPEND})
199 FOREACH (dep ${ADD_DEPEND})
200 SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
202 STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
205 get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
206 list(REMOVE_DUPLICATES ADD_DEPEND)
207 list(APPEND ALL_DEPEND ${ADD_DEPEND})
208 FOREACH (dep ${ADD_DEPEND})
209 SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
211 STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})
213 list(REMOVE_DUPLICATES ALL_DEPEND)
214 list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
215 FOREACH (dep ${ALL_DEPEND})
216 SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
218 STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
219 execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})
221 #component based dep package generation is only supported above 2.8.5
222 IF (${CMAKE_VERSION} VERSION_GREATER 2.9.4)
224 SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
225 SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
226 SET(CPACK_DEB_COMPONENT_INSTALL ON)
227 ADD_CUSTOM_TARGET(genivi_package
228 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
230 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
231 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
232 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
233 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
235 ELSE (${CMAKE_VERSION} VERSION_GREATER 2.9.4)
236 IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
237 ADD_CUSTOM_TARGET(genivi_package
238 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
240 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
242 ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
243 ADD_CUSTOM_TARGET(genivi_package
244 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
246 COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
247 COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
248 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
250 ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
251 ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.9.4)