~mir-team/qtmir/mir-0.16-rebuild

250.4.1 by Robert Carr
Begin on cmake
1
cmake_minimum_required(VERSION 2.8.9)
2
3
project(qtmir)
4
5
set(QTMIR_VERSION_MAJOR 0)
6
set(QTMIR_VERSION_MINOR 1)
7
set(QTMIR_VERSION_PATCH 0)
8
9
if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
10
   message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt and CMakeFiles/ from source root and try again.")
11
endif()
12
13
# Find includes in corresponding build directories
14
set(CMAKE_INCLUDE_CURRENT_DIR ON)
15
16
# add custom cmake modules
250.4.73 by Michał Sawicz
Use FindGMock from cmake-extras > 0.3
17
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
250.4.1 by Robert Carr
Begin on cmake
18
19
# Instruct CMake to run moc automatically when needed.
20
set(CMAKE_AUTOMOC ON)
21
250.4.36 by Robert Carr
Adopt Werror over pedantic
22
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra -Werror")
23
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fno-strict-aliasing -Werror -Wextra")
250.4.1 by Robert Carr
Begin on cmake
24
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
25
26
27
include(EnableCoverageReport)
28
#####################################################################
29
# Enable code coverage calculation with gcov/gcovr/lcov
30
# Usage:
31
#  * Switch build type to coverage (use ccmake or cmake-gui)
32
#  * Invoke make, make test, make coverage (or ninja if you use that backend)
33
#  * Find html report in subdir coveragereport
34
#  * Find xml report feasible for jenkins in coverage.xml
35
#####################################################################
36
if(cmake_build_type_lower MATCHES coverage)
37
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
38
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
39
    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
40
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
41
    ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
42
endif()
43
44
# Make sure we have all the needed symbols
45
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
46
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,defs")
47
48
# Static C++ checks
49
add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
50
                                       ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
51
52
include(FindPkgConfig)
250.4.29 by Robert Carr
Bump qt 5.2->5.3
53
find_package(Qt5Core 5.3 REQUIRED)
54
find_package(Qt5DBus 5.3 REQUIRED)
55
find_package(Qt5Gui 5.3 REQUIRED)
56
find_package(Qt5Qml 5.3 REQUIRED)
57
find_package(Qt5Quick 5.3 REQUIRED)
250.4.39 by Robert Carr
Fix qt5 sensors link
58
find_package(Qt5Sensors 5.3 REQUIRED)
250.4.71 by Gerry Boland
Do not use deprecated qt5_use_module cmake command
59
find_package(Qt5Test 5.3 REQUIRED)
250.4.1 by Robert Carr
Begin on cmake
60
61
find_package(Threads REQUIRED)
62
63
find_package(Protobuf REQUIRED)
64
if(PROTOBUF_PROTOC_EXECUTABLE STREQUAL "PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND")
65
    message(SEND_ERROR "protoc executable not found! Missing protobuf-compiler package?")
66
endif()
67
323.5.7 by Alan Griffiths
Use the correct package, use it explicitly, use the package version (not the ABI version)
68
pkg_check_modules(MIRSERVER mirserver>=0.13 REQUIRED)
69
pkg_check_modules(MIRCLIENT mirclient>=0.13 REQUIRED)
250.4.1 by Robert Carr
Begin on cmake
70
250.4.10 by Robert Carr
Wooo
71
pkg_check_modules(GLIB glib-2.0 REQUIRED)
72
pkg_check_modules(PROCESS_CPP process-cpp REQUIRED)
73
pkg_check_modules(UBUNTU_APP_LAUNCH ubuntu-app-launch-2 REQUIRED)
74
pkg_check_modules(URL_DISPATCHER url-dispatcher-1)
75
pkg_check_modules(PROTOBUF protobuf)
76
pkg_check_modules(EGL egl)
77
pkg_check_modules(GIO gio-2.0)
250.4.54 by Robert Carr
Merge lp:qtmir
78
pkg_check_modules(GIO_UNIX gio-unix-2.0)
250.4.10 by Robert Carr
Wooo
79
pkg_check_modules(LTTNG lttng-ust)
323.3.1 by Michael Zanetti
read exception list from gsettings instead a hardcoded list
80
pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
319.3.6 by Gerry Boland
SharedWakelock refactoring - RAII design faulty when wrapping an asynchronous service. Was possible for wakelocks to not be removed.
81
pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
82
pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
282.3.18 by Daniel d'Andrada
Tests also need to be pointed to the location of unity-api headers
83
pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
250.4.10 by Robert Carr
Wooo
84
319.2.1 by Robert Carr
Port to MirEvent 2.0
85
add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
250.4.10 by Robert Carr
Wooo
86
282.3.24 by Daniel d'Andrada
One include_directories(${APPLICATION_API_INCLUDE_DIRS}) to rule them all
87
include_directories( ${APPLICATION_API_INCLUDE_DIRS} )
88
250.4.27 by Robert Carr
Cleanup main CMakeLists.txt
89
# We expect this to be set via debian/rules for GLES builds
250.4.15 by Robert Carr
Restort parts of GL detection
90
if ("${USE_OPENGLES}" STREQUAL 1)
250.4.13 by Robert Carr
Restort parts of GL detection
91
    message(STATUS "Qt5 determined to be compiled with GLES support")
250.4.47 by Robert Carr
Use pkgconfig to find gl
92
    pkg_check_modules(GLESv2 glesv2)
250.4.13 by Robert Carr
Restort parts of GL detection
93
    add_definitions(-DQT_USING_GLES)
94
    include_directories (${GLESv2_INCLUDE_DIRS})
95
    set (GL_LIBRARIES "${GLESv2_LIBRARIES}")
250.4.52 by Robert Carr
Sweet sweet hacks
96
# Because qt/gl and qt/gles are not parallel installable we have a difficulty
97
# building qtmir-desktop on armhf. We would like to link against opengl and bind the
98
# opengl API but Qt is already linked against the ES APIs. So in this setup we link against OpenGLES
99
# to accomodate Qt but bind the OpenGL API anyway. This is technically broken though
100
# I suspect Mesa may allow it ~racarr.
101
elseif("${USE_OPENGL_BUT_LINK_AGAINST_OPENGLES}")
102
    message(STATUS "Linking against OpenGL ES but binding OpenGL API")
103
    pkg_check_modules(GLESv2 glesv2)
104
    add_definitions(-DQT_USING_GL)
105
    include_directories (${GLESv2_INCLUDE_DIRS})
106
    set (GL_LIBRARIES "${GLESv2_LIBRARIES}")
250.4.13 by Robert Carr
Restort parts of GL detection
107
else()
108
    message(STATUS "Qt5 determined to be compiled with OpenGL support")
250.4.48 by Robert Carr
Fix typo
109
    pkg_check_modules(GL gl)
250.4.13 by Robert Carr
Restort parts of GL detection
110
    add_definitions(-DQT_USING_OPENGL)
250.4.47 by Robert Carr
Use pkgconfig to find gl
111
    include_directories (${GL_INCLUDE_DIRS})
250.4.13 by Robert Carr
Restort parts of GL detection
112
endif()
250.4.1 by Robert Carr
Begin on cmake
113
114
# Standard install paths
115
include(GNUInstallDirs)
116
117
118
# Determine QPA plugin install path
119
# FIXME(greyback) there must be a better way than calling a private macro to set a property.
120
# I'm manually calling a macro from Qt5GuiConfig.cmake, but I don't understand why it isn't being called.
121
_populate_Gui_plugin_properties("Gui" "PLATFORMS" "platforms")
122
get_target_property(Qt5Gui_QPA_Plugin_Path Qt5::Gui IMPORTED_LOCATION_PLATFORMS)
123
250.4.70 by Gerry Boland
Use macros in QMLPlugin module to install QML plugin
124
# Set QML module install path
125
set(QML_MODULE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/qt5/qml")
250.4.1 by Robert Carr
Begin on cmake
126
127
128
# Customisations for the build type
129
if(NOT CMAKE_BUILD_TYPE)
130
    message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
131
    set(CMAKE_BUILD_TYPE RelWithDebInfo)
132
endif()
133
134
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
135
136
if(cmake_build_type_lower MATCHES relwithdebinfo) # workaround for http://public.kitware.com/Bug/view.php?id=14696
137
    add_definitions(-DQT_NO_DEBUG)
138
endif()
139
if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
140
    option(Werror "Treat warnings as errors" ON)
141
else()
142
    option(Werror "Treat warnings as errors" OFF)
143
endif()
144
145
if (Werror)
146
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
147
endif()
148
149
150
# Mir uses boost, which does not like Qt defining macros named "signals" and "slots"
250.4.27 by Robert Carr
Cleanup main CMakeLists.txt
151
add_definitions(-DQT_NO_KEYWORDS)
250.4.1 by Robert Carr
Begin on cmake
152
153
# Tests
290.1.1 by Daniel d'Andrada
Update README and readd option to disable building tests
154
if (NOT NO_TESTS)
155
    include(CTest)
156
    enable_testing()
157
    add_subdirectory(tests)
158
else()
159
    message(STATUS "Tests disabled")
160
endif()
250.4.1 by Robert Carr
Begin on cmake
161
162
163
# add subdirectories to build
164
add_subdirectory(src)