3 #Copyright (C) 2011, BMW AG
6 #author Christian Mueller (christian.ei.mueller@bmw.de)
8 #***********************************************************************************************************
10 #***********************************************************************************************************
12 #GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 #Copyright (C) 2011, BMW AG – Christian Mueller Christian.ei.mueller@bmw.de
15 #This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16 #This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17 #You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18 #Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 #Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20 #As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21 #Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
25 cmake_minimum_required(VERSION 2.6)
27 execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
28 OUTPUT_VARIABLE DAEMONVERSION
29 OUTPUT_STRIP_TRAILING_WHITESPACE)
32 SET( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" )
34 STRING(REGEX REPLACE "(-)[^-]+$" "" DAEMONVERSION ${DAEMONVERSION})
35 STRING(REGEX REPLACE "-" "." DAEMONVERSION ${DAEMONVERSION})
38 message(STATUS "Build Version ${DAEMONVERSION}")
40 FILE(READ "cmake/DoxyFile.in" DOXYFILE)
41 STRING(REGEX REPLACE "(PROJECT_NUMBER = [0-9].[0-9].[0-9].[0-9])" "PROJECT_NUMBER = ${DAEMONVERSION}" DOXYFILE ${DOXYFILE})
42 FILE(WRITE "cmake/DoxyFile.in" ${DOXYFILE} )
44 execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
45 OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)
47 PROJECT(AudioManagerDeamon)
49 FIND_PACKAGE(PkgConfig)
51 OPTION( WITH_DBUS_WRAPPER
52 "Enable Dbus Wrapper Support" ON )
55 "Enable automotive-DLT Support" ON )
57 OPTION( WITH_SOCKETHANDLER_LOOP
58 "Enable SocketHandler Support (cannot work with SimpleDBusLoop)" ON )
60 OPTION( WITH_SIMPLEDBUS_LOOP
61 "Enable SimpleDBusLoop (requires DBus_Wrapper,cannot work with SocketHandler)" OFF )
64 "Build together with all available unitTest" ON )
66 OPTION( WITH_DOCUMENTATION
67 "Build together with Doxygen Documentation" OFF )
69 OPTION( WITH_PLUGIN_COMMAND
70 "Build command pluings" ON)
72 OPTION( WITH_PLUGIN_CONTROL
73 "Build control pluing" ON)
75 OPTION( WITH_PLUGIN_ROUTING
76 "Build routing pluings" ON)
79 "Build with daemon" ON)
82 "libc supports ppoll" ON)
85 "build with Telnetserver (can only work with SocketHandler)" ON)
87 OPTION ( USE_BUILD_LIBS
88 "build with default library path = build path" ON)
90 OPTION ( GLIB_DBUS_TYPES_TOLERANT
91 "build dbus with tolerance towards glib 16bit/32bit handling" ON)
93 #Can be changed via passing -DDBUS_SERVICE_PREFIX="XXX" to cmake
94 IF(NOT DEFINED DBUS_SERVICE_PREFIX)
95 SET( DBUS_SERVICE_PREFIX "org.genivi.audiomanager\0" )
96 ENDIF(NOT DEFINED DBUS_SERVICE_PREFIX)
98 #Can be changed via passing -DDBUS_SERVICE_OBJECT_PATH="XXX" to cmake
99 IF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
100 SET( DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager\0" )
101 ENDIF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
103 #Can be changed via passing -DDEFAULT_TELNETPORT="XXX" to cmake
104 IF(NOT DEFINED DEFAULT_TELNETPORT)
105 SET( DEFAULT_TELNETPORT 6060 )
106 ENDIF(NOT DEFINED DEFAULT_TELNETPORT)
108 #Can be changed via passing -DMAX_TELNETCONNECTIONS="XXX" to cmake
109 IF(NOT DEFINED MAX_TELNETCONNECTIONS)
110 SET( MAX_TELNETCONNECTIONS 3 )
111 ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS)
113 SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
114 SET(LIB_INSTALL_SUFFIX "audioManager")
117 SET(DEFAULT_PLUGIN_COMMAND_DIR "${PLUGINS_OUTPUT_PATH}/command")
118 SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
119 SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
121 SET(DEFAULT_PLUGIN_COMMAND_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/command")
122 SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
123 SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
124 endif(USE_BUILD_LIBS)
126 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
127 SET(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/includes)
128 SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
129 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
130 SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
131 SET(DOXY_FILE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
132 SET(INTROSPECTION_COMMAND_XML_FILE "${AUDIO_INCLUDES_FOLDER}/dbus/CommandInterface.xml")
134 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/includes/config.h )
137 pkg_check_modules(DLT REQUIRED automotive-dlt)
140 IF(WITH_DOCUMENTATION)
141 find_package(Doxygen)
142 configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Doxyfile @ONLY IMMEDIATE)
143 add_custom_target (AudioManangerDoku ALL
144 COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
145 SOURCES ${CMAKE_SOURCE_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
147 ENDIF(WITH_DOCUMENTATION)
149 ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
150 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE -pedantic -Wno-variadic-macros")
151 #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")
153 if(WITH_PLUGIN_COMMAND)
154 add_subdirectory (PluginCommandInterfaceDbus)
155 endif(WITH_PLUGIN_COMMAND)
157 if(WITH_PLUGIN_ROUTING)
158 add_subdirectory (PluginRoutingInterfaceDbus)
159 add_subdirectory (PluginRoutingInterfaceAsync)
160 endif(WITH_PLUGIN_ROUTING)
162 if(WITH_PLUGIN_CONTROL)
163 add_subdirectory (PluginControlInterface)
164 endif(WITH_PLUGIN_CONTROL)
167 add_subdirectory (AudioManagerDaemon)
172 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
173 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
176 add_custom_target(uninstall
177 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
179 # Here starts package creation
180 SET(CPACK_SET_DESTDIR ON)
181 SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
182 SET(CPACK_GENERATOR "DEB")
183 SET(CPACK_PACKAGE_NAME "AudioManager")
184 SET(CPACK_PACKAGE_VENDOR "GENIVI")
185 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
186 SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
187 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
188 SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
189 SET(CPACK_PACKAGE_CONTACT "Christian Mueller (BMW) christian.ei.mueller@bmw.de")
190 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
191 SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
192 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
193 SET(CPACK_STRIP_FILES TRUE)
194 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
195 SET(CPACK_SOURCE_GENERATOR "TGZ")
196 SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" ".project" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h")
198 #evaluate the properties
200 get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
201 list(REMOVE_DUPLICATES ADD_DEPEND)
202 set(ALL_DEPEND ${ADD_DEPEND})
203 FOREACH (dep ${ADD_DEPEND})
204 SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
206 STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
209 get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
210 list(REMOVE_DUPLICATES ADD_DEPEND)
211 list(APPEND ALL_DEPEND ${ADD_DEPEND})
212 FOREACH (dep ${ADD_DEPEND})
213 SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
215 STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
218 get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
219 list(REMOVE_DUPLICATES ADD_DEPEND)
220 list(APPEND ALL_DEPEND ${ADD_DEPEND})
221 FOREACH (dep ${ADD_DEPEND})
222 SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
224 STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
227 get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
228 list(REMOVE_DUPLICATES ADD_DEPEND)
229 list(APPEND ALL_DEPEND ${ADD_DEPEND})
230 FOREACH (dep ${ADD_DEPEND})
231 SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
233 STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})
235 list(REMOVE_DUPLICATES ALL_DEPEND)
236 list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
237 FOREACH (dep ${ALL_DEPEND})
238 SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
240 STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
241 execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})
243 #component based dep package generation is only supported above 2.8.5
244 IF (${CMAKE_VERSION} VERSION_GREATER 2.9.4)
246 SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
247 SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
248 SET(CPACK_DEB_COMPONENT_INSTALL ON)
249 ADD_CUSTOM_TARGET(genivi_package
250 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
252 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
253 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
254 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
255 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
257 ELSE (${CMAKE_VERSION} VERSION_GREATER 2.9.4)
258 IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
259 ADD_CUSTOM_TARGET(genivi_package
260 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
262 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
264 ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
265 ADD_CUSTOM_TARGET(genivi_package
266 COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=ON
268 COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
269 COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
270 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
272 ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
273 ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.9.4)