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 GStreamer" 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" OFF)
39 option(BUILD_AVAHI_SUPPORT "libavahi support" OFF)
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" ON)
43 option(BUILD_TESTS_WITH_HMI "Possibility to build and run HMI tests" OFF)
44 option(ENABLE_LOG "Logging feature" ON)
45 option(EXTENDED_POLICY_FLAG "Build with specific features and extended functionality" OFF)
47 set(OS_TYPE_OPTION "$ENV{OS_TYPE}")
48 set(DEBUG_OPTION "$ENV{DEBUG}")
49 set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}")
50 set(TARGET_OPTION "$ENV{TARGET}")
51 set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}")
52 set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}")
55 if (${OS_TYPE_OPTION} STREQUAL "QNX")
56 message(STATUS "Jenkins integration: set build process for QNX")
57 INCLUDE("./qnx_6.5.0_linux_x86.cmake")
58 #tests are not supported yet for QNX build
64 if (${HMI_TYPE_OPTION} STREQUAL "HTML5")
65 message(STATUS "Jenkins integration: select HTML5 HMI")
67 elseif (${HMI_TYPE_OPTION} STREQUAL "NONE")
68 message(STATUS "Jenkins integration: select HMI none")
71 message(STATUS "Jenkins integration: select QML HMI none")
76 if (MEDIA_MODE_OPTION)
77 if (${MEDIA_MODE_OPTION} STREQUAL "EXTENDED_MEDIA")
78 message(STATUS "Jenkins integration: select extended media mode")
79 set (EXTENDED_MEDIA_MODE ON)
84 if (${DEBUG_OPTION} STREQUAL "DBG_OFF")
85 message(STATUS "Jenkins integration: build release version")
86 set (CMAKE_BUILD_TYPE Release)
90 if (HMI_ADAPTER_OPTION)
91 if (${HMI_ADAPTER_OPTION} STREQUAL "MESSAGEBROKER")
92 message(STATUS "Jenkins integration: selected HMI adapter MESSAGEBROKER")
93 set (HMIADAPTER "messagebroker")
94 elseif (${HMI_ADAPTER_OPTION} STREQUAL "DBUS")
95 message(STATUS "Jenkins integration: selected HMI adapter DBUS")
96 set (HMIADAPTER "dbus")
97 elseif (${HMI_ADAPTER_OPTION} STREQUAL "MQUEUE")
98 message(STATUS "Jenkins integration: selected HMI adapter MQUEUE")
99 set (HMIADAPTER "mqueue")
103 #Jenkins integration section end
106 cmake_minimum_required(VERSION 2.8.0)
108 set (PROJECT smartDeviceLinkCore)
111 #ADD_DEPENDENCIES(${PROJECT} Policy)
113 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
115 # Please do not change compiler/linker flags if You do not know how particular
116 # flag is handled by CMake
117 set(CMAKE_INSTALL_PREFIX .)
118 set(ARCHIVE_OUTPUT_DIRECTORY ./bin)
119 set(CMAKE_CXX_FLAGS "-fPIC -g3 -ggdb3 -std=gnu++0x -Werror=return-type -Wuninitialized --coverage")
120 set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -s -O2") #It will be appended to CMAKE_CXX_FLAGS in release
122 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
123 add_definitions(-DOS_LINUX)
124 elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
125 add_definitions(-DOS_QNX)
126 SET(BUILD_BT_SUPPORT OFF)
127 SET(BUILD_AVAHI_SUPPORT OFF)
128 SET(BUILD_BACKTRACE_SUPPORT OFF)
129 SET(EXTENDED_MEDIA_MODE OFF)
132 if (BUILD_USB_SUPPORT)
133 add_definitions(-DUSB_SUPPORT)
136 if (BUILD_BT_SUPPORT)
137 add_definitions(-DBLUETOOTH_SUPPORT)
140 if (BUILD_AVAHI_SUPPORT)
141 add_definitions(-DAVAHI_SUPPORT)
142 # --- Check libavahi-common, libavahi-client availability
143 find_package(Libavahi)
146 if (BUILD_RWLOCK_SUPPORT)
147 add_definitions(-DRWLOCK_SUPPORT)
150 if (BUILD_BACKTRACE_SUPPORT)
151 add_definitions(-DBACKTRACE_SUPPORT)
155 add_definitions(-DENABLE_LOG)
158 # TODO(AK): check current OS here
159 add_definitions(-DOS_POSIX)
161 # FIXME(DC): weird logic
162 IF(CMAKE_C_FLAGS_DEBUG)
163 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG" )
164 add_definitions(-DDEBUG)
165 ELSE (CMAKE_C_FLAGS_DEBUG)
166 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRELEASE" )
167 add_definitions(-DRELEASE)
168 ENDIF(CMAKE_C_FLAGS_DEBUG)
171 if (EXTENDED_MEDIA_MODE)
172 add_definitions(-DEXTENDED_MEDIA_MODE)
173 # required to find 'glibconfig.h'
174 find_package(PkgConfig)
175 pkg_check_modules(GLIB2 REQUIRED glib-2.0)
176 add_definitions(${GLIB2_CFLAGS})
179 # --- Interface generator
181 find_package(PythonInterp)
182 if(NOT PYTHONINTERP_FOUND)
183 message(ERROR "Python interpreter is not found")
184 message(ERROR "To install it type in the command line:")
185 message(ERROR "sudo apt-get install python")
186 endif(NOT PYTHONINTERP_FOUND)
188 if (HMI STREQUAL "qt")
189 cmake_minimum_required(VERSION 2.8.11)
190 if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
191 set(qt_version "4.8.5")
193 set(qt_version "5.1.0")
197 COMMAND ${CMAKE_SOURCE_DIR}/FindQt.sh -v ${qt_version}
198 OUTPUT_VARIABLE qt_bin_dir
200 message(STATUS "Binary directory Qt ${qt_version} is ${qt_bin_dir}")
201 set(ENV{PATH} ${qt_bin_dir}:$ENV{PATH})
203 if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
204 find_package(Qt4 ${qt_version} REQUIRED QtCore QtGui QtDBus QtDeclarative)
206 find_package(Qt5Core REQUIRED)
207 find_package(Qt5DBus REQUIRED)
208 find_package(Qt5Qml REQUIRED)
209 find_package(Qt5Quick REQUIRED)
210 set(qmlplugindump_binary ${qt_bin_dir}/qmlplugindump)
214 set(INTEFRACE_GENERATOR "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/Generator.py")
215 set(INTEFRACE_GENERATOR_CMD ${PYTHON_EXECUTABLE} -B ${INTEFRACE_GENERATOR})
216 file(GLOB_RECURSE INTERFACE_GENERATOR_DEPENDENCIES "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/*.*")
218 macro (GenerateInterface arg_xml_name arg_namespace parser_type)
219 string(REGEX MATCH "^[a-zA-Z_0-9]*[^.]" file_name ${arg_xml_name}) # TODO: make expression more robust
222 "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h"
223 "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.h"
226 set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.cc")
227 set(full_xml_name "${CMAKE_CURRENT_SOURCE_DIR}/${arg_xml_name}")
229 add_custom_command( OUTPUT ${hpp_file} ${cpp_file}
230 COMMAND ${INTEFRACE_GENERATOR_CMD} ${full_xml_name} ${arg_namespace} ${CMAKE_CURRENT_BINARY_DIR} "--parser-type" "${parser_type}"
231 DEPENDS ${INTERFACE_GENERATOR_DEPENDENCIES} ${full_xml_name}
232 COMMENT "Generating files:\n ${hpp_file}\n ${cpp_file}\nfrom:\n ${arg_xml_name} ..."
236 include_directories (
237 ../../../src/components/smart_objects/include
238 ../../../src/components/formatters/include/
239 ${CMAKE_SOURCE_DIR}/src/components/formatters/include/
243 add_library("${file_name}" ${cpp_file})
244 endmacro(GenerateInterface)
247 macro(create_test NAME SOURCES LIBS)
248 add_executable("${NAME}" ${SOURCES})
249 target_link_libraries("${NAME}" ${LIBS})
250 if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
251 add_test(${NAME} ${CMAKE_SOURCE_DIR}/qnx/remote_run_test.sh ${NAME})
253 add_test(${NAME} ${NAME})
255 endmacro(create_test)
257 # Building application
260 if (HMI STREQUAL "qt")
262 add_definitions(-DQT_HMI)
263 elseif (HMI STREQUAL "web")
265 add_definitions(-DWEB_HMI)
268 add_definitions(-DNO_HMI)
271 if (HMI STREQUAL "qt" AND NOT DEFINED HMIADAPTER)
272 set(HMIADAPTER "dbus")
274 if (HMI STREQUAL "web" AND NOT DEFINED HMIADAPTER)
275 set(HMIADAPTER "messagebroker")
277 if (HMI STREQUAL "no" AND NOT DEFINED HMIADAPTER)
278 set(HMIADAPTER "mqueue")
281 if (HMIADAPTER STREQUAL "dbus")
283 add_definitions(-DDBUS_HMIADAPTER)
284 add_definitions(-DHMI_DBUS_API)
286 if (HMIADAPTER STREQUAL "messagebroker")
288 add_definitions(-DMESSAGEBROKER_HMIADAPTER)
289 add_definitions(-DHMI_JSON_API)
291 if (HMIADAPTER STREQUAL "mqueue")
293 add_definitions(-DMQUEUE_HMIADAPTER)
294 add_definitions(-DHMI_JSON_API)
298 add_subdirectory(./src/thirdPartyLibs)
301 add_subdirectory(./tools)
304 add_subdirectory(./src/components)
306 # --- Main application
307 add_subdirectory(./src/appMain)
311 if(BUILD_TESTS_WITH_HMI)
312 add_definitions(-DTESTS_WITH_HMI)
316 # Framework GoogleTest is also integrated together gmock
317 # and must not be added separately
318 add_subdirectory(./src/thirdPartyLibs/gmock-1.7.0)
319 add_subdirectory(./test)
322 # Building documentation
324 # At first creating directory for generated documentation. Unfortunately doxygen
325 # cannot generate it byself
326 FIND_PACKAGE(Doxygen)
328 option(DOXYGEN_ENABLE_DIAGRAMS "Enable graphical diagram generation" ON)
330 if(DOXYGEN_ENABLE_DIAGRAMS)
331 set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "YES")
332 else(DOXYGEN_ENABLE_DIAGRAMS)
333 set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "NO")
335 configure_file("${PROJECT_SOURCE_DIR}/Doxyfile" "${PROJECT_BINARY_DIR}/Doxyfile")
336 file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc/doxygen")
337 ADD_CUSTOM_TARGET(doxygen COMMAND ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile")
339 MESSAGE(STATUS "Doxygen not found. Documentation will not be generated")
340 MESSAGE(STATUS "To enable documentation generation please install doxygen and graphviz packages")
341 MESSAGE(STATUS "sudo apt-get install doxygen graphviz")
342 MESSAGE(STATUS "To enable processing of MscGen comments please install mscgen")
343 MESSAGE(STATUS "sudo apt-get install mscgen")