summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: ec2782dcbad4302ed2162b7f8d96b0deea810364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# Copyright (C) 2012, BMW AG
#
# This file is part of GENIVI Project AudioManager.
# 
# Contributions are licensed to the GENIVI Alliance under one or more
# Contribution License Agreements.
# 
# copyright
# This Source Code Form is subject to the terms of the
# Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
# 
# author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
#
# For further information see http://www.genivi.org/.
#


cmake_minimum_required(VERSION 2.6)

execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 
                OUTPUT_VARIABLE DAEMONVERSION 
                OUTPUT_STRIP_TRAILING_WHITESPACE)           

IF (NOT DAEMONVERSION)
    #Can be changed via passing -DVERSION="XXX" to cmake
    IF(NOT DEFINED VERSION)
        SET( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" )
    ELSE (NOT DEFINED VERSION)
        SET( DAEMONVERSION "${VERSION}" )   
    ENDIF(NOT DEFINED VERSION)
ELSE (NOT DAEMONVERSION)
    STRING(REGEX REPLACE "(-)[^-]+$" "" DAEMONVERSION ${DAEMONVERSION})
    STRING(REGEX REPLACE "-" "." DAEMONVERSION ${DAEMONVERSION})
ENDIF(NOT DAEMONVERSION)

message(STATUS "Build Version ${DAEMONVERSION}")

execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 
                OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG)

PROJECT(AudioManagerDeamon)

FIND_PACKAGE(PkgConfig)

OPTION( WITH_DBUS_WRAPPER 
	"Enable Dbus Wrapper Support" ON )
	
OPTION( WITH_DLT 
    "Enable automotive-DLT Support" ON )

OPTION( WITH_TESTS
	"Build together with all available unitTest" ON )

OPTION( WITH_DOCUMENTATION
	"Build together with Doxygen Documentation" OFF )

OPTION( WITH_PLUGIN_COMMAND
	"Build command pluings" ON)

OPTION( WITH_PLUGIN_CONTROL
	"Build control plugin" ON)

OPTION( WITH_PLUGIN_ROUTING
	"Build routing pluings" ON)

OPTION( WITH_TELNET
	"build with Telnetserver (can only work with SocketHandler)" ON)
	
OPTION ( WITH_SYSTEMD_WATCHDOG
    "build with systemD support & watchdog" OFF)
	
OPTION ( USE_BUILD_LIBS
	"build with default library path = build path" ON)
	
OPTION ( GLIB_DBUS_TYPES_TOLERANT
    "build dbus with tolerance towards glib 16bit/32bit handling" ON)

OPTION ( WITH_NSM
    "build with NSM support" ON)
    
 OPTION ( WITH_DATABASE_STORAGE
    "build with sqlite as in memory storage" OFF)
    
IF (NOT WITH_DBUS_WRAPPER)
    SET (WITH_NSM OFF)
ENDIF (NOT WITH_DBUS_WRAPPER)
 
#Can be changed via passing -DDBUS_SERVICE_PREFIX="XXX" to cmake
IF(NOT DEFINED DBUS_SERVICE_PREFIX)
	SET( DBUS_SERVICE_PREFIX "org.genivi.audiomanager\0")
ENDIF(NOT DEFINED DBUS_SERVICE_PREFIX)

#Can be changed via passing -DDBUS_SERVICE_OBJECT_PATH="XXX" to cmake
IF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)
	SET( DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager\0" )
ENDIF(NOT DEFINED DBUS_SERVICE_OBJECT_PATH)

#Can be changed via passing -DDEFAULT_TELNETPORT="XXX" to cmake
IF(NOT DEFINED DEFAULT_TELNETPORT)
	SET( DEFAULT_TELNETPORT 6080 )
ENDIF(NOT DEFINED DEFAULT_TELNETPORT)

#Can be changed via passing -DMAX_TELNETCONNECTIONS="XXX" to cmake
IF(NOT DEFINED MAX_TELNETCONNECTIONS)
	SET( MAX_TELNETCONNECTIONS 3 )
ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS)

#Can be changed via passing -DNSM_BUS_INTERFACE="XXX" to cmake
IF(NOT DEFINED NSM_BUS_INTERFACE)
	SET( NSM_BUS_INTERFACE "org.genivi.NodeStateManager")
ENDIF(NOT DEFINED NSM_BUS_INTERFACE)

#Can be changed via passing -DNSM_PATH="XXX" to cmake
IF(NOT DEFINED NSM_PATH)
	SET( NSM_PATH "/org/genivi/NodeStateManager")
ENDIF(NOT DEFINED NSM_PATH)

#Can be changed via passing -DNSM_INTERFACE="XXX" to cmake
IF(NOT DEFINED NSM_INTERFACE)
	SET( NSM_INTERFACE "org.genivi.NodeStateManager.Consumer")
ENDIF(NOT DEFINED NSM_INTERFACE)

SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins)
SET(LIB_INSTALL_SUFFIX "audioManager")

if(USE_BUILD_LIBS)
	IF(NOT DEFINED DEFAULT_PLUGIN_COMMAND_DIR)
		SET(DEFAULT_PLUGIN_COMMAND_DIR "${PLUGINS_OUTPUT_PATH}/command")
	ENDIF(NOT DEFINED DEFAULT_PLUGIN_COMMAND_DIR)	
	IF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)	
		SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
	ENDIF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)		
	IF(NOT DEFINED CONTROLLER_PLUGIN)
		SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
	ENDIF(NOT DEFINED CONTROLLER_PLUGIN)
else(USE_BUILD_LIBS)
	IF(NOT DEFINED DEFAULT_PLUGIN_COMMAND_DIR)
		SET(DEFAULT_PLUGIN_COMMAND_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/command")
	ENDIF(NOT DEFINED DEFAULT_PLUGIN_COMMAND_DIR)
	IF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)
		SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
	ENDIF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)
	IF(NOT DEFINED CONTROLLER_PLUGIN)
		SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
	ENDIF(NOT DEFINED CONTROLLER_PLUGIN)
endif(USE_BUILD_LIBS)

IF(EXISTS "ProjectSpecific/")
    SET(PROJECT_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/ProjectSpecific/include)
endif(EXISTS "ProjectSpecific/")

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
SET(AUDIO_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/include)
SET(DOC_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/doc)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test)
SET(DOXY_PROTOTYPE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in)
SET(DOXY_FILE ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile)

CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/docx/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile )

IF(WITH_DLT)    
    pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)   
ENDIF(WITH_DLT)

IF(WITH_TESTS)	
	add_subdirectory(googleMock)
	set(GMOCK_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/googleMock/include")
	set(GOOGLE_TEST_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/googleMock/gtest/include")
ENDIF(WITH_TESTS)

IF(WITH_DOCUMENTATION)
	find_package(Doxygen)
	configure_file(${DOXY_FILE}  ${DOC_OUTPUT_PATH}/Doxyfile  @ONLY IMMEDIATE)
  	add_custom_target (AudioManangerDoku ALL 
  		COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
  		SOURCES ${CMAKE_SOURCE_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
	)
ENDIF(WITH_DOCUMENTATION)

##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=gnu++0x -D_GNU_SOURCE -pedantic -Wno-variadic-macros -Wno-long-long")
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE")

if(WITH_PLUGIN_COMMAND)
	add_subdirectory (PluginCommandInterfaceDbus)
endif(WITH_PLUGIN_COMMAND)

if(WITH_PLUGIN_ROUTING)
	add_subdirectory (PluginRoutingInterfaceDbus)
	add_subdirectory (PluginRoutingInterfaceAsync)
endif(WITH_PLUGIN_ROUTING)

if(WITH_PLUGIN_CONTROL)
	add_subdirectory (PluginControlInterface)
endif(WITH_PLUGIN_CONTROL)

add_subdirectory (AudioManagerDaemon)

IF(EXISTS "${CMAKE_SOURCE_DIR}/ProjectSpecific/")
    add_subdirectory (ProjectSpecific)
endif(EXISTS "${CMAKE_SOURCE_DIR}/ProjectSpecific/")

# uninstall target
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

add_custom_target(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

# Here starts package creation
SET(CPACK_SET_DESTDIR ON)
SET(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/packages)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_NAME "AudioManager")
SET(CPACK_PACKAGE_VENDOR "GENIVI")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AudioManager: This component manages audio in the GENIVI context")
SET(CPACK_PACKAGE_VERSION "${DAEMONVERSION}")
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENCE)
SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
SET(CPACK_PACKAGE_CONTACT "Christian Linke(BMW) christian.linke@bmw.de")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "genivi")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "*")
SET(CPACK_STRIP_FILES TRUE)
SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES ".settings*" ".cproject" "/\\\\.metadata" "\\\\.#" "/#" ".*~" "/\\\\.git" "${CMAKE_CURRENT_BINARY_DIR}" "bin/" "packages/" "config.h") 

IF(WITH_TESTS)
	get_property(ADD_DEPEND GLOBAL PROPERTY tests_prop)
	list(REMOVE_DUPLICATES ADD_DEPEND)
	list(APPEND ALL_DEPEND ${ADD_DEPEND})
	FOREACH (dep ${ADD_DEPEND})	
		SET(tests_DEPENDENCIES "${dep} ,${tests_DEPENDENCIES}")
	ENDFOREACH(dep)
	STRING(REGEX REPLACE ".$" "" tests_DEPENDENCIES ${tests_DEPENDENCIES})
ENDIF(WITH_TESTS)

#evaluate the properties
if(WITH_MAIN)
get_property(ADD_DEPEND GLOBAL PROPERTY bin_prop)
list(REMOVE_DUPLICATES ADD_DEPEND)
set(ALL_DEPEND ${ADD_DEPEND})
FOREACH (dep ${ADD_DEPEND})
	SET(bin_DEPENDENCIES "${dep} ,${bin_DEPENDENCIES}")
ENDFOREACH(dep)
STRING(REGEX REPLACE ".$" "" bin_DEPENDENCIES ${bin_DEPENDENCIES})
endif(WITH_MAIN)

if(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)
get_property(ADD_DEPEND GLOBAL PROPERTY sampleplugins_prop)
list(REMOVE_DUPLICATES ADD_DEPEND)
list(APPEND ALL_DEPEND ${ADD_DEPEND})
FOREACH (dep ${ADD_DEPEND})
	SET(sampleplugins_DEPENDENCIES "${dep} ,${sampleplugins_DEPENDENCIES}")
ENDFOREACH(dep)
STRING(REGEX REPLACE ".$" "" sampleplugins_DEPENDENCIES ${sampleplugins_DEPENDENCIES})
endif(WITH_PLUGIN_COMMAND OR WITH_PLUGIN_CONTROL OR WITH_PLUGIN_ROUTING)

get_property(ADD_DEPEND GLOBAL PROPERTY dev_prop)
list(REMOVE_DUPLICATES ADD_DEPEND)
list(APPEND ALL_DEPEND ${ADD_DEPEND})
FOREACH (dep ${ADD_DEPEND})
	SET(dev_DEPENDENCIES "${dep} ,${dev_DEPENDENCIES}")
ENDFOREACH(dep)
STRING(REGEX REPLACE ".$" "" dev_DEPENDENCIES ${dev_DEPENDENCIES})

list(REMOVE_DUPLICATES ALL_DEPEND)
list(REMOVE_ITEM ALL_DEPEND "audiomanager-bin")
FOREACH (dep ${ALL_DEPEND})
	SET(all_DEPENDENCIES "${dep} ,${all_DEPENDENCIES}")
ENDFOREACH(dep)
STRING(REGEX REPLACE ".$" "" all_DEPENDENCIES ${all_DEPENDENCIES})
execute_process(COMMAND cp ${CMAKE_MODULE_PATH}/add_package_dependencies.sh ${CMAKE_CURRENT_BINARY_DIR})

#component based dep package generation is only supported above 2.8.5
IF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)

	SET(CPACK_COMPONENTS_ALL bin sampleplugins tests dev)
	SET(CPACK_COMPONENTS_IGNORE_GROUPS 1)
	SET(CPACK_DEB_COMPONENT_INSTALL ON)
	ADD_CUSTOM_TARGET(genivi_package 
		COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=OFF
		COMMAND make package
		COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-bin.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${bin_DEPENDENCIES}\"
		COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-sampleplugins.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${sampleplugins_DEPENDENCIES}\"
		COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-tests.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${tests_DEPENDENCIES}\"
		COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux-dev.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${dev_DEPENDENCIES}\"
	) 
ELSE (${CMAKE_VERSION} VERSION_GREATER 2.8.5)
	IF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
		ADD_CUSTOM_TARGET(genivi_package 
			COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=OFF
			COMMAND make package
			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}\"
		)
	ELSE(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
		ADD_CUSTOM_TARGET(genivi_package 
			COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DUSE_BUILD_LIBS=OFF
			COMMAND make package
			COMMAND mkdir -p ../${CPACK_OUTPUT_FILE_PREFIX}
			COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX}
			COMMAND ${CMAKE_CURRENT_BINARY_DIR}/add_package_dependencies.sh ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Linux.deb ${CPACK_OUTPUT_FILE_PREFIX} \"${all_DEPENDENCIES}\"
		)
	ENDIF(${CMAKE_VERSION} VERSION_GREATER 2.8.3)
ENDIF (${CMAKE_VERSION} VERSION_GREATER 2.8.5)

INCLUDE(CPack)