Debian Codegraph @

CMakeModules/KPMcoreHelper.cmake

raw
1 # === This file is part of Calamares - <https://calamares.io> ===
2 #
3 # SPDX-FileCopyrightText: 2020 Adriaan de Groot <[email protected]>
4 # SPDX-License-Identifier: BSD-2-Clause
5 #
6 ###
7 #
8 # Finds KPMcore and consistently sets API flags based on the version.
9 #
10 # If KPMcore is not found, still create calamares::kpmcore interface
11 # library, which will add definition WITHOUT_KPMcore.
12 #
13 if(NOT TARGET calapmcore)
14 find_package(${kfname}Config CONFIG)
15 find_package(${kfname}I18n CONFIG)
16 find_package(${kfname}WidgetsAddons CONFIG)
17
18 if(WITH_QT6)
19 find_package(KPMcore 24.01.75)
20 else()
21 find_package(KPMcore 20.04.0)
22 endif()
23 set_package_properties(
24 KPMcore
25 PROPERTIES
26 URL "https://invent.kde.org/kde/kpmcore"
27 DESCRIPTION "KDE Partitioning library"
28 TYPE RECOMMENDED
29 PURPOSE "For disk partitioning support"
30 )
31
32 # Create an internal Calamares interface to KPMcore
33 # and give it a nice alias name. If kpmcore is not found,
34 # then make a "no KPMcore" library.
35 add_library(calapmcore INTERFACE)
36
37 if(KPMcore_FOUND)
38 find_package(${qtname} REQUIRED DBus) # Needed for KPMCore
39 find_package(${kfname}I18n REQUIRED) # Needed for KPMCore
40 find_package(${kfname}WidgetsAddons REQUIRED) # Needed for KPMCore
41
42 target_link_libraries(calapmcore INTERFACE kpmcore ${qtname}::DBus ${kfname}::I18n ${kfname}::WidgetsAddons)
43 target_include_directories(calapmcore INTERFACE ${KPMCORE_INCLUDE_DIR})
44 math(EXPR _kpm_version_number "(0x${KPMcore_VERSION_MAJOR} * 0x10000)+(0x${KPMcore_VERSION_MINOR} * 0x100)+(0x${KPMcore_VERSION_PATCH})" OUTPUT_FORMAT HEXADECIMAL)
45 target_compile_definitions(calapmcore INTERFACE WITH_KPMcore=${_kpm_version_number})
46
47 # Flag that this library has KPMcore support. A variable
48 # set here has the wrong scope. ENV{} would be visible
49 # everywhere but seems the wrong thing to do. Setting
50 # properties on calapmcore requires a newer CMake than
51 # Debian 11 has, so runs into support issues.
52 add_library(calamares::kpmcore ALIAS calapmcore)
53 else()
54 target_compile_definitions(calapmcore INTERFACE WITHOUT_KPMcore)
55 endif()
56 else()
57 if(TARGET calamares::kpmcore)
58 message(STATUS "KPMcore has already been found")
59 set(KPMcore_FOUND TRUE)
60 else()
61 message(STATUS "KPMcore has been searched-for and not found")
62 set(KPMcore_FOUND FALSE)
63 endif()
64 endif()