Merge bitcoin-core/secp256k1#1687: cmake: support the use of launchers in ctest -S scripts

0dfe387dbe cmake: support the use of launchers in ctest -S scripts (Daniel Pfeifer)

Pull request description:

  When `CTEST_USE_LAUNCHERS` is set to `ON` in a `ctest -S` script, the configure step fails with the error message:

  ```
  CMake Error:
    CTEST_USE_LAUNCHERS is enabled, but the RULE_LAUNCH_COMPILE global property
    is not defined.

    Did you forget to include(CTest) in the toplevel CMakeLists.txt ?
  ```

  However, `include(CTest)` produces unwanted clutter. `include(CTestUseLaunchers)` is a more lightweight alternative.

  To reproduce the issue, run the following script with and without the PR applied.

  ```cmake
  #!/usr/bin/env -S ctest -VV -S

  set(CTEST_SOURCE_DIRECTORY "/path/to/secp256k1")
  set(CTEST_BINARY_DIRECTORY "/path/to/secp256k1-build")

  set(CTEST_CMAKE_GENERATOR "Ninja")
  set(CTEST_USE_LAUNCHERS ON)

  ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
  ctest_start("Experimental")
  ctest_configure()
  ctest_build()
  ```

ACKs for top commit:
  hebasto:
    ACK 0dfe387dbe.

Tree-SHA512: 643d0fabd19ddfd5a64a0b34cfcca8ea2cff64438ee3441ba9a1745618daf99c468ec201ea6992c542d4e33152f4833691c42c8a90301fe3dfc3f0f49f755e55
This commit is contained in:
merge-script
2025-07-01 09:00:26 +02:00

View File

@@ -13,6 +13,7 @@ project(libsecp256k1
LANGUAGES C
)
enable_testing()
include(CTestUseLaunchers) # Allow users to set CTEST_USE_LAUNCHERS in custom `ctest -S` scripts.
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# The library version is based on libtool versioning of the ABI. The set of