Merge branch 'master' of github.com:otcshare/automotive-message-broker
[profile/ivi/automotive-message-broker.git] / CMakeLists.txt
1 project(automotive-message-broker)
2 cmake_minimum_required(VERSION 2.8)
3
4 set(CMAKE_BUILD_TYPE, Debug)
5
6 include(FindPkgConfig)
7
8 set(PROJECT_NAME "automotive-message-broker")
9 set(PROJECT_VERSION "0.10.8")
10 set(PROJECT_CODENAME "challenger")
11
12 add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}")
13 add_definitions(-DPROJECT_NAME="${PROJECT_NAME}")
14 add_definitions(-DPROJECT_CODENAME="${PROJECT_CODENAME}")
15
16 set (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
17 set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_LIBRARY_ARCHITECTURE}" CACHE STRING "Directory where lib will install")
18 set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
19 set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PROJECT_NAME}" CACHE PATH "The directory the docs will be installed to")
20
21 option(qtmainloop "Use QCoreApplication mainloop " OFF)
22 option(websocket_plugin "websocket source and sink plugins" OFF)
23 option(tpms_plugin "TPMS plugin " OFF)
24 option(obd2_plugin "OBD-II plugin" OFF)
25 option(database_plugin "Database plugins" OFF)
26 option(qt_bindings "AMB Qt DBus bindings" OFF)
27 option(opencvlux_plugin "OpenCV Lux plugin" OFF)
28 option(gpsd_plugin "gpsd location plugin" OFF)
29 option(murphy_plugin "murphy policy framework plugin" OFF)
30 option(test_plugin "Test Plugin" ON)
31 option(bluemonkey_plugin "bluemonkey irc plugin" OFF)
32
33 if(opencvlux_plugin)
34    message(STATUS "OpenCV Lux plugin enabled")
35
36 endif(opencvlux_plugin)
37
38 include (CMakeForceCompiler)
39 option(ENABLE_ICECC "Enable icecc checking, for distributed compilation" ON)
40
41 if (ENABLE_ICECC)
42    find_program(ICECC /usr/lib/icecc/bin/c++)
43     if (ICECC)
44         message(STATUS "icecc will be used for distributed compiling")
45         cmake_force_cxx_compiler(${ICECC} icecc)
46     else(ICECC)
47         message(STATUS "Not using icecc")
48     endif(ICECC)
49 endif(ENABLE_ICECC)
50
51 find_library(libtool_LIBRARY ltdl DOC "Libtool libraries")
52 find_path(libtool_INCLUDE_DIR ltdl.h DOC "Libtool headers")
53
54 if(libtool_LIBRARY)
55      message(STATUS "libtool found")
56 else(libtool_LIBRARY)
57      message(FATAL_ERROR "libtool missing.  please install libtool")
58 endif(libtool_LIBRARY)
59
60 find_package(Boost REQUIRED)
61
62
63 pkg_check_modules(glib REQUIRED glib-2.0 gobject-2.0)
64 pkg_check_modules(json REQUIRED json)
65
66
67 add_definitions(-std=c++0x)
68 add_definitions(-DDBusServiceName="org.automotive.message.broker")
69
70 set(include_dirs ${libtool_INCLUDE_DIR} ${glib_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${json_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
71 set(link_libraries -lamb ${libtool_LIBRARY} ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib)
72
73 if(qtmainloop)
74         message(STATUS "using Qt mainloop")
75
76         find_package(Qt5Core)
77         if(Qt5Core_FOUND)
78                 message(STATUS "using Qt5")
79                 set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS})
80                 set(QT_LIBRARIES ${Qt5Core_LIBRARIES})
81                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} -mcmodel=large")
82                 add_definitions(${Qt5Core_DEFINITIONS})
83         else(Qt5Core_FOUND)
84                 message(STATUS "using Qt4")
85                 find_package( Qt4 REQUIRED )
86                 include(${QT_USE_FILE})
87
88         endif(Qt5Core_FOUND)
89
90         set(include_dirs ${include_dirs} ${QT_INCLUDE_DIRS})
91         set(link_libraries ${link_libraries} ${QT_LIBRARIES})
92
93         add_definitions(-DQT_NO_KEYWORDS)
94         add_definitions(-DUSE_QT_CORE)
95 endif(qtmainloop)
96
97 set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
98 add_custom_target(dist COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
99
100 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
101 add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
102
103 # packaging stuff:
104 # Common things to every type of package
105 SET(CPACK_PACKAGE_DESCRIPTION "daemon to access vehicle data")
106 SET(CPACK_PACKAGE_NAME "automotive-message-broker")
107 SET(CPACK_PACKAGE_EXECUTABLES "ambd")
108 SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
109 SET(CPACK_STRIP_FILES true)
110 SET(CPACK_PACKAGE_CONTACT "tripzero.kev@gmail.com")
111 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
112
113
114 # Always build .tar.gz and .sh files
115 SET(CPACK_GENERATOR "STGZ;TGZ")
116
117 SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
118 SET(CPACK_DEBIAN_PACKAGE_DEPENDS "gpsd (>=2.0), libopencv, libjson0, libltdl7")
119 SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
120
121 INCLUDE(CPack)
122
123 add_subdirectory(lib)
124 add_subdirectory(ambd)
125 add_subdirectory(plugins)
126 add_subdirectory(docs)
127 add_subdirectory(tests)
128 add_subdirectory(examples)