[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:
From: |
Greg Hogan |
Subject: |
[bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`. |
Date: |
Wed, 9 Oct 2024 11:04:58 -0400 |
On Wed, Oct 9, 2024 at 3:32 AM Hartmut Goebel
<h.goebel@crazy-compilers.com> wrote:
>
> Am 08.10.24 um 19:19 schrieb Greg Hogan:
>
> 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.")
>
> This is a neat trick!
>
> Did you check whether this also overwrites any default in CMakeList.txt?
> Otherwise we might need to pass `-DBUILD_TESTING=…` on the command line, too.
As I understand it, setting a variable in a "-C" cache file and with a
"-D" command-line argument is equivalent. The only difference is the
requisite precedence, and since we are not specifying "FORCE" for the
"-C" cache file entries any "-D" configure-flags from a Guix package
take precedence.
I also noticed the following in my simple test project, so I am
looking to also move these "-D" arguments into the "-C" cache file in
cmake-build's configure.
--8<---------------cut here---------------start------------->8---
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_INSTALL_LIBDIR
--8<---------------cut here---------------end--------------->8---
This persistent cache is the lowest-level scope [1] so is overwritten
by a "set" command in any CMakeLists.txt. An "option" (for example
BUILD_TESTING in the CTest module) does not affect a normal or cache
variable [2].
[1]
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#cmake-language-variables
[2] https://cmake.org/cmake/help/latest/command/option.html