~mterry/qtmir/warn-on-xapp

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
404.2.1 by Gerry Boland
Fix armhf builds on Xenial by using -std=gnu99 instead of c99
22
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -Werror")
384.5.5 by Alan Griffiths
Back to the future
23
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -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)
345.2.1 by Gerry Boland
We depend on Qt 5.4, remove compatibility code for older versions
53
find_package(Qt5Core 5.4 REQUIRED)
54
find_package(Qt5DBus 5.4 REQUIRED)
55
find_package(Qt5Gui 5.4 REQUIRED)
56
find_package(Qt5Qml 5.4 REQUIRED)
57
find_package(Qt5Quick 5.4 REQUIRED)
58
find_package(Qt5Sensors 5.4 REQUIRED)
59
find_package(Qt5Test 5.4 REQUIRED)
250.4.1 by Robert Carr
Begin on cmake
60
61
find_package(Threads REQUIRED)
62
363.4.27 by Gerry Boland
Fix conflicts but have ScreenController test failing
63
pkg_check_modules(MIRSERVER mirserver>=0.17 REQUIRED)
64
pkg_check_modules(MIRCLIENT mirclient>=0.17 REQUIRED)
65
pkg_check_modules(MIRRENDERERGLDEV mir-renderer-gl-dev>=0.17 REQUIRED)
250.4.1 by Robert Carr
Begin on cmake
66
250.4.10 by Robert Carr
Wooo
67
pkg_check_modules(GLIB glib-2.0 REQUIRED)
68
pkg_check_modules(PROCESS_CPP process-cpp REQUIRED)
69
pkg_check_modules(UBUNTU_APP_LAUNCH ubuntu-app-launch-2 REQUIRED)
70
pkg_check_modules(URL_DISPATCHER url-dispatcher-1)
71
pkg_check_modules(EGL egl)
72
pkg_check_modules(GIO gio-2.0)
250.4.54 by Robert Carr
Merge lp:qtmir
73
pkg_check_modules(GIO_UNIX gio-unix-2.0)
250.4.10 by Robert Carr
Wooo
74
pkg_check_modules(LTTNG lttng-ust)
323.3.1 by Michael Zanetti
read exception list from gsettings instead a hardcoded list
75
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.
76
pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
77
pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
379.3.14 by Michael Terry
Bump shell application version
78
pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=10)
250.4.10 by Robert Carr
Wooo
79
328.7.13 by Daniel d'Andrada
Fixed all issues pointed out by code review
80
include_directories(${APPLICATION_API_INCLUDE_DIRS})
81
319.2.1 by Robert Carr
Port to MirEvent 2.0
82
add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
250.4.10 by Robert Carr
Wooo
83
381.2.1 by Albert Astals Cid
Enable Efficient String Construction by default
84
# Use the fast string builder
85
add_definitions(-DQT_USE_QSTRINGBUILDER)
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")
369.4.2 by Nick Dedekind
updated CMake
126
set(QTMIR_DATA_DIR ${CMAKE_INSTALL_DATADIR}/qtmir)
250.4.1 by Robert Carr
Begin on cmake
127
128
129
# Customisations for the build type
130
if(NOT CMAKE_BUILD_TYPE)
131
    message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
132
    set(CMAKE_BUILD_TYPE RelWithDebInfo)
133
endif()
134
135
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
136
137
if(cmake_build_type_lower MATCHES relwithdebinfo) # workaround for http://public.kitware.com/Bug/view.php?id=14696
138
    add_definitions(-DQT_NO_DEBUG)
139
endif()
140
if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
141
    option(Werror "Treat warnings as errors" ON)
142
else()
143
    option(Werror "Treat warnings as errors" OFF)
144
endif()
145
146
if (Werror)
147
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
148
endif()
149
150
151
# Mir uses boost, which does not like Qt defining macros named "signals" and "slots"
250.4.27 by Robert Carr
Cleanup main CMakeLists.txt
152
add_definitions(-DQT_NO_KEYWORDS)
250.4.1 by Robert Carr
Begin on cmake
153
154
# Tests
290.1.1 by Daniel d'Andrada
Update README and readd option to disable building tests
155
if (NOT NO_TESTS)
156
    include(CTest)
157
    enable_testing()
158
    add_subdirectory(tests)
159
else()
160
    message(STATUS "Tests disabled")
161
endif()
250.4.1 by Robert Carr
Begin on cmake
162
163
# add subdirectories to build
164
add_subdirectory(src)
369.4.2 by Nick Dedekind
updated CMake
165
add_subdirectory(demos)
166
add_subdirectory(benchmarks)