CMakeLists.txt 3.69 KB
Newer Older
1
2
3
# SPDX-FileCopyrightText: 2008 Volker Lanz <vl@fidra.de>
# SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
# SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu>
4
# SPDX-FileCopyrightText: 2020 David Edmundson <kde@davidedmundson.co.uk>
5
6

# SPDX-License-Identifier: GPL-3.0-or-later
7

8
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
9

10
# KDE Application Version, managed by release script
11
12
set (RELEASE_SERVICE_VERSION_MAJOR "22")
set (RELEASE_SERVICE_VERSION_MINOR "03")
13
14
15
16
set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(kpmcore VERSION ${RELEASE_SERVICE_VERSION})

17
set(SOVERSION "12")
18
19
20
add_definitions(-D'VERSION="${RELEASE_SERVICE_VERSION}"') #"


21
22
23
set(CMAKE_USE_RELATIVE_PATHS OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)

24
# Dependencies
Andrius Štikonas's avatar
Andrius Štikonas committed
25
set(QT_MIN_VERSION "5.15.0")
26
set(KF5_MIN_VERSION "5.88")
27
set(BLKID_MIN_VERSION "2.33.2")
28
# PolkitQt5-1
29
30

# Runtime
31
# smartmontools 7.0
32

33
set(CMAKE_CXX_STANDARD 17)
34
35
set(CMAKE_CXX_STANDARD_REQUIRED ON)

36
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
37
38
39
40
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")

include(KDEInstallDirs)
include(KDECMakeSettings)
Andrius Štikonas's avatar
Andrius Štikonas committed
41
include(KDECompilerSettings NO_POLICY_SCOPE)
42
43
44
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMSetupVersion)
David Edmundson's avatar
David Edmundson committed
45
include(ECMConfiguredInstall)
46

47
ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KPMCORE
48
                        VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpmcore_version.h"
49
                        PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPMcoreConfigVersion.cmake"
50
                        SOVERSION ${SOVERSION})
51

Andrius Štikonas's avatar
Andrius Štikonas committed
52
53
54
55
56
if (NOT QT_MAJOR_VERSION)
    set(QT_MAJOR_VERSION "5")
endif()

find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} COMPONENTS REQUIRED
57
  Core
58
  DBus
59
60
61
62
63
  Gui
  Widgets
)

# Load the frameworks we need
64
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
Andrius Štikonas's avatar
Andrius Štikonas committed
65
  CoreAddons
66
  I18n
67
  WidgetsAddons
68
69
)

Andrius Štikonas's avatar
Andrius Štikonas committed
70
find_package(PolkitQt${QT_MAJOR_VERSION}-1 REQUIRED)
71

72
73
74
75
76
77
78
79
# use sane compile flags
add_definitions(
  -DQT_USE_QSTRINGBUILDER
  -DQT_NO_CAST_TO_ASCII
  -DQT_NO_CAST_FROM_ASCII
  -DQT_STRICT_ITERATORS
  -DQT_NO_URL_CAST_FROM_STRING
  -DQT_NO_CAST_FROM_BYTEARRAY
80
  -DQT_NO_CAST_TO_BYTEARRAY
81
  -DQT_USE_FAST_OPERATOR_PLUS
82
  -DQT_NO_KEYWORDS
Andrius Štikonas's avatar
Andrius Štikonas committed
83
  -DQT_DISABLE_DEPRECATED_BEFORE=0x050f00
84
)
85
86
kde_enable_exceptions()

87
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
88
  find_package(PkgConfig REQUIRED)
89
  pkg_check_modules(BLKID REQUIRED blkid>=${BLKID_MIN_VERSION})
90
endif()
91
92
93
94

add_subdirectory(src)

# create a Config.cmake and a ConfigVersion.cmake file and install them
Andrius Štikonas's avatar
Andrius Štikonas committed
95
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KPMcore")
96

97
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KPMcoreConfig.cmake.in"
98
                              "${CMAKE_CURRENT_BINARY_DIR}/KPMcoreConfig.cmake"
99
                              INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
100
                              PATH_VARS INCLUDE_INSTALL_DIR
101
102
                              )

103
104
install(FILES  "${CMAKE_CURRENT_BINARY_DIR}/KPMcoreConfig.cmake"
               "${CMAKE_CURRENT_BINARY_DIR}/KPMcoreConfigVersion.cmake"
105
106
107
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel )

108
install(EXPORT KPMcoreTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KPMcoreTargets.cmake )
109
110
111

ki18n_install(po)

112
set_target_properties( kpmcore
113
  PROPERTIES VERSION ${RELEASE_SERVICE_VERSION} SOVERSION ${SOVERSION}
114
115
)

116
message(STATUS "kpmcore ${RELEASE_SERVICE_VERSION} will be built for install into ${CMAKE_INSTALL_PREFIX}")
117
118

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
119
120
121

enable_testing()
add_subdirectory(test)