Subject: Re: [bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`.

From: Greg Hogan <[email-masked]>
Date: Tue, 8 Oct 2024 13:19:57 -0400

I think we can do this without warnings in the output logs or
modifications to the project CMakeLists.txt. We can preload
BUILD_TESTING into the cache:

$ cat cache.txt
set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
$ cmake --build build -C cache.txt .

It's not a "manually-specified variable" so no warning and can be
overwritten by a configure flag ("-DBUILD_TESTING=...") or from
CMakeLists.txt (as patched by the rosegarden package).

I have added a commit titled "build-system/cmake: Optionally build
tests." to my branch at
https://github.com/greghogan/guix/commits/master-cmake/ as part of a
v2 for #70031.

After resolving this feature we should look to create a branch on the
build service as with #73135.

[1] https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-C
[2] https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry
[3] https://cmake.org/cmake/help/book/mastering-cmake/chapter/CMake%20Cache.html