File: KPMcoreHelper.cmake

package info (click to toggle)
calamares 3.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,104 kB
  • sloc: cpp: 71,902; python: 4,365; xml: 1,379; sh: 717; ansic: 105; makefile: 7
file content (64 lines) | stat: -rw-r--r-- 2,507 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# === This file is part of Calamares - <https://calamares.io> ===
#
#   SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
#   SPDX-License-Identifier: BSD-2-Clause
#
###
#
# Finds KPMcore and consistently sets API flags based on the version.
#
# If KPMcore is not found, still create calamares::kpmcore interface
# library, which will add definition WITHOUT_KPMcore.
#
if(NOT TARGET calapmcore)
    find_package(${kfname}Config CONFIG)
    find_package(${kfname}I18n CONFIG)
    find_package(${kfname}WidgetsAddons CONFIG)

    if(WITH_QT6)
        find_package(KPMcore 24.01.75)
    else()
        find_package(KPMcore 20.04.0)
    endif()
    set_package_properties(
        KPMcore
        PROPERTIES
        URL "https://invent.kde.org/kde/kpmcore"
        DESCRIPTION "KDE Partitioning library"
        TYPE RECOMMENDED
        PURPOSE "For disk partitioning support"
    )

    # Create an internal Calamares interface to KPMcore
    # and give it a nice alias name. If kpmcore is not found,
    # then make a "no KPMcore" library.
    add_library(calapmcore INTERFACE)

    if(KPMcore_FOUND)
        find_package(${qtname} REQUIRED DBus) # Needed for KPMCore
        find_package(${kfname}I18n REQUIRED) # Needed for KPMCore
        find_package(${kfname}WidgetsAddons REQUIRED) # Needed for KPMCore

        target_link_libraries(calapmcore INTERFACE kpmcore ${qtname}::DBus ${kfname}::I18n ${kfname}::WidgetsAddons)
        target_include_directories(calapmcore INTERFACE ${KPMCORE_INCLUDE_DIR})
        math(EXPR _kpm_version_number "(0x${KPMcore_VERSION_MAJOR} * 0x10000)+(0x${KPMcore_VERSION_MINOR} * 0x100)+(0x${KPMcore_VERSION_PATCH})" OUTPUT_FORMAT HEXADECIMAL)
        target_compile_definitions(calapmcore INTERFACE WITH_KPMcore=${_kpm_version_number})

        # Flag that this library has KPMcore support. A variable
        # set here has the wrong scope. ENV{} would be visible
        # everywhere but seems the wrong thing to do. Setting
        # properties on calapmcore requires a newer CMake than
        # Debian 11 has, so runs into support issues.
        add_library(calamares::kpmcore ALIAS calapmcore)
    else()
        target_compile_definitions(calapmcore INTERFACE WITHOUT_KPMcore)
    endif()
else()
    if(TARGET calamares::kpmcore)
        message(STATUS "KPMcore has already been found")
        set(KPMcore_FOUND TRUE)
    else()
        message(STATUS "KPMcore has been searched-for and not found")
        set(KPMcore_FOUND FALSE)
    endif()
endif()