]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: avoid setting `BUILD_TESTING`
authorViktor Szakats <commit@vsz.me>
Tue, 22 Oct 2024 11:22:39 +0000 (13:22 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 23 Oct 2024 19:24:02 +0000 (21:24 +0200)
`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
lib/CMakeLists.txt

index e03b6e9f8c0a6c66cb3c493ac7fc18a1cfd8b830..ffde386ebeed24f8d06243e648036de23342887d 100644 (file)
@@ -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()
 
index dfda7f9051c580d81d9909d7a314369ef7d03c22..895bc9165abca786fa3c4d66a0e528470a9ee787 100644 (file)
@@ -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