on 8.15+17.04.20161129-0ubuntu1 help sign in
unity8/CMakeLists.txt
190 lines 6.7 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 and rcc automatically when needed.
17set(CMAKE_AUTOMOC ON)
18set(CMAKE_AUTORCC ON)
20# enable QML debugging
21string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
22if(cmake_build_type_lower MATCHES "debug")
23 add_definitions(-DQT_QML_DEBUG)
24endif()
26include(EnableCoverageReport)
27#####################################################################
28# Enable code coverage calculation with gcov/gcovr/lcov
29# Usage:
30# * Switch build type to coverage (use ccmake or cmake-gui)
31# * Invoke make, make test, make coverage (or ninja if you use that backend)
32# * Find html report in subdir coveragereport
33# * Find xml report feasible for jenkins in coverage.xml
34#####################################################################
35if(cmake_build_type_lower MATCHES coverage)
36 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
38 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
39 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
40 ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
41endif()
43# Make sure we have all the needed symbols
44set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
45set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,defs")
47# Static C++ checks
48add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
49 ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
51include(FindPkgConfig)
52find_package(Qt5Core 5.4 REQUIRED)
53find_package(Qt5Qml 5.4 REQUIRED)
54find_package(Qt5Quick 5.4 REQUIRED)
55find_package(Qt5Gui 5.4 REQUIRED)
56find_package(Qt5DBus 5.4 REQUIRED)
57find_package(Qt5Concurrent 5.4 REQUIRED)
58find_package(Qt5Sql 5.4 REQUIRED)
60pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=22)
61pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
64pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
65pkg_check_modules(GD3 REQUIRED gnome-desktop-3.0)
66pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2)
67pkg_check_modules(UBUNTUGESTURES REQUIRED UbuntuGestures)
69### Check UbuntuGestures private headers. No pkg-config (.pc) file is provided for them
70find_path(UBUNTUGESTUREPRIV
71 NAMES UbuntuGestures/private/damper_p.h UbuntuGestures/private/ucswipearea_p.h UbuntuGestures/private/ucswipearea_p_p.h
72 PATHS ${UBUNTUGESTURES_INCLUDEDIR}/UbuntuGestures/${UBUNTUGESTURES_VERSION}
73 NO_DEFAULT_PATH)
74if (${UBUNTUGESTUREPRIV} STREQUAL UBUNTUGESTUREPRIV-NOTFOUND)
75 message(FATAL_ERROR "UbuntuGestures private headers not found.")
76endif()
77# end of UbuntuGesture private headers check
79# Standard install paths
80include(GNUInstallDirs)
82set(SHELL_APP_DIR ${CMAKE_INSTALL_DATADIR}/unity8)
83set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
85execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugin_private_module_dir SystemSettings OUTPUT_VARIABLE USS_PRIVATE_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
86if(USS_PRIVATE_PLUGINDIR STREQUAL "")
87 message(FATAL_ERROR "Could not determine USS private plugin installation dir.")
88endif()
90execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir_suffix unity-shell-api OUTPUT_VARIABLE SHELL_INSTALL_QML OUTPUT_STRIP_TRAILING_WHITESPACE)
91if(SHELL_INSTALL_QML STREQUAL "")
92 message(FATAL_ERROR "Could not determine plugin installation dir.")
93endif()
95set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
97execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir unity-shell-api OUTPUT_VARIABLE SHELL_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
98if(SHELL_PLUGINDIR STREQUAL "")
99 message(FATAL_ERROR "Could not determine plugin import dir.")
100endif()
102set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
104if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
105 option(Werror "Treat warnings as errors" ON)
106else()
107 option(Werror "Treat warnings as errors" OFF)
108endif()
110if (Werror)
111 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
112endif()
114# gtk and unity-core (actually sigc++) do not like Qt defining macros named
115# "signals" and "slots"
116add_definitions(-DQT_NO_KEYWORDS)
118# Save a few container detach and conversions
119add_definitions(-DQT_STRICT_ITERATORS)
121# Use the fast string builder
122add_definitions(-DQT_USE_QSTRINGBUILDER)
124# Autopilot tests
125include(autopilot)
126declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
128set(SHELL_APP unity8)
129set(DASH_APP unity8-dash)
130set(SCOPE_TOOL unity-scope-tool)
131set(INDICATORS_CLIENT_APP indicators-client)
132set(GREETER_APP unity8-greeter)
133set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
135include_directories(
136 ${CMAKE_SOURCE_DIR}/include
137 ${CMAKE_BINARY_DIR}/include
138 ${APPLICATION_API_INCLUDE_DIRS}
141set(ARTIFACTS_DIR "" CACHE PATH "Store test artifacts in this directory.")
143# Quiet logger
144set(QUIET_LOGGER OFF CACHE BOOL "Disable test output on stdout.")
145if(NOT QUIET_LOGGER)
146 set(STDOUT_LOGGER "-o" "-,txt")
147endif()
149execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH OUTPUT_VARIABLE ARCH)
150if (NOT ARCH MATCHES "arm*")
151 set(ENABLE_TOUCH_EMULATION true)
152 add_definitions(-DUNITY8_ENABLE_TOUCH_EMULATION)
153 pkg_check_modules(MOUSETOUCHADAPTOR_LIBS REQUIRED x11 xcb xi)
154else()
155 set(ENABLE_TOUCH_EMULATION false)
156 message(STATUS "Touch emulation support disabled.")
157endif()
159# add subdirectories to build
160add_subdirectory(include)
161add_subdirectory(src)
162add_subdirectory(tools)
163add_subdirectory(qml)
165# Tests
166set(NO_TESTS OFF CACHE BOOL "Disable tests.")
167if (NOT NO_TESTS)
168 include(CTest)
169 enable_testing()
170 add_subdirectory(tests)
171else()
172 message(STATUS "Tests disabled")
173endif()
175add_subdirectory(plugins)
178# Data files
180add_subdirectory(data)
183# Translation
185add_subdirectory(po)
188# Documentation
190add_subdirectory(doc)