cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.
MIT License
3.04k stars 187 forks source link

GTest configuration fails as of CPM version ``0.40.1`` #603

Open DNKpp opened 1 month ago

DNKpp commented 1 month ago

As the title already states, my project fails configuring when upgrading CPM to Version 0.40.1 and beyond, due to this error:

1> [CMake] CMake Error: File /home/dnkpp/.vs/cpm_test/952dbcb6-53c6-4ed1-b2ba-4d91dcbd3971/out/build/Linux-Clang-Debug/_deps/gtest-src/cmake/Config.cmake.in does not exist.
1> [CMake] CMake Error at /usr/local/share/cmake-3.28/Modules/CMakePackageConfigHelpers.cmake:344 (configure_file):
1> [CMake]   configure_file Problem configuring file
1> [CMake] Call Stack (most recent call first):
1> [CMake]   /home/dnkpp/.vs/cpm_test/952dbcb6-53c6-4ed1-b2ba-4d91dcbd3971/out/build/Linux-Clang-Debug/_deps/gtest-src/googletest/CMakeLists.txt:102 (configure_package_config_file)
1> [CMake] -- Configuring incomplete, errors occurred!

This is just the output from my minimal example. If you want to have a look at my actual project output, here is the relevant gh-action run: https://github.com/DNKpp/mimicpp/actions/runs/10965745313 This happens to be the case for all linux based machines, I've tested it (also some local docker containers).

I'll attach the minimal example: cpm_test.zip

Avus-c commented 1 month ago

This is a bug in CMake which was resolved in version 3.30.3: CMake Issue 26243. The bug also affects older versions of CMake.

For context: CMake 3.30 deprecates a function signature that CPM versions earlier than 0.40.1 used to add packages. This was addressed in CPM 0.40.1 to align with CMake's new expectations. See pr #570 for more details.

When I implemented the fixes in #570, I aimed to use the "new method" with the earliest CMake version that supported it, which was 3.28. However, now that I’m aware of the bug in these versions, I think it would be the best to update the version checks from 3.28 to 3.30, where the deprecation warnings actually begin. Although CMake versions 3.30.0 - 3.30.2 still contain the bug, it's easier to upgrade from 3.30.0 to 3.30.3 than from 3.28 to 3.30.3.

PS: Windows should also be effected. The log from your action looked weird: CPM: Adding package GTest@0 (1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2). Haven't looked further, maybe it's expected :)

DNKpp commented 1 month ago

Thank you for your explanation, but unfortunantly I have still no idea how that can be the root cause for the non-existing input template. But either way. If it's the reason, I'm fine with the fix :) Thank you!

Windows should also be effected. The log from your action looked weird: CPM: Adding package GTest@0 (1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2). Haven't looked further, maybe it's expected :)

Well, I don't think so. In that runner I've selected an actual git commit hash. Seems fine too me. But as I use gtest just for the dedicated adapter test, I use the very minimal of it. For my actual unit-test I'm using catch2.