mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 21:34:12 +02:00
7ec13cbc1a
CMake fetches pugixml, SingleApplication and the three KDE Frameworks modules by git tag. A tag is a mutable pointer that its owner can move, so two builds of the same QElectroTech commit can silently get different third-party sources, and a compromised upstream account can change what every builder downloads without anything changing in this repository. Pinning each dependency to the commit its tag currently points at closes that, while keeping the tag name in a trailing comment so the intended version stays readable. No versions change. Every pinned commit is the one its tag resolves to, checked with git ls-remote and confirmed by fetching each one and verifying that git describe reports exactly the tag. The three KDE modules live in separate repositories and therefore need separate commits, so the single KF_GIT_TAG variable becomes three per-module variables; passing -DKF_GIT_TAG=<ref> still selects one ref for all three, unpinned, exactly as before, and KF_GIT_TAG stays defined so the build summary in define_definitions.cmake is unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
96 lines
3.7 KiB
CMake
96 lines
3.7 KiB
CMake
# Copyright 2006 The QElectroTech Team
|
|
# This file is part of QElectroTech.
|
|
#
|
|
# QElectroTech is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# QElectroTech is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
message(" - fetch_kdeaddons")
|
|
|
|
if(BUILD_WITH_KF)
|
|
Include(FetchContent)
|
|
|
|
option(BUILD_KF "Build KF libraries, use system ones otherwise" YES)
|
|
|
|
if(BUILD_KF)
|
|
|
|
# v6.10.0 is a more or less random version, taken as an conservative
|
|
# approach. Pinned to the commits those tags point at, not to the tags
|
|
# themselves; see the note in fetch_pugixml.cmake. Each module lives in its
|
|
# own repository, so the same release is a different commit in each.
|
|
set(KF_ECM_GIT_COMMIT 7dd28cc56c339c3f8fb356f7c53c0e8f61433d81) # v6.10.0
|
|
set(KF_KCOREADDONS_GIT_COMMIT c569f974dab24b4784ad186a3db4b76b2fa36612) # v6.10.0
|
|
set(KF_KWIDGETSADDONS_GIT_COMMIT 1abbed8a280d6626c59fb197f2c4667d2b1e7445) # v6.10.0
|
|
|
|
if(DEFINED KF_GIT_TAG)
|
|
# Explicit override: -DKF_GIT_TAG=<ref> selects one ref for all three
|
|
# modules, unpinned, exactly as it did before.
|
|
set(KF_ECM_GIT_COMMIT ${KF_GIT_TAG})
|
|
set(KF_KCOREADDONS_GIT_COMMIT ${KF_GIT_TAG})
|
|
set(KF_KWIDGETSADDONS_GIT_COMMIT ${KF_GIT_TAG})
|
|
else()
|
|
# Keep KF_GIT_TAG defined: define_definitions.cmake reports it.
|
|
set(KF_GIT_TAG v6.10.0)
|
|
endif()
|
|
# 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)
|
|
|
|
FetchContent_Declare(
|
|
ecm
|
|
GIT_REPOSITORY https://invent.kde.org/frameworks/extra-cmake-modules.git
|
|
GIT_TAG ${KF_ECM_GIT_COMMIT})
|
|
FetchContent_MakeAvailable(ecm)
|
|
|
|
FetchContent_Declare(
|
|
kcoreaddons
|
|
GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git
|
|
GIT_TAG ${KF_KCOREADDONS_GIT_COMMIT})
|
|
FetchContent_MakeAvailable(kcoreaddons)
|
|
|
|
FetchContent_Declare(
|
|
kwidgetsaddons
|
|
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
|
|
GIT_TAG ${KF_KWIDGETSADDONS_GIT_COMMIT})
|
|
FetchContent_MakeAvailable(kwidgetsaddons)
|
|
endfunction()
|
|
qet_make_kf_available()
|
|
else()
|
|
find_package(KF6CoreAddons REQUIRED)
|
|
find_package(KF6WidgetsAddons REQUIRED)
|
|
endif()
|
|
|
|
set(KF_PRIVATE_LIBRARIES
|
|
KF6::WidgetsAddons
|
|
KF6::CoreAddons
|
|
)
|
|
endif()
|