From ab813b607f0973b764fa96826a0ae4a8599c2b03 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Jul 2022 11:31:32 +0200 Subject: [PATCH 1/5] CMake: move kpmcore support into the helper-CMake-module - find the dependencies just once - fix the interface for kpmcore so it can find its own includes (this is mostly relevant for Debian) --- CMakeModules/KPMcoreHelper.cmake | 7 +++++++ src/libcalamares/CMakeLists.txt | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeModules/KPMcoreHelper.cmake b/CMakeModules/KPMcoreHelper.cmake index 05dff18dd..3d4f520f5 100644 --- a/CMakeModules/KPMcoreHelper.cmake +++ b/CMakeModules/KPMcoreHelper.cmake @@ -18,10 +18,17 @@ if ( NOT KPMcore_searched_for ) TYPE RECOMMENDED PURPOSE "For disk partitioning support" ) + find_package(Qt5 REQUIRED DBus) # Needed for KPMCore + find_package(KF5 REQUIRED I18n WidgetsAddons) # Needed for KPMCore if( KPMcore_FOUND ) set( KPMcore_API_DEFINITIONS "" ) else() set( KPMcore_API_DEFINITIONS WITHOUT_KPMcore ) endif() + + foreach(d ${KPMcore_API_DEFINITIONS}) + target_compile_definitions(kpmcore INTERFACE ${d}) + endforeach() + target_include_directories(kpmcore INTERFACE ${KPMCORE_INCLUDE_DIR}) endif() diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 181ec2b30..09291707c 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -115,13 +115,6 @@ endif() include(KPMcoreHelper) if(KPMcore_FOUND) - find_package(Qt5 REQUIRED DBus) # Needed for KPMCore - find_package(KF5 REQUIRED I18n WidgetsAddons) # Needed for KPMCore - - foreach(d ${KPMcore_API_DEFINITIONS}) - add_definitions(-D${d}) - endforeach() - include_directories(${KPMCORE_INCLUDE_DIR}) target_sources( calamares PRIVATE From fb620464d78c710bb3d0f8232ec08e5e2bc53074 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Jul 2022 11:39:57 +0200 Subject: [PATCH 2/5] CMake: create an alias for KPMcore that fixes its interface - kpmcore (when used as target "kpmcore") has an interface include directory that does not contain the "kpmcore/" subdirectory. But the headers it has installed, assume it is there (e.g. kpmcore internals use #include ). - add an alias at Calamares level that sticks in some more includes, adds the relevant WITHOUT_kpmcore when it's not there, etc. --- CMakeModules/KPMcoreHelper.cmake | 43 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/CMakeModules/KPMcoreHelper.cmake b/CMakeModules/KPMcoreHelper.cmake index 3d4f520f5..d0cb95239 100644 --- a/CMakeModules/KPMcoreHelper.cmake +++ b/CMakeModules/KPMcoreHelper.cmake @@ -7,28 +7,49 @@ # # Finds KPMcore and consistently sets API flags based on the version. # -if ( NOT KPMcore_searched_for ) - set( KPMcore_searched_for TRUE ) +# If KPMcore is not found, still create calamares::kpmcore interface +# library, which will add definition WITHOUT_KPMcore. +# +if(NOT KPMcore_searched_for AND NOT TARGET calapmcore) + set(KPMcore_searched_for TRUE) - find_package( KPMcore 21.12.0 ) + find_package(KPMcore 20.04.0) set_package_properties( - KPMcore PROPERTIES + KPMcore + PROPERTIES URL "https://invent.kde.org/kde/kpmcore" DESCRIPTION "KDE Partitioning library" TYPE RECOMMENDED PURPOSE "For disk partitioning support" ) - find_package(Qt5 REQUIRED DBus) # Needed for KPMCore - find_package(KF5 REQUIRED I18n WidgetsAddons) # Needed for KPMCore - if( KPMcore_FOUND ) - set( KPMcore_API_DEFINITIONS "" ) + # 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(Qt5 REQUIRED DBus) # Needed for KPMCore + find_package(KF5 REQUIRED I18n WidgetsAddons) # Needed for KPMCore + + target_link_libraries(calapmcore INTERFACE kpmcore Qt5::DBus KF5::I18n KF5::WidgetsAddons) + target_include_directories(calapmcore INTERFACE ${KPMCORE_INCLUDE_DIR}) + set(KPMcore_API_DEFINITIONS "") else() - set( KPMcore_API_DEFINITIONS WITHOUT_KPMcore ) + set(KPMcore_API_DEFINITIONS WITHOUT_KPMcore) endif() foreach(d ${KPMcore_API_DEFINITIONS}) - target_compile_definitions(kpmcore INTERFACE ${d}) + target_compile_definitions(calapmcore INTERFACE ${d}) endforeach() - target_include_directories(kpmcore INTERFACE ${KPMCORE_INCLUDE_DIR}) + + add_library(calamares::kpmcore ALIAS calapmcore) +else() + if(TARGET calapmcore) + 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() From 3360ad612e19ed47ec903607ccf0280a667d15c4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Jul 2022 11:43:01 +0200 Subject: [PATCH 3/5] [libcalamares] Use Calamares interface-library to kpmcore --- src/libcalamares/CMakeLists.txt | 6 +++--- src/modules/fsresizer/CMakeLists.txt | 4 ++-- src/modules/partition/CMakeLists.txt | 6 ++---- src/modules/partition/tests/CMakeLists.txt | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 09291707c..1798d2ee4 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -123,7 +123,7 @@ if(KPMcore_FOUND) partition/PartitionIterator.cpp partition/PartitionQuery.cpp ) - target_link_libraries(calamares PRIVATE kpmcore) + target_link_libraries(calamares PRIVATE calamares::kpmcore) endif() ### LIBRARY @@ -238,8 +238,8 @@ calamares_add_test(libcalamaresnetworktest SOURCES network/Tests.cpp) calamares_add_test(libcalamarespackagestest SOURCES packages/Tests.cpp) if(KPMcore_FOUND) - calamares_add_test(libcalamarespartitiontest SOURCES partition/Global.cpp partition/Tests.cpp LIBRARIES kpmcore) - calamares_add_test(libcalamarespartitionkpmtest SOURCES partition/KPMTests.cpp LIBRARIES kpmcore) + calamares_add_test(libcalamarespartitiontest SOURCES partition/Global.cpp partition/Tests.cpp LIBRARIES calamares::kpmcore) + calamares_add_test(libcalamarespartitionkpmtest SOURCES partition/KPMTests.cpp LIBRARIES calamares::kpmcore) endif() calamares_add_test(libcalamaresutilstest SOURCES utils/Tests.cpp utils/Runner.cpp) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 189e7c1dc..f4c94bc8b 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(KF5WidgetsAddons CONFIG) include(KPMcoreHelper) -if(KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND) +if(KPMcore_FOUND) include_directories(${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition) # The PartitionIterator is a small class, and it's easiest -- but also a @@ -20,7 +20,7 @@ if(KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND) SOURCES ResizeFSJob.cpp LINK_PRIVATE_LIBRARIES - kpmcore + calamares::kpmcore COMPILE_DEFINITIONS ${KPMcore_API_DEFINITIONS} SHARED_LIB ) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 6d07ec281..3b6269854 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -49,9 +49,7 @@ find_package(KF5Config CONFIG) find_package(KF5I18n CONFIG) find_package(KF5WidgetsAddons CONFIG) -if(KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND) - list(APPEND _partition_defs ${KPMcore_API_DEFINITIONS}) - include_directories(${KPMCORE_INCLUDE_DIR}) +if(KPMcore_FOUND) include_directories(${PROJECT_BINARY_DIR}/src/libcalamaresui) add_subdirectory(tests) @@ -118,7 +116,7 @@ if(KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND) gui/ReplaceWidget.ui gui/VolumeGroupBaseDialog.ui LINK_PRIVATE_LIBRARIES - kpmcore + calamares::kpmcore KF5::CoreAddons COMPILE_DEFINITIONS ${_partition_defs} SHARED_LIB diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 26a1d83f9..9c5dd3257 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -25,14 +25,14 @@ calamares_add_test( ${PartitionModule_SOURCE_DIR}/jobs/DeletePartitionJob.cpp ${PartitionModule_SOURCE_DIR}/jobs/PartitionJob.cpp ${PartitionModule_SOURCE_DIR}/jobs/ResizePartitionJob.cpp - LIBRARIES kpmcore + LIBRARIES calamares::kpmcore DEFINITIONS ${_partition_defs} ) calamares_add_test( partitionclearmountsjobtest SOURCES ${PartitionModule_SOURCE_DIR}/jobs/ClearMountsJob.cpp ClearMountsJobTests.cpp - LIBRARIES kpmcore + LIBRARIES calamares::kpmcore DEFINITIONS ${_partition_defs} ) @@ -45,7 +45,7 @@ calamares_add_test( ${PartitionModule_SOURCE_DIR}/core/PartitionLayout.cpp ${PartitionModule_SOURCE_DIR}/core/PartUtils.cpp ${PartitionModule_SOURCE_DIR}/core/DeviceModel.cpp - LIBRARIES kpmcore Calamares::calamaresui + LIBRARIES calamares::kpmcore Calamares::calamaresui DEFINITIONS ${_partition_defs} ) @@ -58,6 +58,6 @@ calamares_add_test( calamares_add_test( partitiondevicestest SOURCES DevicesTests.cpp ${PartitionModule_SOURCE_DIR}/core/DeviceList.cpp - LIBRARIES kpmcore + LIBRARIES calamares::kpmcore DEFINITIONS ${_partition_defs} ) From eccfdbd9867f5dd1b79844a5a7ebad0dfd0e6709 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Jul 2022 12:01:39 +0200 Subject: [PATCH 4/5] [libcalamares] Mark a TODO that is causing build failures --- src/libcalamares/partition/Global.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcalamares/partition/Global.h b/src/libcalamares/partition/Global.h index b76c74c58..64c221240 100644 --- a/src/libcalamares/partition/Global.h +++ b/src/libcalamares/partition/Global.h @@ -20,6 +20,8 @@ #include "FileSystem.h" #include "JobQueue.h" +// TODO: this assumes KPMcore is present, but the header and TU +// are used always. #include namespace CalamaresUtils From 64eed3a40cc72e0db0c2f0d12bd470751efdeb3b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Jul 2022 23:17:08 +0200 Subject: [PATCH 5/5] CI: remove nonsense CMake flags --- .github/workflows/nightly-debian.yml | 2 -- .github/workflows/nightly-neon.yml | 2 -- .github/workflows/nightly-opensuse.yml | 2 -- 3 files changed, 6 deletions(-) diff --git a/.github/workflows/nightly-debian.yml b/.github/workflows/nightly-debian.yml index f201729db..d24df05a0 100644 --- a/.github/workflows/nightly-debian.yml +++ b/.github/workflows/nightly-debian.yml @@ -9,9 +9,7 @@ env: BUILDDIR: /build SRCDIR: ${{ github.workspace }} CMAKE_ARGS: | - -DWEBVIEW_FORCE_WEBKIT=1 -DKDE_INSTALL_USE_QT_SYS_PATHS=ON - -DWITH_PYTHONQT=OFF" -DCMAKE_BUILD_TYPE=Debug jobs: diff --git a/.github/workflows/nightly-neon.yml b/.github/workflows/nightly-neon.yml index b0c576721..daa04a215 100644 --- a/.github/workflows/nightly-neon.yml +++ b/.github/workflows/nightly-neon.yml @@ -9,9 +9,7 @@ env: BUILDDIR: /build SRCDIR: ${{ github.workspace }} CMAKE_ARGS: | - -DWEBVIEW_FORCE_WEBKIT=1 -DKDE_INSTALL_USE_QT_SYS_PATHS=ON - -DWITH_PYTHONQT=OFF" -DCMAKE_BUILD_TYPE=Debug jobs: diff --git a/.github/workflows/nightly-opensuse.yml b/.github/workflows/nightly-opensuse.yml index 0bc0e74e7..0ad5d058e 100644 --- a/.github/workflows/nightly-opensuse.yml +++ b/.github/workflows/nightly-opensuse.yml @@ -9,9 +9,7 @@ env: BUILDDIR: /build SRCDIR: ${{ github.workspace }} CMAKE_ARGS: | - -DWEBVIEW_FORCE_WEBKIT=1 -DKDE_INSTALL_USE_QT_SYS_PATHS=ON - -DWITH_PYTHONQT=OFF" -DCMAKE_BUILD_TYPE=Debug jobs: