Hide the use of FetchContent behind a flag

FetchContent is now disabled by default, when the project is included as
an subproject by another top-level project.
Also, every usage of FetchContent is behind a separate flag to enable and
disable the usage with granular control.
This commit is contained in:
2024-11-18 17:22:03 +01:00
parent ca9ef16d0d
commit c3eb5e6a62
9 changed files with 100 additions and 63 deletions

View File

@@ -2,12 +2,22 @@ include(GoogleTest)
set(DRAMSYS_TEST_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.12.1)
option(DRAMSYS_USE_FETCH_CONTENT_GTEST "Enable FetchContent to provide gtest" ${DRAMSYS_USE_FETCH_CONTENT})
FetchContent_MakeAvailable(googletest)
if (DRAMSYS_USE_FETCH_CONTENT)
if (DRAMSYS_USE_FETCH_CONTENT_GTEST)
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.12.1
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(GTest)
endif()
endif()
find_package(GTest REQUIRED)
add_subdirectory(tests_configuration)
add_subdirectory(tests_dramsys)