diff --git a/CMakeLists.txt b/CMakeLists.txt index 38d31d8..c6dde34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +IF (DEFINED PROJECT_NAME) + SET(SCALR_SUBPROJECT ON) +ENDIF() + FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/scalr/version.hpp" version) STRING(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${version}) @@ -44,7 +48,7 @@ SET_TARGET_PROPERTIES( INSTALL(DIRECTORY include/scalr TYPE INCLUDE) # Testing -IF(BUILD_TESTING) +IF(BUILD_TESTING AND NOT SCALR_SUBPROJECT) ENABLE_TESTING() ADD_SUBDIRECTORY(tests) ENDIF() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 900b678..cd71aca 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,14 @@ -find_package(Catch2 3 REQUIRED) +find_package(Catch2 3 QUIET) + +if (NOT Catch2_FOUND) + include(FetchContent) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.3.2) + FetchContent_MakeAvailable(Catch2) +endif() + include(Catch) add_executable(