Merge pull request #63 from tripzero/trip
[profile/ivi/automotive-message-broker.git] / CMakeLists.txt
1 project(automotive-message-broker)
2 cmake_minimum_required(VERSION 2.8.11)
3
4 set(CMAKE_BUILD_TYPE, Debug)
5
6 include(FindPkgConfig)
7 include(CMakeDependentOption)
8 include(GNUInstallDirs)
9
10 set(PROJECT_NAME "automotive-message-broker")
11 set(PROJECT_PRETTY_NAME "Automotive Message Broker")
12 set(PROJECT_SERIES "0.15")
13 set(PROJECT_MAJOR_VERSION "0.14")
14 set(PROJECT_MINOR_VERSION "802")
15 set(PROJECT_VERSION "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}")
16 set(PROJECT_CODENAME "")
17 set(PROJECT_QUALITY "alpha")
18
19 add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}")
20 add_definitions(-DPROJECT_NAME="${PROJECT_PRETTY_NAME}")
21 add_definitions(-DPROJECT_CODENAME="${PROJECT_CODENAME}")
22 add_definitions(-DPROJECT_QUALITY="${PROJECT_QUALITY}")
23 add_definitions(-DPROJECT_SERIES="${PROJECT_SERIES}")
24
25 set (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
26 set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" )
27 set (PLUGIN_INSTALL_PATH "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
28 set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
29 set (DOC_INSTALL_DIR "${CMAKE_INSTALL_DOCDIR}/${PROJECT_SERIES}")
30 set (PLUGIN_SEGMENT_INSTALL_PATH "/${CMAKE_INSTALL_SYSCONFDIR}/ambd/plugins.d")
31
32 option(qtmainloop "Use QCoreApplication mainloop " OFF)
33 option(websocket_plugin "websocket source and sink plugins" OFF)
34 option(obd2_plugin "OBD-II plugin" OFF)
35 option(database_plugin "Database plugins" OFF)
36 option(qt_bindings "AMB Qt DBus bindings" OFF)
37 option(opencvlux_plugin "OpenCV Lux plugin" OFF)
38 option(murphy_plugin "murphy policy framework plugin" OFF)
39 option(test_plugin "Test Plugin" ON)
40 option(bluemonkey_plugin "bluemonkey plugin" OFF)
41 option(gpsnmea_plugin "gps NMEA location plugin" OFF)
42 option(chrony_plugin "chrony plugin" OFF)
43 option(openxc_plugin "OpenXC plugin" OFF)
44 option(bluetooth_plugin "bluetooth plugin" OFF)
45 option(cansim_plugin "Can simulator plugin" OFF)
46 option(cangen_plugin "Can generator plugin" OFF)
47 option(enable_icecc "Enable icecc checking, for distributed compilation" ON)
48 option(enable_docs "enable Doxygen doc generation" OFF)
49 option(usebluez5 "use bluez 5 API" OFF)
50 option(xwalk_vehicle_extension "Crosswalk vehicle extension" OFF)
51 set(XWALK_EXTENSION_PATH "/automotive-message-broker/xwalk" CACHE PATH "directory the xwalk extension will be installed to")
52 set(QMAKE_INSTALL_PATH "/usr/bin/qmake" CACHE PATH "qmake executable path")
53
54 #turn on -fpic/-fpie:
55 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
56 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie -pie -std=c++14")
57
58 if (enable_icecc)
59         include (CMakeForceCompiler)
60         find_program(ICECC /usr/lib/icecc/bin/g++)
61                 if (ICECC)
62                         message(STATUS "icecc will be used for distributed compiling")
63                         cmake_force_cxx_compiler(${ICECC} icecc)
64                 else(ICECC)
65                         message(STATUS "Not using icecc")
66                 endif(ICECC)
67 endif(enable_icecc)
68
69 find_package(Boost REQUIRED)
70
71
72 pkg_check_modules(glib REQUIRED glib-2.0 gobject-2.0)
73
74 add_definitions(-DDBusServiceName="org.automotive.message.broker")
75
76 set(include_dirs ${libtool_INCLUDE_DIR} ${glib_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${json_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
77 set(link_libraries -lamb ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib)
78
79 if(usebluez5)
80         add_definitions(-DUSE_BLUEZ5)
81
82 endif(usebluez5)
83
84 set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
85 add_custom_target(dist COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
86
87 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
88 add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
89
90 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RELEASE.in.md" "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE.md" @ONLY)
91
92 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/TODO" "${CMAKE_CURRENT_SOURCE_DIR}/TODO.md" @ONLY)
93
94 # packaging stuff:
95 # Common things to every type of package
96 SET(CPACK_PACKAGE_DESCRIPTION "daemon that provides access vehicle data")
97 SET(CPACK_PACKAGE_NAME "automotive-message-broker")
98 SET(CPACK_PACKAGE_EXECUTABLES "ambd")
99 SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
100 SET(CPACK_STRIP_FILES true)
101 SET(CPACK_PACKAGE_CONTACT "tripzero.kev@gmail.com")
102 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
103
104 # Always build .tar.gz and .sh files
105 SET(CPACK_GENERATOR "STGZ;TGZ;TBZ2")
106
107 add_subdirectory(lib)
108 add_subdirectory(plugins)
109 add_subdirectory(ambd)
110 add_subdirectory(docs)
111 add_subdirectory(tests)
112 add_subdirectory(tools)
113 add_subdirectory(examples)
114 add_subdirectory(xwalk)
115 add_subdirectory(packaging.in)
116
117