CMake: add a helper module for finding KPMcore
I think we had this (kind of) module a long time ago and it was removed for over-complicating things; re-introduce one now that KPMcore is used in 3 different places and all would benefit from consistent API handling / defines.
This commit is contained in:
parent
db537535ee
commit
40aa0fcaba
39
CMakeModules/KPMcoreHelper.cmake
Normal file
39
CMakeModules/KPMcoreHelper.cmake
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# === 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 ( NOT KPMcore_searched_for )
|
||||||
|
set( KPMcore_searched_for TRUE )
|
||||||
|
|
||||||
|
find_package( KPMcore 3.3 )
|
||||||
|
set_package_properties(
|
||||||
|
KPMcore PROPERTIES
|
||||||
|
URL "https://invent.kde.org/kde/kpmcore"
|
||||||
|
DESCRIPTION "KDE Partitioning library"
|
||||||
|
TYPE RECOMMENDED
|
||||||
|
PURPOSE "For disk partitioning support"
|
||||||
|
)
|
||||||
|
|
||||||
|
if( KPMcore_FOUND )
|
||||||
|
set( KPMcore_API_DEFINITIONS "" )
|
||||||
|
if( KPMcore_VERSION VERSION_GREATER "3.3.70" AND KPMcore_VERSION VERSION_LESS "4.0" )
|
||||||
|
message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} not supported" )
|
||||||
|
endif()
|
||||||
|
if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
|
||||||
|
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations
|
||||||
|
endif()
|
||||||
|
if ( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0")
|
||||||
|
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE4API) # kpmcore 4 with new API
|
||||||
|
endif()
|
||||||
|
if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" )
|
||||||
|
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE42API) # kpmcore 4.2 with new API
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set( KPMcore_API_DEFINITIONS WITHOUT_KPMcore )
|
||||||
|
endif()
|
||||||
|
endif()
|
@ -114,30 +114,13 @@ endif()
|
|||||||
### OPTIONAL KPMcore support
|
### OPTIONAL KPMcore support
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
find_package( KPMcore 3.3 )
|
include( KPMcoreHelper )
|
||||||
set_package_properties(
|
|
||||||
KPMcore PROPERTIES
|
|
||||||
URL "https://invent.kde.org/kde/kpmcore"
|
|
||||||
DESCRIPTION "KDE Partitioning library"
|
|
||||||
TYPE RECOMMENDED
|
|
||||||
PURPOSE "For partitioning service"
|
|
||||||
)
|
|
||||||
|
|
||||||
if ( KPMcore_FOUND )
|
if ( KPMcore_FOUND )
|
||||||
find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore
|
find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore
|
||||||
find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore
|
find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore
|
||||||
|
|
||||||
if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" )
|
add_definitions( ${KPMcore_API_DEFINITIONS} )
|
||||||
add_definitions(
|
|
||||||
-DWITH_KPMCORE42API
|
|
||||||
-DWITH_KPMCORE4API
|
|
||||||
) # kpmcore 4.2 with new API
|
|
||||||
elseif( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" )
|
|
||||||
add_definitions( -DWITH_KPMCORE4API ) # kpmcore 4 with new API
|
|
||||||
elseif( KPMcore_VERSION VERSION_GREATER "3.3.70" )
|
|
||||||
message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} not supported" )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
||||||
list( APPEND libSources
|
list( APPEND libSources
|
||||||
partition/FileSystem.cpp
|
partition/FileSystem.cpp
|
||||||
|
@ -3,24 +3,15 @@
|
|||||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
#
|
#
|
||||||
find_package( KPMcore 3.3 )
|
|
||||||
find_package( KF5Config CONFIG )
|
find_package( KF5Config CONFIG )
|
||||||
find_package( KF5I18n CONFIG )
|
find_package( KF5I18n CONFIG )
|
||||||
find_package( KF5WidgetsAddons CONFIG )
|
find_package( KF5WidgetsAddons CONFIG )
|
||||||
|
|
||||||
set( _partition_defs "" )
|
include( KPMcoreHelper )
|
||||||
|
|
||||||
if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
|
if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
|
||||||
include_directories( ${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition )
|
include_directories( ${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition )
|
||||||
|
|
||||||
if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" )
|
|
||||||
list( APPEND _partition_defs WITH_KPMCORE42API WITH_KPMCORE4API ) # kpmcore 4.2 with new API
|
|
||||||
elseif( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" )
|
|
||||||
list( APPEND _partition_defs WITH_KPMCORE4API ) # kpmcore 4 with new API
|
|
||||||
elseif( KPMcore_VERSION VERSION_GREATER "3.3.70" )
|
|
||||||
message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} are not supported" )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# The PartitionIterator is a small class, and it's easiest -- but also a
|
# The PartitionIterator is a small class, and it's easiest -- but also a
|
||||||
# gross hack -- to just compile it again from the partition module tree.
|
# gross hack -- to just compile it again from the partition module tree.
|
||||||
calamares_add_plugin( fsresizer
|
calamares_add_plugin( fsresizer
|
||||||
@ -31,7 +22,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
|
|||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
kpmcore
|
kpmcore
|
||||||
calamares
|
calamares
|
||||||
COMPILE_DEFINITIONS ${_partition_defs}
|
COMPILE_DEFINITIONS ${KPMcore_API_DEFINITIONS}
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,7 +33,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
|
|||||||
LIBRARIES
|
LIBRARIES
|
||||||
calamares_job_fsresizer # From above
|
calamares_job_fsresizer # From above
|
||||||
yamlcpp
|
yamlcpp
|
||||||
DEFINITIONS ${_partition_defs}
|
DEFINITIONS ${KPMcore_API_DEFINITIONS}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
if ( NOT KPMcore_FOUND )
|
if ( NOT KPMcore_FOUND )
|
||||||
|
@ -31,26 +31,14 @@ endif()
|
|||||||
|
|
||||||
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
||||||
|
|
||||||
find_package( KPMcore 3.3 )
|
include( KPMcoreHelper )
|
||||||
set_package_properties(
|
|
||||||
KPMcore PROPERTIES
|
|
||||||
PURPOSE "For partition module"
|
|
||||||
)
|
|
||||||
find_package( KF5Config CONFIG )
|
find_package( KF5Config CONFIG )
|
||||||
find_package( KF5I18n CONFIG )
|
find_package( KF5I18n CONFIG )
|
||||||
find_package( KF5WidgetsAddons CONFIG )
|
find_package( KF5WidgetsAddons CONFIG )
|
||||||
|
|
||||||
if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
|
if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND )
|
||||||
if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
|
list( APPEND _partition_defs ${KPMcore_API_DEFINITIONS} )
|
||||||
list( APPEND _partition_defs WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations
|
|
||||||
endif()
|
|
||||||
if ( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0")
|
|
||||||
list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API
|
|
||||||
endif()
|
|
||||||
if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" )
|
|
||||||
list( APPEND _partition_defs WITH_KPMCORE42API) # kpmcore 4.2 with new API
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
||||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user