~laney/ubuntu-system-settings/battery-charge-graph

317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
1
project(ubuntu-system-settings C CXX)
2
cmake_minimum_required(VERSION 2.8.10)
3
480.2.5 by Iain Lane
Oops, don't break the CMakeLists
4
if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
5
   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.")
6
endif()
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
7
8
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
9
317.4.23 by Jussi Pakkanen
Generate pkg-config file and install it.
10
set(PROJECT_VERSION 0.1)
317.4.35 by Jussi Pakkanen
Added coverage support.
11
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
12
include(EnableCoverageReport)
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
13
include(FindPkgConfig)
14
include(GNUInstallDirs)
317.4.2 by Jussi Pakkanen
Some more progression towards CMake.
15
set(LIBDIR ${CMAKE_INSTALL_LIBDIR})
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
16
enable_testing()
17
317.4.35 by Jussi Pakkanen
Added coverage support.
18
if(cmake_build_type_lower MATCHES coverage)
19
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
20
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
21
  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" )
22
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
23
24
  # We add -g when building with coverage so valgrind reports line numbers.
25
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" )
26
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
27
endif()
28
29
317.4.18 by Jussi Pakkanen
Translations can be installed.
30
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fno-permissive -pedantic -Wall -Wextra")
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
31
find_package(Qt5Widgets REQUIRED)
32
# Workaround for https://bugreports.qt-project.org/browse/QTBUG-29987
33
set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/qml")
317.4.4 by Jussi Pakkanen
Can build full executable.
34
set(CMAKE_AUTOMOC ON)
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
35
317.4.7 by Jussi Pakkanen
Can build battery plugin.
36
pkg_search_module(GLIB REQUIRED glib-2.0)
317.4.50 by Jussi Pakkanen
Merged trunk.
37
pkg_check_modules(GIO REQUIRED gio-2.0 gio-unix-2.0)
317.4.7 by Jussi Pakkanen
Can build battery plugin.
38
pkg_search_module(UPOWER_GLIB REQUIRED upower-glib)
39
pkg_search_module(LIBNM_GLIB REQUIRED libnm-glib)
317.4.8 by Jussi Pakkanen
Compile a few plugins more.
40
pkg_search_module(ACCOUNTSSERVICE REQUIRED accountsservice)
317.4.9 by Jussi Pakkanen
Compile a few more.
41
pkg_search_module(OFONO REQUIRED ofono-qt)
317.4.10 by Jussi Pakkanen
Some more plugins compiling.
42
pkg_search_module(TIMEZONEMAP REQUIRED timezonemap)
317.4.7 by Jussi Pakkanen
Can build battery plugin.
43
317.4.17 by Jussi Pakkanen
Some cleanups and po.
44
find_program(XGETTEXT_BIN xgettext)
317.4.18 by Jussi Pakkanen
Translations can be installed.
45
find_program(MSGFMT_BIN msgfmt)
317.4.17 by Jussi Pakkanen
Some cleanups and po.
46
317.4.2 by Jussi Pakkanen
Some more progression towards CMake.
47
set(PLUGIN_MANIFEST_DIR_BASE share/ubuntu/settings/system)
48
set(PLUGIN_MODULE_DIR_BASE ubuntu-system-settings)
49
set(PLUGIN_PRIVATE_MODULE_DIR_BASE "${PLUGIN_MODULE_DIR_BASE}/private")
50
set(PLUGIN_QML_DIR_BASE share/ubuntu/settings/system/qml-plugins)
51
52
set(PLUGIN_MANIFEST_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_MANIFEST_DIR_BASE}")
317.4.49 by Jussi Pakkanen
Add prefix to module dir definitions.
53
set(PLUGIN_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${LIBDIR}/${PLUGIN_MODULE_DIR_BASE}")
317.4.2 by Jussi Pakkanen
Some more progression towards CMake.
54
set(PLUGIN_QML_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_QML_DIR_BASE}")
317.4.49 by Jussi Pakkanen
Add prefix to module dir definitions.
55
set(PLUGIN_PRIVATE_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${LIBDIR}/${PLUGIN_PRIVATE_MODULE_DIR_BASE}")
317.4.2 by Jussi Pakkanen
Some more progression towards CMake.
56
317.4.5 by Jussi Pakkanen
Build about plugin.
57
set(ANDR_PROP_LIB -landroid-properties)
58
317.4.18 by Jussi Pakkanen
Translations can be installed.
59
add_subdirectory(po)
317.4.20 by Jussi Pakkanen
Install XML schema.
60
add_subdirectory(schema)
317.4.4 by Jussi Pakkanen
Can build full executable.
61
add_subdirectory(lib)
317.4.7 by Jussi Pakkanen
Can build battery plugin.
62
include_directories(lib)
317.4.5 by Jussi Pakkanen
Build about plugin.
63
add_subdirectory(plugins)
317.4.1 by Jussi Pakkanen
Started on CMake build skeleton.
64
add_subdirectory(src)
317.4.11 by Jussi Pakkanen
Compile tests.
65
add_subdirectory(tests)
66
317.4.28 by Jussi Pakkanen
Install .desktop file.
67
install(FILES ubuntu-system-settings.desktop DESTINATION share/applications)
317.4.35 by Jussi Pakkanen
Added coverage support.
68
69
if(cmake_build_type_lower MATCHES coverage)
70
  ENABLE_COVERAGE_REPORT(TARGETS system-settings FILTER /usr/include ${CMAKE_SOURCE_DIR}/test/* ${CMAKE_BINARY_DIR}/*)
71
endif()