From af87d28e33ebdd388e835636c88c49e376f2cc3d Mon Sep 17 00:00:00 2001 From: Andre Rummler Date: Mon, 10 Aug 2026 19:47:34 +0200 Subject: [PATCH] Fix several parameters after Qt6 migration. --- .github/workflows/windows-build.yml | 2 +- CMakeLists.txt | 12 +++- cmake/fetch_kdeaddons.cmake | 93 +++++++++++++++-------------- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index e41a6cf5a..2a5eeb7df 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -113,7 +113,7 @@ jobs: -DQt5_DIR=/ucrt64/lib/cmake/Qt5 \ -DQT_VERSION_MAJOR=5 \ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON \ - -DBUILD_TESTING=OFF \ + -DPACKAGE_TESTS=OFF \ -DCMAKE_POLICY_DEFAULT_CMP0077=NEW \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DCMAKE_CXX_FLAGS="-DQET_EXPORT_PROJECT_DB" \ diff --git a/CMakeLists.txt b/CMakeLists.txt index f3bdaf9e0..2bf51eff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ find_package( # and only provide the implicit Qt6::GuiPrivate target created alongside # Qt6::Gui. Try the component quietly, then verify the target below so a # missing private-headers package fails here instead of at compile time. -# Qt5 has no such component — its GuiPrivate target always exists once Gui is found. +# Qt5 has no such component as its GuiPrivate target always exists once Gui is found. if(QT_VERSION_MAJOR GREATER_EQUAL 6) find_package(Qt6 QUIET COMPONENTS GuiPrivate) endif() @@ -91,6 +91,16 @@ endif() find_package(SQLite3 REQUIRED) +# CMake < 4.3 only creates the SQLite::SQLite3 target (no SQLite3::SQLite3 +# alias yet), while CMake >= 4.3's bundled FindSQLite3 creates SQLite3::SQLite3 +# and deprecates the old name. Add the missing alias ourselves so we can use +# the modern target name everywhere regardless of the CMake version in use +# (this project must keep building on CMake versions below 4.3, e.g. on most +# current Linux distros). +if(NOT TARGET SQLite3::SQLite3 AND TARGET SQLite::SQLite3) + add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3) +endif() + set(CMAKE_AUTOUIC_SEARCH_PATHS ${QET_DIR}/sources/ui) if(QT_VERSION_MAJOR EQUAL 6) diff --git a/cmake/fetch_kdeaddons.cmake b/cmake/fetch_kdeaddons.cmake index d5f3affcf..b8c7e1d51 100644 --- a/cmake/fetch_kdeaddons.cmake +++ b/cmake/fetch_kdeaddons.cmake @@ -20,58 +20,63 @@ message(" - fetch_kdeaddons") if(BUILD_WITH_KF) Include(FetchContent) - option(BUILD_KF "Build KF5 libraries, use system ones otherwise" YES) + option(BUILD_KF "Build KF libraries, use system ones otherwise" YES) if(BUILD_KF) - if(KF_MAJOR_VERSION EQUAL 5) - if(NOT DEFINED KF_GIT_TAG) - #https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924 - set(KF_GIT_TAG v5.77.0) + if(KF_MAJOR_VERSION EQUAL 5) + if(NOT DEFINED KF_GIT_TAG) + #https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924 + set(KF_GIT_TAG v5.77.0) + endif() + else() + if(NOT DEFINED KF_GIT_TAG) + # this is a more or less random version, taken as an conservative approach + set(KF_GIT_TAG v6.10.0) + endif() endif() - else() - if(NOT DEFINED KF_GIT_TAG) - set(KF_GIT_TAG v6.10.0) - endif() - endif() - - # Fix stop the run autotests of kcoreaddons - # see - # https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/CMakeLists.txt#L98 - # issue: - # CMake Error at /usr/share/ECM/modules/ECMAddTests.cmake:89 (add_executable): - # Cannot find source file: - # see - # https://qelectrotech.org/forum/viewtopic.php?pid=13929#p13929 - set(KDE_SKIP_TEST_SETTINGS "TRUE") - set(BUILD_TESTING "0") + // using a function in order to limit the scope of the variables + // with CMake >=3.25 we could use a block() + function(qet_make_kf_available) + # Fix stop the run autotests of kcoreaddons + # see + # https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/CMakeLists.txt#L98 + # issue: + # CMake Error at /usr/share/ECM/modules/ECMAddTests.cmake:89 (add_executable): + # Cannot find source file: + # see + # https://qelectrotech.org/forum/viewtopic.php?pid=13929#p13929 + set(KDE_SKIP_TEST_SETTINGS ON) + set(BUILD_TESTING OFF) - # QElectroTech is a plain QtWidgets application with no QML anywhere in - # it; these disable optional features of the fetched KF modules that - # would otherwise pull in extra Qt6 components (e.g. Qt6Qml) we don't - # have and don't need. - set(BUILD_DESIGNERPLUGIN OFF) - set(KCOREADDONS_USE_QML OFF) - set(BUILD_QCH OFF) - set(BUILD_SHARED_LIBS OFF) + # QElectroTech is a plain QtWidgets application with no QML anywhere in + # it; these disable optional features of the fetched KF modules that + # would otherwise pull in extra Qt6 components (e.g. Qt6Qml) we don't + # have and don't need. + set(BUILD_DESIGNERPLUGIN OFF) + set(KCOREADDONS_USE_QML OFF) + set(BUILD_QCH OFF) + set(BUILD_SHARED_LIBS OFF) - FetchContent_Declare( - ecm - GIT_REPOSITORY https://invent.kde.org/frameworks/extra-cmake-modules.git - GIT_TAG ${KF_GIT_TAG}) - FetchContent_MakeAvailable(ecm) + FetchContent_Declare( + ecm + GIT_REPOSITORY https://invent.kde.org/frameworks/extra-cmake-modules.git + GIT_TAG ${KF_GIT_TAG}) + FetchContent_MakeAvailable(ecm) - FetchContent_Declare( - kcoreaddons - GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git - GIT_TAG ${KF_GIT_TAG}) - FetchContent_MakeAvailable(kcoreaddons) + FetchContent_Declare( + kcoreaddons + GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git + GIT_TAG ${KF_GIT_TAG}) + FetchContent_MakeAvailable(kcoreaddons) - FetchContent_Declare( - kwidgetsaddons - GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git - GIT_TAG ${KF_GIT_TAG}) - FetchContent_MakeAvailable(kwidgetsaddons) + FetchContent_Declare( + kwidgetsaddons + GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git + GIT_TAG ${KF_GIT_TAG}) + FetchContent_MakeAvailable(kwidgetsaddons) + endfunction() + qet_make_kf_available() else() find_package(KF${KF_MAJOR_VERSION}CoreAddons REQUIRED) find_package(KF${KF_MAJOR_VERSION}WidgetsAddons REQUIRED)