1 # Copyright (c) 2013, Ford Motor Company
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # Redistributions of source code must retain the above copyright notice, this
8 # list of conditions and the following disclaimer.
10 # Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided with the
15 # Neither the name of the Ford Motor Company nor the names of its contributors
16 # may be used to endorse or promote products derived from this software
17 # without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
31 #Jenkins integration section
32 #dont modify this section if you dont know details about integration with Jenkins!!!
33 set (HMI "web" CACHE STRING "HMI type")
34 option(HMI2 "Use Qt HMI" OFF)
35 option(EXTENDED_MEDIA_MODE "Turn on and off extended Madia Manager features relates to PulseAudio A2DP and GSteamer" OFF)
36 option(BUILD_SHARED_LIBS "Build all libraries as shared (if ON) or static (if OFF)" OFF)
37 option(BUILD_BT_SUPPORT "Bluetooth support" ON)
38 option(BUILD_USB_SUPPORT "libusb support" ON)
39 option(BUILD_AVAHI_SUPPORT "libavahi support" ON)
40 option(BUILD_RWLOCK_SUPPORT "rwlocks support" OFF)
41 option(BUILD_BACKTRACE_SUPPORT "backtrace support" ON)
42 option(BUILD_TESTS "Possibility to build and run tests" OFF)
43 option(BUILD_TESTS_WITH_HMI "Possibility to build and run HMI tests" OFF)
44 option(ENABLE_LOG "Logging feature" ON)
46 set(OS_TYPE_OPTION "$ENV{OS_TYPE}")
47 set(DEBUG_OPTION "$ENV{DEBUG}")
48 set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}")
49 set(TARGET_OPTION "$ENV{TARGET}")
50 set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}")
51 set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}")
54 if (${OS_TYPE_OPTION} STREQUAL "QNX")
55 message(STATUS "Jenkins integration: set build process for QNX")
56 INCLUDE("./qnx_6.5.0_linux_x86.cmake")
57 #tests are not supported yet for QNX build
63 if (${HMI_TYPE_OPTION} STREQUAL "HTML5")
64 message(STATUS "Jenkins integration: select HTML5 HMI")
66 elseif (${HMI_TYPE_OPTION} STREQUAL "NONE")
67 message(STATUS "Jenkins integration: select HMI none")
70 message(STATUS "Jenkins integration: select QML HMI none")
75 if (MEDIA_MODE_OPTION)
76 if (${MEDIA_MODE_OPTION} STREQUAL "EXTENDED_MEDIA")
77 message(STATUS "Jenkins integration: select extended media mode")
78 set (EXTENDED_MEDIA_MODE ON)
83 if (${DEBUG_OPTION} STREQUAL "DBG_OFF")
84 message(STATUS "Jenkins integration: build release version")
85 set (CMAKE_BUILD_TYPE Release)
89 if (HMI_ADAPTER_OPTION)
90 if (${HMI_ADAPTER_OPTION} STREQUAL "MESSAGEBROKER")
91 message(STATUS "Jenkins integration: selected HMI adapter MESSAGEBROKER")
92 set (HMIADAPTER "messagebroker")
93 elseif (${HMI_ADAPTER_OPTION} STREQUAL "DBUS")
94 message(STATUS "Jenkins integration: selected HMI adapter DBUS")
95 set (HMIADAPTER "dbus")
96 elseif (${HMI_ADAPTER_OPTION} STREQUAL "MQUEUE")
97 message(STATUS "Jenkins integration: selected HMI adapter MQUEUE")
98 set (HMIADAPTER "mqueue")
102 #Jenkins integration section end
105 cmake_minimum_required(VERSION 2.8.0)
107 set (PROJECT smartDeviceLinkCore)
110 #ADD_DEPENDENCIES(${PROJECT} Policy)
112 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
114 # Please do not change compiler/linker flags if You do not know how particular
115 # flag is handled by CMake
116 set(CMAKE_INSTALL_PREFIX .)
117 set(ARCHIVE_OUTPUT_DIRECTORY ./bin)
118 set(CMAKE_CXX_FLAGS "-g3 -ggdb3 -std=gnu++0x -Werror=return-type -Wuninitialized --coverage")
119 set(CMAKE_CXX_FLAGS_RELEASE "-s -O2") #It will be appended to CMAKE_CXX_FLAGS in release
121 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
122 add_definitions(-DOS_LINUX)
123 elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
124 add_definitions(-DOS_QNX)
125 SET(BUILD_BT_SUPPORT OFF)
126 SET(BUILD_AVAHI_SUPPORT OFF)
127 SET(BUILD_BACKTRACE_SUPPORT OFF)
128 SET(EXTENDED_MEDIA_MODE OFF)
131 if (BUILD_USB_SUPPORT)
132 add_definitions(-DUSB_SUPPORT)
135 if (BUILD_BT_SUPPORT)
136 add_definitions(-DBLUETOOTH_SUPPORT)
139 if (BUILD_AVAHI_SUPPORT)
140 add_definitions(-DAVAHI_SUPPORT)
141 # --- Check libavahi-common, libavahi-client availability
142 find_package(Libavahi)
145 if (BUILD_RWLOCK_SUPPORT)
146 add_definitions(-DRWLOCK_SUPPORT)
149 if (BUILD_BACKTRACE_SUPPORT)
150 add_definitions(-DBACKTRACE_SUPPORT)
154 add_definitions(-DENABLE_LOG)
157 # TODO(AK): check current OS here
158 add_definitions(-DOS_POSIX)
160 # FIXME(DC): weird logic
161 IF(CMAKE_C_FLAGS_DEBUG)
162 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG" )
163 add_definitions(-DDEBUG)
164 ELSE (CMAKE_C_FLAGS_DEBUG)
165 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRELEASE" )
166 add_definitions(-DRELEASE)
167 ENDIF(CMAKE_C_FLAGS_DEBUG)
170 if (EXTENDED_MEDIA_MODE)
171 add_definitions(-DEXTENDED_MEDIA_MODE)
172 # required to find 'glibconfig.h'
173 find_package(PkgConfig)
174 pkg_check_modules(GLIB2 REQUIRED glib-2.0)
175 add_definitions(${GLIB2_CFLAGS})
178 # --- Interface generator
180 find_package(PythonInterp)
181 if(NOT PYTHONINTERP_FOUND)
182 message(ERROR "Python interpreter is not found")
183 message(ERROR "To install it type in the command line:")
184 message(ERROR "sudo apt-get install python")
185 endif(NOT PYTHONINTERP_FOUND)
187 if (HMI STREQUAL "qt")
188 cmake_minimum_required(VERSION 2.8.11)
189 if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
190 set(qt_version "4.8.5")
192 set(qt_version "5.1.0")
196 COMMAND ${CMAKE_SOURCE_DIR}/FindQt.sh -v ${qt_version}
197 OUTPUT_VARIABLE qt_bin_dir
199 message(STATUS "Binary directory Qt ${qt_version} is ${qt_bin_dir}")
200 set(ENV{PATH} ${qt_bin_dir}:$ENV{PATH})
202 if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
203 find_package(Qt4 ${qt_version} REQUIRED QtCore QtGui QtDBus QtDeclarative)
205 find_package(Qt5Core REQUIRED)
206 find_package(Qt5DBus REQUIRED)
207 find_package(Qt5Qml REQUIRED)
208 find_package(Qt5Quick REQUIRED)
209 set(qmlplugindump_binary ${qt_bin_dir}/qmlplugindump)
213 set(INTEFRACE_GENERATOR "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/Generator.py")
214 set(INTEFRACE_GENERATOR_CMD ${PYTHON_EXECUTABLE} -B ${INTEFRACE_GENERATOR})
215 file(GLOB_RECURSE INTERFACE_GENERATOR_DEPENDENCIES "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/*.*")
217 macro (GenerateInterface arg_xml_name arg_namespace parser_type)
218 string(REGEX MATCH "^[a-zA-Z_0-9]*[^.]" file_name ${arg_xml_name}) # TODO: make expression more robust
221 "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h"
222 "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.h"
225 set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.cc")
226 set(full_xml_name "${CMAKE_CURRENT_SOURCE_DIR}/${arg_xml_name}")
228 add_custom_command( OUTPUT ${hpp_file} ${cpp_file}
229 COMMAND ${INTEFRACE_GENERATOR_CMD} ${full_xml_name} ${arg_namespace} ${CMAKE_CURRENT_BINARY_DIR} "--parser-type" "${parser_type}"
230 DEPENDS ${INTERFACE_GENERATOR_DEPENDENCIES} ${full_xml_name}
231 COMMENT "Generating files:\n ${hpp_file}\n ${cpp_file}\nfrom:\n ${arg_xml_name} ..."
235 include_directories (
236 ../../../src/components/smart_objects/include
237 ../../../src/components/formatters/include/
238 ${CMAKE_SOURCE_DIR}/src/components/formatters/include/
242 add_library("${file_name}" ${cpp_file})
243 endmacro(GenerateInterface)
246 macro(create_test NAME SOURCES LIBS)
247 add_executable("${NAME}" ${SOURCES})
248 target_link_libraries("${NAME}" ${LIBS})
249 if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
250 add_test(${NAME} ${CMAKE_SOURCE_DIR}/qnx/remote_run_test.sh ${NAME})
252 add_test(${NAME} ${NAME})
254 endmacro(create_test)
256 # Building application
259 if (HMI STREQUAL "qt")
261 add_definitions(-DQT_HMI)
262 elseif (HMI STREQUAL "web")
264 add_definitions(-DWEB_HMI)
267 add_definitions(-DNO_HMI)
270 if (HMI STREQUAL "qt" AND NOT DEFINED HMIADAPTER)
271 set(HMIADAPTER "dbus")
273 if (HMI STREQUAL "web" AND NOT DEFINED HMIADAPTER)
274 set(HMIADAPTER "messagebroker")
276 if (HMI STREQUAL "no" AND NOT DEFINED HMIADAPTER)
277 set(HMIADAPTER "mqueue")
280 if (HMIADAPTER STREQUAL "dbus")
282 add_definitions(-DDBUS_HMIADAPTER)
283 add_definitions(-DHMI_DBUS_API)
285 if (HMIADAPTER STREQUAL "messagebroker")
287 add_definitions(-DMESSAGEBROKER_HMIADAPTER)
288 add_definitions(-DHMI_JSON_API)
290 if (HMIADAPTER STREQUAL "mqueue")
292 add_definitions(-DMQUEUE_HMIADAPTER)
293 add_definitions(-DHMI_JSON_API)
297 add_subdirectory(./src/thirdPartyLibs)
300 add_subdirectory(./tools)
303 add_subdirectory(./src/components)
305 # --- Main application
306 add_subdirectory(./src/appMain)
310 if(BUILD_TESTS_WITH_HMI)
311 add_definitions(-DTESTS_WITH_HMI)
315 # Framework GoogleTest is also integrated together gmock
316 # and must not be added separately
317 add_subdirectory(./src/thirdPartyLibs/gmock-1.6.0)
318 add_subdirectory(./test)
321 # Building documentation
323 # At first creating directory for generated documentation. Unfortunately doxygen
324 # cannot generate it byself
325 FIND_PACKAGE(Doxygen)
327 option(DOXYGEN_ENABLE_DIAGRAMS "Enable graphical diagram generation" ON)
329 if(DOXYGEN_ENABLE_DIAGRAMS)
330 set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "YES")
331 else(DOXYGEN_ENABLE_DIAGRAMS)
332 set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "NO")
334 configure_file("${PROJECT_SOURCE_DIR}/Doxyfile" "${PROJECT_BINARY_DIR}/Doxyfile")
335 file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc/doxygen")
336 ADD_CUSTOM_TARGET(doxygen COMMAND ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile")
338 MESSAGE(STATUS "Doxygen not found. Documentation will not be generated")
339 MESSAGE(STATUS "To enable documentation generation please install doxygen and graphviz packages")
340 MESSAGE(STATUS "sudo apt-get install doxygen graphviz")
341 MESSAGE(STATUS "To enable processing of MscGen comments please install mscgen")
342 MESSAGE(STATUS "sudo apt-get install mscgen")