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

From: Hartmut Goebel <[email-masked]>
Date: Tue, 8 Oct 2024 11:06:34 +0200

Am 07.10.24 um 17:45 schrieb Greg Hogan:
> Could we detect with `cmake -L` [1] that the package has a
> BUILD_TESTING option and only then pass this flag?

Running `cmake -L` would run the configure phase. Thus we would need to 
configure twice: first to learn whether BUILD_TESTING is defined and 
then a second time to change it. We might be able to optimize this: if 
BUILD_TESTING is already set to the value we want, we can skip the 
second run. While we can hope that the second run will be cheap, if 
might not if things change depending on the values.

IMHO this is too much effort just to suppress a warning.

Anyhow, there is a much simpler solution, according to 
<https://stackoverflow.com/questions/36451368/> we could just add a line 
to the CMakeList.txt file.

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(lalala)
set(__guix_suppress_BUILD_TESTING_warning__ "${BUILD_TESTING}")
$ cmake -DBUILD_TESTING=OFF .
…
-- Generating done (0.0s)
-- Build files have been written to: /tmp/xxx

Voila, no warning.

WDYT?

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          [email-masked]                |
|www.crazy-compilers.com  | compilers which you thought are impossible |