on 2139c25 help sign in
unity8/CMakeLists.txt
170 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)
52find_package(Qt5Qml)
53find_package(Qt5Quick)
54find_package(Qt5Gui)
55find_package(Qt5DBus)
57# Standard install paths
58include(GNUInstallDirs)
60set(SHELL_APP_DIR ${CMAKE_INSTALL_DATADIR}/unity8)
61set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
63configure_file(paths.h.in ${CMAKE_CURRENT_BINARY_DIR}/paths.h @ONLY)
65include_directories(
66 ${CMAKE_CURRENT_BINARY_DIR}
67 ${CMAKE_CURRENT_SOURCE_DIR}
68 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
69 )
71set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
73set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
75if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
76 option(Werror "Treat warnings as errors" ON)
77else()
78 option(Werror "Treat warnings as errors" OFF)
79endif()
81if (Werror)
82 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
83endif()
85# gtk and unity-core (actually sigc++) do not like Qt defining macros named
86# "signals" and "slots"
87add_definitions(-DQT_NO_KEYWORDS)
89# Tests
90include(CTest)
91enable_testing()
93# Autopilot tests
94include(autopilot)
95declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
96declare_autopilot_test(indicators_client unity8.indicators_client ${CMAKE_SOURCE_DIR}/tests/autopilot/)
98set(SHELL_APP unity8)
100set(shell_app_HDRS
101 )
103add_executable(${SHELL_APP}
104 ${shellapplication_MOC_SRCS}
105 ApplicationArguments.h
106 main.cpp
107 MouseTouchAdaptor.cpp
108 )
110qt5_use_modules(${SHELL_APP} Qml Quick Test)
111pkg_check_modules(XCB REQUIRED xcb)
113if (NOT "${XCB_INCLUDE_DIRS}" STREQUAL "")
114 set_target_properties(${SHELL_APP} PROPERTIES INCLUDE_DIRECTORIES ${XCB_INCLUDE_DIRS})
115endif()
117target_link_libraries(${SHELL_APP}
118 ${Qt5Qml_LIBRARIES}
119 ${Qt5Quick_LIBRARIES}
120 ${XCB_LDFLAGS}
121 )
123# install binaries
124install(TARGETS ${SHELL_APP}
125 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
126 )
128# install top level qml and js files
129file(GLOB QML_JS_FILES *.qml *.js)
131install(FILES ${QML_JS_FILES}
132 DESTINATION ${SHELL_APP_DIR}
133 )
135# add subdirectories to build
136add_subdirectory(tests)
137add_subdirectory(plugins)
138add_subdirectory(src)
140# install subdirectories
141set(QML_DIRS
142 Applications
143 Bottombar
144 Components
145 Dash
146 graphics
147 Greeter
148 Hud
149 Panel
150 Launcher
151 SideStage
152 Notifications
153 )
155install(DIRECTORY ${QML_DIRS}
156 DESTINATION ${SHELL_APP_DIR}
157 )
159# generate desktop file
160configure_file(${SHELL_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop @ONLY)
162# install desktop file
163install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop
164 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
165 )
168# Translation
170add_subdirectory(po)