From b3816f67b92b3031353ccb008340edd6a76f14b4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 22 Oct 2024 13:22:39 +0200 Subject: [PATCH] cmake: avoid setting `BUILD_TESTING` `BUILD_TESTING` variable is used by other projects and CMake internally. Replace `cmake_dependent_option()` with `option()` and introduce an internal variable to track if want and can do testing. Follow-up to #6036 Follow-up to 3a1e798009799be1e9fad30666351b66f250befb #6072 Reported-by: Robert Maynard Fixes #15351 Closes #15355 --- CMakeLists.txt | 11 +++++++---- lib/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e03b6e9f8c..ffde386ebe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1858,9 +1858,12 @@ set(_generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(_project_config "${_generated_dir}/${PROJECT_NAME}Config.cmake") set(_version_config "${_generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") -cmake_dependent_option(BUILD_TESTING "Build tests" - ON "PERL_FOUND;NOT CURL_DISABLE_TESTS" - OFF) +option(BUILD_TESTING "Build tests" ON) +if(BUILD_TESTING AND PERL_FOUND AND NOT CURL_DISABLE_TESTS) + set(CURL_BUILD_TESTING ON) +else() + set(CURL_BUILD_TESTING OFF) +endif() if(HAVE_MANUAL_TOOLS) set(CURL_MANPAGE "${PROJECT_BINARY_DIR}/docs/cmdline-opts/curl.1") @@ -1879,7 +1882,7 @@ if(BUILD_EXAMPLES) add_subdirectory(docs/examples) endif() -if(BUILD_TESTING) +if(CURL_BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index dfda7f9051..895bc9165a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -46,7 +46,7 @@ if(USE_ARES) include_directories(SYSTEM ${CARES_INCLUDE_DIRS}) endif() -if(BUILD_TESTING) +if(CURL_BUILD_TESTING) add_library( curlu # special libcurlu library just for unittests STATIC -- 2.47.3