CMakeLists.txt 3.58 KB
Newer Older
Fabian Kosmale's avatar
Fabian Kosmale committed
1 2
cmake_minimum_required(VERSION 3.4.0 FATAL_ERROR)

Luca Giambonini's avatar
Luca Giambonini committed
3 4
#project(akabeicore)
project(akabeicore VERSION 0.0.1)
5

Fabian Kosmale's avatar
Fabian Kosmale committed
6 7 8 9 10 11
set(MAJOR_AKABEI_VERSION 0 CACHE INT "Akabei’s major version number" FORCE)
set(MINOR_AKABEI_VERSION 0 CACHE INT "Akabei’s minor version number" FORCE)
set(PATCH_AKABEI_VERSION 1 CACHE INT "Akabei’s patch version number" FORCE)
set(FIX_AKABEI_VERSION 0 CACHE INT "Akabei’s fix version number" FORCE)
set(AKABEI_VERSION_STRING "${MAJOR_AKABEI_VERSION}.${MINOR_AKABEI_VERSION}.${PATCH_AKABEI_VERSION}.${FIX_AKABEI_VERSION}")

12
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
13
option(BUILD_TESTS "Builds various tests and examples for Akabei" ON)
14
option(BUILD_COVERAGE "Builds code coverage data for Akabei" OFF)
15 16

if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_COVERAGE AND BUILD_TESTS)
Fabian Kosmale's avatar
Fabian Kosmale committed
17
    include(CodeCoverage)
18
    setup_target_for_coverage(coverage ctest coverage)
Fabian Kosmale's avatar
Fabian Kosmale committed
19 20 21
    SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
    SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
endif()
22

Fabian Kosmale's avatar
Fabian Kosmale committed
23 24 25 26 27 28 29 30
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-W -Wall)
add_definitions(-Werror)

# set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

31 32 33 34 35
# Compiles with debugging symbols (Debug mode)
if (CMAKE_COMPILER_IS_GNUCC)
    set(CMAKE_C_FLAGS_DEBUG "-ggdb")
endif(CMAKE_COMPILER_IS_GNUCC)

36
# https://cmake.org/cmake/help/v3.0/policy/CMP0003.html
37 38
if(COMMAND cmake_policy)
   cmake_policy(SET CMP0003 NEW)
39
endif(COMMAND cmake_policy)
40

41 42 43 44 45 46 47 48 49
# KF5 global definitions, use them to be compatible with KF5 applications
add_definitions(#-DQT_NO_CAST_TO_ASCII
                #-DQT_NO_CAST_FROM_ASCII
                -DQT_NO_URL_CAST_FROM_STRING
                -DQT_NO_CAST_FROM_BYTEARRAY
                -DQT_NO_SIGNALS_SLOTS_KEYWORDS
                -DQT_USE_FAST_OPERATOR_PLUS
                -DQT_USE_QSTRINGBUILDER
               )
50

51
find_package(Qt5 5.2.0 REQUIRED CONFIG COMPONENTS Core Test Concurrent DBus Widgets)
Dario Freddi's avatar
Dario Freddi committed
52
find_package(LibArchive REQUIRED)
Lukas Appelhans's avatar
Lukas Appelhans committed
53
find_package(Sqlite REQUIRED)
54
find_package(PolkitQt5-1 REQUIRED)
55

56
# Define install directories
57 58 59 60 61
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/akabei" CACHE "Akabei data installation directory" STRING)
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE "Akabei binary installation directory" STRING)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE "Akabei library installation directory" STRING)
set(INCLUDES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/akabeicore" CACHE "Akabei includes installation directory" STRING)
set(STATE_DIR "/var" CACHE "Directory to store cache data and log files, usually under ${STATE_DIR}/{cache,log,etc...})" STRING)
62
set(CONFIGURATION_DIR "/etc" CACHE "Directory to store Akabei’s configuration files" STRING)
63

64
configure_file(
Luca Giambonini's avatar
Luca Giambonini committed
65 66
    ${CMAKE_CURRENT_SOURCE_DIR}/akabeicoreconfig.h.cmake
    ${CMAKE_CURRENT_BINARY_DIR}/akabeicoreconfig.h
67 68
    IMMEDIATE @ONLY)

Luca Giambonini's avatar
Luca Giambonini committed
69 70
include_directories(${CMAKE_CURRENT_BINARY_DIR})

71
add_subdirectory(lib)
72 73
add_subdirectory(tools)
add_subdirectory(etc)
74
add_subdirectory(docs)
75
add_subdirectory(translations)
76

77 78
include(UseDoxygen)

79 80 81 82 83 84
### Source tarball autogeneration ###
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${AKABEI_VERSION_STRING})
add_custom_target(dist
    COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
        | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
85 86 87 88 89 90 91 92 93

# uninstall target
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

add_custom_target(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)