on 8.02+15.10.20150603.1-0ubuntu1 help sign in
unity8/CMakeLists.txt
147 lines 5.0 kB history raw
1cmake_minimum_required(VERSION 2.8.9)
3# Default install location. Must be set here, before setting the project.
4if (NOT DEFINED CMAKE_INSTALL_PREFIX)
5 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "" FORCE)
6endif()
8project(unity8 C CXX)
10if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
11 message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt from source root and try again.")
12endif()
14set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
16# Instruct CMake to run moc automatically when needed.
17set(CMAKE_AUTOMOC ON)
19# enable QML debugging
20string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
21if(cmake_build_type_lower MATCHES "debug")
22 add_definitions(-DQT_QML_DEBUG)
23endif()
25include(EnableCoverageReport)
26#####################################################################
27# Enable code coverage calculation with gcov/gcovr/lcov
28# Usage:
29# * Switch build type to coverage (use ccmake or cmake-gui)
30# * Invoke make, make test, make coverage (or ninja if you use that backend)
31# * Find html report in subdir coveragereport
32# * Find xml report feasible for jenkins in coverage.xml
33#####################################################################
34if(cmake_build_type_lower MATCHES coverage)
35 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
36 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
37 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
38 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
39 ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
40endif()
42# Make sure we have all the needed symbols
43set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
44set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,defs")
46# Static C++ checks
47add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
48 ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
50include(FindPkgConfig)
51find_package(Qt5Core 5.2 REQUIRED)
52find_package(Qt5Qml 5.2 REQUIRED)
53find_package(Qt5Quick 5.2 REQUIRED)
54find_package(Qt5Gui 5.2 REQUIRED)
55find_package(Qt5DBus 5.2 REQUIRED)
56find_package(Qt5Concurrent 5.2 REQUIRED)
57find_package(Qt5Sql 5.2 REQUIRED)
59# Standard install paths
60include(GNUInstallDirs)
62set(SHELL_APP_DIR ${CMAKE_INSTALL_DATADIR}/unity8)
63set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
65execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugin_private_module_dir SystemSettings OUTPUT_VARIABLE USS_PRIVATE_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
66if(USS_PRIVATE_PLUGINDIR STREQUAL "")
67 message(FATAL_ERROR "Could not determine USS private plugin installation dir.")
68endif()
70execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir_suffix unity-shell-api OUTPUT_VARIABLE SHELL_INSTALL_QML OUTPUT_STRIP_TRAILING_WHITESPACE)
71if(SHELL_INSTALL_QML STREQUAL "")
72 message(FATAL_ERROR "Could not determine plugin installation dir.")
73endif()
75set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
77execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir unity-shell-api OUTPUT_VARIABLE SHELL_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
78if(SHELL_PLUGINDIR STREQUAL "")
79 message(FATAL_ERROR "Could not determine plugin import dir.")
80endif()
82set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
84if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
85 option(Werror "Treat warnings as errors" ON)
86else()
87 option(Werror "Treat warnings as errors" OFF)
88endif()
90if (Werror)
91 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
92endif()
94# gtk and unity-core (actually sigc++) do not like Qt defining macros named
95# "signals" and "slots"
96add_definitions(-DQT_NO_KEYWORDS)
98# Save a few container detach and conversions
99add_definitions(-DQT_STRICT_ITERATORS)
101# Autopilot tests
102include(autopilot)
103declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
105set(SHELL_APP unity8)
106set(DASH_APP unity8-dash)
107set(SCOPE_TOOL unity-scope-tool)
108set(INDICATORS_CLIENT_APP indicators-client)
109set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
111include_directories(
112 ${CMAKE_SOURCE_DIR}/include
113 ${CMAKE_BINARY_DIR}/include
116# add subdirectories to build
117add_subdirectory(include)
118add_subdirectory(libs)
119add_subdirectory(src)
120add_subdirectory(tools)
121add_subdirectory(qml)
123# Tests
124if (NOT NO_TESTS)
125 include(CTest)
126 enable_testing()
127 add_subdirectory(tests)
128else()
129 message(STATUS "Tests disabled")
130endif()
132add_subdirectory(plugins)
135# Data files
137add_subdirectory(data)
140# Translation
142add_subdirectory(po)
145# Documentation
147add_subdirectory(doc)