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 3a1e798009 #6072

Reported-by: Robert Maynard
Fixes #15351
Closes #15355
This commit is contained in:
Viktor Szakats 2024-10-22 13:22:39 +02:00
parent 7c023c3f6e
commit b3816f67b9
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
2 changed files with 8 additions and 5 deletions

View 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()

View 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