~ps-jenkins/unity-scopes-shell/ubuntu-rtm-14.09-proposed

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • Committer: Michal Hruby
  • Date: 2013-11-07 17:48:16 UTC
  • Revision ID: michal.mhr@gmail.com-20131107174816-w1vqq6juarrawx23
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
cmake_minimum_required(VERSION 2.8.9)
 
2
 
 
3
# Default install location. Must be set here, before setting the project.
 
4
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
 
5
    set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "" FORCE)
 
6
endif()
 
7
 
 
8
project(unity-scopes-shell C CXX)
 
9
 
 
10
if(${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.")
 
12
endif()
 
13
 
 
14
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
 
15
 
 
16
include(EnableCoverageReport)
 
17
#####################################################################
 
18
# Enable code coverage calculation with gcov/gcovr/lcov
 
19
# Usage:
 
20
#  * Switch build type to coverage (use ccmake or cmake-gui)
 
21
#  * Invoke make, make test, make coverage (or ninja if you use that backend)
 
22
#  * Find html report in subdir coveragereport
 
23
#  * Find xml report feasible for jenkins in coverage.xml
 
24
#####################################################################
 
25
if(cmake_build_type_lower MATCHES coverage)
 
26
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
 
27
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
 
28
  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
 
29
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
 
30
  ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
 
31
endif()
 
32
 
 
33
# Make sure we have all the needed symbols
 
34
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
 
35
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,defs")
 
36
 
 
37
# Static C++ checks
 
38
add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
 
39
                                       ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
 
40
 
 
41
include(FindPkgConfig)
 
42
find_package(Qt5Core)
 
43
find_package(Qt5Qml)
 
44
find_package(Qt5Quick)
 
45
find_package(Qt5Gui)
 
46
find_package(Qt5DBus)
 
47
 
 
48
# Standard install paths
 
49
include(GNUInstallDirs)
 
50
 
 
51
#set(SHELL_APP_DIR ${CMAKE_INSTALL_DATADIR}/unity8)
 
52
set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
 
53
 
 
54
include_directories(
 
55
    ${CMAKE_CURRENT_BINARY_DIR}
 
56
    ${CMAKE_CURRENT_SOURCE_DIR}
 
57
    )
 
58
 
 
59
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
 
60
 
 
61
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
 
62
 
 
63
if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
 
64
    option(Werror "Treat warnings as errors" ON)
 
65
else()
 
66
    option(Werror "Treat warnings as errors" OFF)
 
67
endif()
 
68
 
 
69
if (Werror)
 
70
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
 
71
endif()
 
72
 
 
73
# gtk and unity-core (actually sigc++) do not like Qt defining macros named
 
74
# "signals" and "slots"
 
75
add_definitions(-DQT_NO_KEYWORDS)
 
76
 
 
77
# Tests
 
78
include(CTest)
 
79
enable_testing()
 
80
 
 
81
# add subdirectories to build
 
82
add_subdirectory(src)
 
83
add_subdirectory(tests)
 
84
 
 
85
#
 
86
# Translation
 
87
#
 
88
#add_subdirectory(po)