1 # Copyright (C) 2012, BMW AG
3 # This file is part of GENIVI Project AudioManager.
5 # Contributions are licensed to the GENIVI Alliance under one or more
6 # Contribution License Agreements.
9 # This Source Code Form is subject to the terms of the
10 # Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
11 # this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 # author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
15 # For further information see http://www.genivi.org/.
19 cmake_minimum_required(VERSION 2.6)
21 execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
22 OUTPUT_VARIABLE DAEMONVERSION
23 OUTPUT_STRIP_TRAILING_WHITESPACE)
25 IF (NOT DAEMONVERSION)
26 SET( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" )
27 ELSE (NOT DAEMONVERSION)
28 STRING(REGEX REPLACE "(-)[^-]+$" "" DAEMONVERSION ${DAEMONVERSION})
29 STRING(REGEX REPLACE "-" "." DAEMONVERSION ${DAEMONVERSION})
30 ENDIF(NOT DAEMONVERSION)
32 IF(NOT DEFINED LIBDIR)
34 ENDIF(NOT DEFINED LIBDIR)
36 message(STATUS "Build Version ${DAEMONVERSION}")
38 execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
39 OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)
41 PROJECT(AudioManagerDeamon)
43 FIND_PACKAGE(PkgConfig)
45 OPTION( WITH_DBUS_WRAPPER
46 "Enable Dbus Wrapper Support" ON )
49 "Enable automotive-DLT Support" ON )
52 "Build together with all available unitTest" ON )
54 OPTION( WITH_DOCUMENTATION
55 "Build together with Doxygen Documentation" OFF )
57 OPTION( WITH_PLUGIN_COMMAND
58 "Build command pluings" ON)
60 OPTION( WITH_PLUGIN_CONTROL
61 "Build control pluing" ON)
63 OPTION( WITH_PLUGIN_ROUTING
64 "Build routing pluings" ON)
67 "Build with daemon" 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}/${LIBDIR}/${LIB_INSTALL_SUFFIX}/command")
107 SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/${LIBDIR}/${LIB_INSTALL_SUFFIX}/routing")
108 SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/${LIBDIR}/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
109 endif(USE_BUILD_LIBS)
111 message(STATUS "default directory for command plugin ${DEFAULT_PLUGIN_COMMAND_DIR}")
112 message(STATUS " routing plugin ${DEFAULT_PLUGIN_ROUTING_DIR}")
113 message(STATUS "default controller plugin ${CONTROLLER_PLUGIN}")
116 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
117 SET(AUDIO_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/include)
118 SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
119 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
120 SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
121 SET(DOXY_PROTOTYPE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
122 SET(DOXY_FILE ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile)
124 IF(EXISTS "ProjectSpecific/")
125 SET(PROJECT_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/ProjectSpecific/include)
126 endif(EXISTS "ProjectSpecific/")
128 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h )
129 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/docx/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile )
130 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/audiomanager.pc.cmake ${CMAKE_SOURCE_DIR}/audiomanager.pc @ONLY)
133 pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
135 set(CMAKE_EXE_LINKER_FLAGS "-lrt")
139 IF(WITH_DOCUMENTATION)
140 find_package(Doxygen)
141 configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Doxyfile @ONLY IMMEDIATE)
142 add_custom_target (AudioManangerDoku ALL
143 COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
144 SOURCES ${CMAKE_SOURCE_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
146 ENDIF(WITH_DOCUMENTATION)
148 ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
149 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE -pedantic -Wno-variadic-macros")
150 #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")
152 if(WITH_PLUGIN_COMMAND)
153 add_subdirectory (PluginCommandInterfaceDbus)
154 endif(WITH_PLUGIN_COMMAND)
156 if(WITH_PLUGIN_ROUTING)
157 add_subdirectory (PluginRoutingInterfaceDbus)
158 add_subdirectory (PluginRoutingInterfaceAsync)
159 endif(WITH_PLUGIN_ROUTING)
161 if(WITH_PLUGIN_CONTROL)
162 add_subdirectory (PluginControlInterface)
163 endif(WITH_PLUGIN_CONTROL)
166 add_subdirectory (AudioManagerDaemon)
169 IF(EXISTS "ProjectSpecific/")
170 add_subdirectory (ProjectSpecific)
171 endif(EXISTS "ProjectSpecific/")
173 INSTALL(FILES audiomanager.pc
174 DESTINATION ${LIBDIR}/pkgconfig
179 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
180 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
183 add_custom_target(uninstall
184 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
186 # Here starts package creation
187 SET(CPACK_SET_DESTDIR ON)
188 SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
189 SET(CPACK_GENERATOR "DEB")
190 SET(CPACK_PACKAGE_NAME "AudioManager")
191 SET(CPACK_PACKAGE_VENDOR "GENIVI")
192 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
193 SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
194 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
195 SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
196 SET(CPACK_PACKAGE_CONTACT "Christian Mueller (BMW) christian.ei.mueller@bmw.de")
197 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
198 SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
199 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
200 SET(CPACK_STRIP_FILES TRUE)
201 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
202 SET(CPACK_SOURCE_GENERATOR "TGZ")
203 SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" ".project" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h")
205 #evaluate the properties
207 get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
208 list(REMOVE_DUPLICATES ADD_DEPEND)
209 set(ALL_DEPEND ${ADD_DEPEND})
210 FOREACH (dep ${ADD_DEPEND})
211 SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
213 STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
216 if(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
217 get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
218 list(REMOVE_DUPLICATES ADD_DEPEND)
219 list(APPEND ALL_DEPEND ${ADD_DEPEND})
220 FOREACH (dep ${ADD_DEPEND})
221 SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
223 STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
224 endif(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
227 get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
228 list(REMOVE_DUPLICATES ADD_DEPEND)
229 list(APPEND ALL_DEPEND ${ADD_DEPEND})
230 FOREACH (dep ${ADD_DEPEND})
231 SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
233 STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
236 get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
237 list(REMOVE_DUPLICATES ADD_DEPEND)
238 list(APPEND ALL_DEPEND ${ADD_DEPEND})
239 FOREACH (dep ${ADD_DEPEND})
240 SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
242 STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})
244 list(REMOVE_DUPLICATES ALL_DEPEND)
245 list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
246 FOREACH (dep ${ALL_DEPEND})
247 SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
249 STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
250 execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})
252 #component based dep package generation is only supported above 2.8.5
253 IF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
255 SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
256 SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
257 SET(CPACK_DEB_COMPONENT_INSTALL ON)
258 ADD_CUSTOM_TARGET(genivi_package
259 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
261 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
262 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
263 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
264 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
266 ELSE (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
267 IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
268 ADD_CUSTOM_TARGET(genivi_package
269 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
271 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}\"
273 ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
274 ADD_CUSTOM_TARGET(genivi_package
275 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
277 COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
278 COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
279 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
281 ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
282 ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)