Skip configuration of tests unless `BUILD_TESTING` is set

See https://github.com/Martchus/tagparser/issues/26
and https://cmake.org/cmake/help/latest/module/CTest.html
This commit is contained in:
Martchus 2023-09-16 15:56:29 +02:00
parent c71f835ad0
commit 938da48da0
2 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,9 @@ if (TEST_CONFIG_DONE)
endif ()
include(TestUtilities)
if(NOT BUILD_TESTING)
return()
endif()
# find and link against CppUnit if required (used by all my projects, so it is required by default)
if (NOT META_NO_CPP_UNIT)

View File

@ -6,6 +6,9 @@ if (DEFINED TESTING_UTILITIES_LOADED)
endif ()
set(TESTING_UTILITIES_LOADED YES)
# ensure CTest is loaded (e.g. for BUILD_TESTING variable)
include(CTest)
set(EXCLUDE_TEST_TARGET_BY_DEFAULT ON)
if (ENABLE_DEVEL_DEFAULTS)
set(EXCLUDE_TEST_TARGET_BY_DEFAULT OFF)