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/.
18 cmake_minimum_required(VERSION 2.6)
20 PROJECT(AudioManagerDeamon)
22 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
23 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
25 set(DOC_OUTPUT_PATH ${DOC_OUTPUT_PATH}/AudioManager)
26 set(INCLUDE_FOLDER "include")
28 IF (WITH_DATABASE_STORAGE)
29 pkg_check_modules(SQLITE REQUIRED sqlite3)
30 ENDIF (WITH_DATABASE_STORAGE)
32 IF (WITH_SYSTEMD_WATCHDOG)
33 pkg_check_modules(SYSTEMD libsystemd-daemon>=44)
35 message(STATUS "Found libsystemd-daemon, version: ${SYSTEMD_VERSION}")
37 message(STATUS "Did not find libsystemd-daemon, using own lib")
39 ENDIF (WITH_SYSTEMD_WATCHDOG)
42 FIND_PACKAGE(DBUS REQUIRED)
43 ENDIF(WITH_DBUS_WRAPPER)
45 FIND_PACKAGE(NSM REQUIRED)
48 FIND_PACKAGE(CommonAPI REQUIRED)
49 ENDIF(WITH_CAPI_WRAPPER)
53 src/CAmCommandReceiver.cpp
54 src/CAmCommandSender.cpp
55 src/CAmControlReceiver.cpp
56 src/CAmControlSender.cpp
57 src/CAmDatabaseObserver.cpp
58 src/CAmRoutingReceiver.cpp
59 src/CAmRoutingSender.cpp
61 src/CAmSocketHandler.cpp
67 # Preallocation variable for the map.
68 IF(NOT WITH_DATABASE_STORAGE )
70 IF(NOT DEFINED AM_MAP_CAPACITY)
71 set (AM_MAP_CAPACITY 10)
72 ENDIF(NOT DEFINED AM_MAP_CAPACITY)
73 add_definitions( -DAM_MAP_CAPACITY=${AM_MAP_CAPACITY} )
75 IF(NOT DEFINED AM_MAX_CONNECTIONS)
76 set (AM_MAX_CONNECTIONS 0x1000)
77 ENDIF(NOT DEFINED AM_MAX_CONNECTIONS)
78 add_definitions( -DAM_MAX_CONNECTIONS=${AM_MAX_CONNECTIONS} )
80 IF(NOT DEFINED AM_MAX_MAIN_CONNECTIONS)
81 set (AM_MAX_MAIN_CONNECTIONS SHRT_MAX)
82 ENDIF(NOT DEFINED AM_MAX_MAIN_CONNECTIONS)
83 add_definitions( -DAM_MAX_MAIN_CONNECTIONS=${AM_MAX_MAIN_CONNECTIONS} )
85 ENDIF(NOT WITH_DATABASE_STORAGE)
88 SET (AUDIOMAN_SRCS_CXX
90 src/CAmTelnetServer.cpp
91 src/CAmTelnetMenuHelper.cpp
95 IF(WITH_SYSTEMD_WATCHDOG)
96 SET (AUDIOMAN_SRCS_CXX
100 ENDIF(WITH_SYSTEMD_WATCHDOG)
102 IF (NOT SYSTEMD_FOUND)
103 SET (AUDIOMAN_SRCS_CXX
107 ENDIF (NOT SYSTEMD_FOUND)
109 IF(WITH_DBUS_WRAPPER)
110 SET (AUDIOMAN_SRCS_CXX
112 src/CAmDbusWrapper.cpp
114 ENDIF(WITH_DBUS_WRAPPER)
116 IF(WITH_CAPI_WRAPPER)
117 SET (AUDIOMAN_SRCS_CXX
119 src/CAmCommonAPIWrapper.cpp
121 ENDIF(WITH_CAPI_WRAPPER)
124 IF(WITH_DBUS_WRAPPER)
125 SET (AUDIOMAN_SRCS_CXX
127 src/CAmNodeStateCommunicatorDBus.cpp
129 ELSE(WITH_DBUS_WRAPPER)
130 SET (AUDIOMAN_SRCS_CXX
132 src/CAmNodeStateCommunicatorCAPI.cpp
134 ENDIF(WITH_DBUS_WRAPPER)
137 IF(WITH_DATABASE_STORAGE)
138 SET (AUDIOMAN_SRCS_CXX
140 src/CAmDatabaseHandlerSQLite.cpp
142 ELSE(WITH_DATABASE_STORAGE)
143 SET (AUDIOMAN_SRCS_CXX
145 src/CAmDatabaseHandlerMap.cpp
147 ENDIF(WITH_DATABASE_STORAGE)
151 ${CMAKE_CURRENT_BINARY_DIR}
152 ${AUDIO_INCLUDE_FOLDER}
153 ${PROJECT_INCLUDE_FOLDER}
158 IF(WITH_CAPI_WRAPPER)
160 # Find the common-api sources.
161 # The sources can be placed in the build directory (DESTINATION) or in the source tree (ALT_DESTINATION).
162 # The ALT_DESTINATION is used as fall back if the DESTINATION directory dosen't contain the sources or you just don't want to use the generator.
163 INCLUDE(CommonAPIGenerator)
164 COMMON_API_GENERATE_SOUCRES(TARGET COMMON_API
165 FIDLS fidls/NodeStateManager.fdepl # a list with fidls
166 DESTINATION src-gen # a relative path to the build directory or an absolute path
167 ALT_DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src-gen # an alternative relative/absolute path with common-api sources, usually in the source tree
170 INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
171 ${COMMON_API_INCLUDE_DIRS}
172 ${COMMON_API_DBUS_INCLUDE_DIRS}
173 ${COMMON_API_GEN_INCLUDE_DIR}
175 ENDIF(WITH_CAPI_WRAPPER)
178 INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
183 IF(WITH_DBUS_WRAPPER)
184 INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
185 ${DBUS_ARCH_INCLUDE_DIR}
188 ENDIF(WITH_DBUS_WRAPPER)
190 file(GLOB ${AUDIOMAN_SRCS_CXX} ${COMMON_API_GEN_SOURCES})
192 ADD_EXECUTABLE(AudioManager ${AUDIOMAN_SRCS_CXX} ${COMMON_API_GEN_SOURCES})
194 TARGET_LINK_LIBRARIES(AudioManager
199 IF(WITH_DBUS_WRAPPER)
200 TARGET_LINK_LIBRARIES(AudioManager
204 ELSEIF(WITH_CAPI_WRAPPER)
205 TARGET_LINK_LIBRARIES(AudioManager
206 ${COMMON_API_LIBRARIES}
207 ${COMMON_API_DBUS_LIBRARIES}
213 TARGET_LINK_LIBRARIES(AudioManager
219 TARGET_LINK_LIBRARIES(AudioManager
222 ENDIF (SYSTEMD_FOUND)
224 IF(WITH_CAPI_WRAPPER)
226 INSERT_DBUS_CONF_IF_NEEDED("@NSM_DBUS_CONF@"
227 "${CMAKE_SOURCE_DIR}/AudioManagerDaemon/fidls/NodeStateManager_dbus.conf"
230 # Generates the dbus configuration file. Every component is responsible to append it dbus configuration part.
231 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/fidls/AudioManager_dbus.conf.in ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/fidls/AudioManager_dbus.conf)
232 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/fidls/AudioManager_dbus.conf.in ${CMAKE_BINARY_DIR}/AudioManager_dbus.conf)
234 ENDIF(WITH_CAPI_WRAPPER)
237 INSTALL(TARGETS AudioManager
240 PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
244 INSTALL(DIRECTORY "${AUDIO_INCLUDE_FOLDER}/"
251 SET(NSM_INTROSPECTION_FILE ${EXECUTABLE_OUTPUT_PATH}/LifeCycleConsumer.xml)
253 COMMAND mkdir -p "${CMAKE_SOURCE_DIR}/bin"
254 COMMAND cp "${CMAKE_SOURCE_DIR}/cmake/LifecycleConsumer.xml" ${NSM_INTROSPECTION_FILE}
255 COMMAND cp "${CMAKE_BINARY_DIR}/AudioManager_dbus.conf" ${EXECUTABLE_OUTPUT_PATH})
257 SET(NSM_INTROSPECTION_FILE ${CMAKE_INSTALL_PREFIX}/share/audiomanager/LifecycleConsumer.xml)
259 FILES ${CMAKE_SOURCE_DIR}/cmake/LifecycleConsumer.xml #${CMAKE_BINARY_DIR}/AudioManager_dbus.conf
260 DESTINATION "${NSM_INTROSPECTION_FILE}"
262 ENDIF(USE_BUILD_LIBS)
265 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h )
268 add_subdirectory (test)
271 # General packet dependency
272 IF(WITH_DATABASE_STORAGE)
273 SET(ADD_DEPEND_BIN_PROP "sqlite3(>=3.6.22)")
274 ENDIF(WITH_DATABASE_STORAGE)
276 # Optional packet dependency
278 SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "dlt")
281 IF(WITH_DBUS_WRAPPER)
282 SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "libdbus-1-3(>=1.2.16)")
283 ENDIF(WITH_DBUS_WRAPPER)
285 # Additional Dev packet dependency
286 SET(ADD_DEPEND_DEV_PROP "audiomanager-bin" ${ADD_DEPEND_BIN_PROP})
288 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fno-common -fno-strict-aliasing -DNDEBUG")
290 MESSAGE(STATUS "bin packet dependency: ${ADD_DEPEND_BIN_PROP}")
291 MESSAGE(STATUS "dev dependency: ${ADD_DEPEND_DEV_PROP}")
293 set_property(GLOBAL APPEND PROPERTY bin_prop "${ADD_DEPEND_BIN_PROP}")
294 set_property(GLOBAL APPEND PROPERTY dev_prop "${ADD_DEPEND_DEV_PROP}")