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 message(STATUS "Build Version ${DAEMONVERSION}")
34 execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
35 OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)
37 PROJECT(AudioManagerDeamon)
39 FIND_PACKAGE(PkgConfig)
41 OPTION( WITH_DBUS_WRAPPER
42 "Enable Dbus Wrapper Support" ON )
45 "Enable automotive-DLT Support" ON )
48 "Build together with all available unitTest" ON )
50 OPTION( WITH_DOCUMENTATION
51 "Build together with Doxygen Documentation" OFF )
53 OPTION( WITH_PLUGIN_COMMAND
54 "Build command pluings" ON)
56 OPTION( WITH_PLUGIN_CONTROL
57 "Build control pluing" ON)
59 OPTION( WITH_PLUGIN_ROUTING
60 "Build routing pluings" ON)
63 "Build with daemon" ON)
66 "libc supports ppoll" ON)
69 "build with Telnetserver (can only work with SocketHandler)" ON)
71 OPTION ( USE_BUILD_LIBS
72 "build with default library path = build path" ON)
74 OPTION ( GLIB_DBUS_TYPES_TOLERANT
75 "build dbus with tolerance towards glib 16bit/32bit handling" ON)
77 #Can be changed via passing -DDBUS_SERVICE_PREFIX="XXX" to cmake
78 IF(NOT DEFINED DBUS_SERVICE_PREFIX)
79 SET( DBUS_SERVICE_PREFIX "org.genivi.audiomanager\0" )
80 ENDIF(NOT DEFINED DBUS_SERVICE_PREFIX)
82 #Can be changed via passing -DDBUS_SERVICE_OBJECT_PATH="XXX" to cmake
83 IF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
84 SET( DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager\0" )
85 ENDIF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
87 #Can be changed via passing -DDEFAULT_TELNETPORT="XXX" to cmake
88 IF(NOT DEFINED DEFAULT_TELNETPORT)
89 SET( DEFAULT_TELNETPORT 6060 )
90 ENDIF(NOT DEFINED DEFAULT_TELNETPORT)
92 #Can be changed via passing -DMAX_TELNETCONNECTIONS="XXX" to cmake
93 IF(NOT DEFINED MAX_TELNETCONNECTIONS)
94 SET( MAX_TELNETCONNECTIONS 3 )
95 ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS)
97 SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
98 SET(LIB_INSTALL_SUFFIX "audioManager")
101 SET(DEFAULT_PLUGIN_COMMAND_DIR "${PLUGINS_OUTPUT_PATH}/command")
102 SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
103 SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
105 SET(DEFAULT_PLUGIN_COMMAND_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/command")
106 SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
107 SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
108 endif(USE_BUILD_LIBS)
110 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
111 SET(AUDIO_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/include)
112 SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
113 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
114 SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
115 SET(DOXY_PROTOTYPE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
116 SET(DOXY_FILE ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile)
118 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h )
119 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/docx/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile )
123 pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
127 IF(WITH_DOCUMENTATION)
128 find_package(Doxygen)
129 configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Doxyfile @ONLY IMMEDIATE)
130 add_custom_target (AudioManangerDoku ALL
131 COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
132 SOURCES ${CMAKE_SOURCE_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
134 ENDIF(WITH_DOCUMENTATION)
136 ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
137 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE -pedantic -Wno-variadic-macros")
138 #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")
140 if(WITH_PLUGIN_COMMAND)
141 add_subdirectory (PluginCommandInterfaceDbus)
142 endif(WITH_PLUGIN_COMMAND)
144 if(WITH_PLUGIN_ROUTING)
145 add_subdirectory (PluginRoutingInterfaceDbus)
146 add_subdirectory (PluginRoutingInterfaceAsync)
147 endif(WITH_PLUGIN_ROUTING)
149 if(WITH_PLUGIN_CONTROL)
150 add_subdirectory (PluginControlInterface)
151 endif(WITH_PLUGIN_CONTROL)
154 add_subdirectory (AudioManagerDaemon)
159 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
160 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
163 add_custom_target(uninstall
164 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
166 # Here starts package creation
167 SET(CPACK_SET_DESTDIR ON)
168 SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
169 SET(CPACK_GENERATOR "DEB")
170 SET(CPACK_PACKAGE_NAME "AudioManager")
171 SET(CPACK_PACKAGE_VENDOR "GENIVI")
172 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
173 SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
174 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
175 SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
176 SET(CPACK_PACKAGE_CONTACT "Christian Mueller (BMW) christian.ei.mueller@bmw.de")
177 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
178 SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
179 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
180 SET(CPACK_STRIP_FILES TRUE)
181 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
182 SET(CPACK_SOURCE_GENERATOR "TGZ")
183 SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" ".project" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h")
185 #evaluate the properties
187 get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
188 list(REMOVE_DUPLICATES ADD_DEPEND)
189 set(ALL_DEPEND ${ADD_DEPEND})
190 FOREACH (dep ${ADD_DEPEND})
191 SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
193 STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
196 if(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
197 get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
198 list(REMOVE_DUPLICATES ADD_DEPEND)
199 list(APPEND ALL_DEPEND ${ADD_DEPEND})
200 FOREACH (dep ${ADD_DEPEND})
201 SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
203 STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
204 endif(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
207 get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
208 list(REMOVE_DUPLICATES ADD_DEPEND)
209 list(APPEND ALL_DEPEND ${ADD_DEPEND})
210 FOREACH (dep ${ADD_DEPEND})
211 SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
213 STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
216 get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
217 list(REMOVE_DUPLICATES ADD_DEPEND)
218 list(APPEND ALL_DEPEND ${ADD_DEPEND})
219 FOREACH (dep ${ADD_DEPEND})
220 SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
222 STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})
224 list(REMOVE_DUPLICATES ALL_DEPEND)
225 list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
226 FOREACH (dep ${ALL_DEPEND})
227 SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
229 STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
230 execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})
232 #component based dep package generation is only supported above 2.8.5
233 IF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
235 SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
236 SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
237 SET(CPACK_DEB_COMPONENT_INSTALL ON)
238 ADD_CUSTOM_TARGET(genivi_package
239 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
241 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
242 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
243 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
244 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
246 ELSE (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
247 IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
248 ADD_CUSTOM_TARGET(genivi_package
249 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
251 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}\"
253 ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
254 ADD_CUSTOM_TARGET(genivi_package
255 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
257 COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
258 COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
259 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
261 ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
262 ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)