1
cmake_minimum_required(VERSION 2.8.9)
5
set(QTMIR_VERSION_MAJOR 0)
6
set(QTMIR_VERSION_MINOR 1)
7
set(QTMIR_VERSION_PATCH 0)
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.")
13
# Find includes in corresponding build directories
14
set(CMAKE_INCLUDE_CURRENT_DIR ON)
16
# add custom cmake modules
17
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
19
# Instruct CMake to run moc automatically when needed.
22
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -pedantic -Wextra")
23
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fno-strict-aliasing -pedantic -Wextra")
24
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
27
include(EnableCoverageReport)
28
#####################################################################
29
# Enable code coverage calculation with gcov/gcovr/lcov
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}/*)
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")
49
add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
50
${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
52
include(FindPkgConfig)
53
find_package(Qt5Core 5.2 REQUIRED)
54
find_package(Qt5DBus 5.2 REQUIRED)
55
find_package(Qt5Gui 5.2 REQUIRED)
56
find_package(Qt5Qml 5.2 REQUIRED)
57
find_package(Qt5Quick 5.2 REQUIRED)
59
find_package(Threads REQUIRED)
60
find_package(Boost 1.50 COMPONENTS system REQUIRED)
62
find_package(Protobuf REQUIRED)
63
if(PROTOBUF_PROTOC_EXECUTABLE STREQUAL "PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND")
64
message(SEND_ERROR "protoc executable not found! Missing protobuf-compiler package?")
67
pkg_check_modules(MIRSERVER mirserver REQUIRED)
68
pkg_check_modules(MIRCOMMON mircommon REQUIRED)
70
# detect if Qt compiled with GL or GLES
71
include(CheckCXXSourceCompiles)
72
check_cxx_source_compiles("
73
#include <QtCore/QtGlobal>
74
#if !defined(QT_OPENGL_ES)
75
#error \"No OpenGLES\"
81
message(STATUS "Qt5 determined to be compiled with GLES support")
82
find_package(GLESv2 REQUIRED)
83
add_definitions(-DQT_USING_GLES)
84
include_directories (${GLESv2_INCLUDE_DIRS})
85
set (GL_LIBRARIES "${GLESv2_LIBRARIES}")
88
message(STATUS "Qt5 determined to be compiled with OpenGL support")
89
find_package(OpenGL REQUIRED)
90
add_definitions(-DQT_USING_OPENGL)
91
include_directories (${OpenGL_INCLUDE_DIRS})
92
set (GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
95
# Standard install paths
96
include(GNUInstallDirs)
99
# Determine QPA plugin install path
100
# FIXME(greyback) there must be a better way than calling a private macro to set a property.
101
# I'm manually calling a macro from Qt5GuiConfig.cmake, but I don't understand why it isn't being called.
102
_populate_Gui_plugin_properties("Gui" "PLATFORMS" "platforms")
103
get_target_property(Qt5Gui_QPA_Plugin_Path Qt5::Gui IMPORTED_LOCATION_PLATFORMS)
105
# Determine install path for QML module
106
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir_suffix unity-shell-api OUTPUT_VARIABLE QTMIR_INSTALL_QML OUTPUT_STRIP_TRAILING_WHITESPACE)
107
if(SHELL_INSTALL_QML STREQUAL "")
108
message(FATAL_ERROR "Could not determine plugin installation dir.")
111
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir unity-shell-api OUTPUT_VARIABLE QTMIR_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
112
if(SHELL_PLUGINDIR STREQUAL "")
113
message(FATAL_ERROR "Could not determine plugin import dir.")
118
# Customisations for the build type
119
if(NOT CMAKE_BUILD_TYPE)
120
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
121
set(CMAKE_BUILD_TYPE RelWithDebInfo)
124
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
126
if(cmake_build_type_lower MATCHES relwithdebinfo) # workaround for http://public.kitware.com/Bug/view.php?id=14696
127
add_definitions(-DQT_NO_DEBUG)
129
if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
130
option(Werror "Treat warnings as errors" ON)
132
option(Werror "Treat warnings as errors" OFF)
136
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
140
# Mir uses boost, which does not like Qt defining macros named "signals" and "slots"
141
#add_definitions(-DQT_NO_KEYWORDS)
148
# add subdirectories to build
149
add_subdirectory(src)
150
#add_subdirectory(demos)