Bug 504518

Summary: ECMSetupVersion.cmake uses deprecated policies (breaks tests with CMake 4)
Product: [Frameworks and Libraries] extra-cmake-modules Reporter: Klaus Zimmermann <klaus_zimmermann>
Component: generalAssignee: ecm-bugs-null <ecm-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: klaus_zimmermann
Priority: NOR    
Version First Reported In: 6.13.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.17.0
Sentry Crash Report:

Description Klaus Zimmermann 2025-05-19 11:50:43 UTC
SUMMARY
CMake version 4.0 removes policy CMP0048, which breaks the test ECMGeneratePkgConfigFile.
That is because the test does not call the project macro, but with CMP0048 now always being true,
ecm_setup_version assumes that project manages the PROJECT_VERSION macros, c.f. https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/master/modules/ECMSetupVersion.cmake?ref_type=heads#L113 and https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/master/modules/ECMSetupVersion.cmake?ref_type=heads#L164.


STEPS TO REPRODUCE
1. Install cmake>=4 or force CMP0048 to NEW
2. Run ECMGeneratePkgConfigFile test

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
This surfaced while updating the extra-cmake-modules package for conda-forge at https://github.com/conda-forge/extra-cmake-modules-feedstock/pull/68
Comment 1 Christophe Marin 2025-08-01 08:03:45 UTC
Git commit 972be57827edd88af97dc740eb55dd19ce1f85e8 by Christophe Marin, on behalf of Heiko Becker.
Committed on 01/08/2025 at 08:03.
Pushed by krop into branch 'master'.

ECMSetupVersion: Adapt to the removal of CMP0048 with cmake 4.0

**Move ECMGeneratePkgConfigFiles's tests to separate projects**
    
    With cmake >=4.0 CMP0048 doesn't exist anymore and ECMSetupVersion
    doesn't set PROJECT_VERSION* anymore.
    Script mode doesn't allow to set project, so move the tests from
    run_test.cmake to separate projects.

**ECMSetupVersion: Adapt to the removal of CMP0048 with cmake 4.0**
    
    Because the policy was removed and thus can't be set anymore, it doesn't
    make sense to test the old behaviour, so just skip these tests.
    
    This is another piece to make the tests run successfully with CMake >=
    4.0.0-rc1.
FIXED-IN: 6.17.0

M  +2    -1    modules/ECMGeneratePkgConfigFile.cmake
M  +15   -8    modules/ECMSetupVersion.cmake
M  +16   -5    tests/ECMGeneratePkgConfigFile/CMakeLists.txt
A  +28   -0    tests/ECMGeneratePkgConfigFile/custom_defines/CMakeLists.txt
A  +29   -0    tests/ECMGeneratePkgConfigFile/no_description_parameter_metainfo_with_description-param/CMakeLists.txt
A  +29   -0    tests/ECMGeneratePkgConfigFile/no_description_parameter_metainfo_with_empty_description/CMakeLists.txt
A  +29   -0    tests/ECMGeneratePkgConfigFile/no_description_parameter_metainfo_without_description/CMakeLists.txt
A  +24   -0    tests/ECMGeneratePkgConfigFile/no_optional_arguments/CMakeLists.txt
D  +0    -161  tests/ECMGeneratePkgConfigFile/run_test.cmake.config
A  +32   -0    tests/ECMGeneratePkgConfigFile/test-and-comparison-helpers.cmake
A  +26   -0    tests/ECMGeneratePkgConfigFile/with_an_URL_parameter/CMakeLists.txt
A  +29   -0    tests/ECMGeneratePkgConfigFile/with_public_and_private_dependencies/CMakeLists.txt
M  +14   -10   tests/ECMSetupVersionTest/CMakeLists.txt

https://invent.kde.org/frameworks/extra-cmake-modules/-/commit/972be57827edd88af97dc740eb55dd19ce1f85e8