From 7596790a3fb4a32bfe16e63684d8eadc1207b98e Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 28 Jan 2025 11:09:47 -0400 Subject: [PATCH] Offer GoogleTest and GoogleBenchmark to downstream components Signed-off-by: Juan Cruz Viotti --- CMakeLists.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97c154757..3435aacb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ option(SOURCEMETA_CORE_DOCS "Build the Sourcemeta Core docs" OFF) option(SOURCEMETA_CORE_INSTALL "Install the Sourcemeta Core library" ON) option(SOURCEMETA_CORE_ADDRESS_SANITIZER "Build Sourcemeta Core with an address sanitizer" OFF) option(SOURCEMETA_CORE_UNDEFINED_SANITIZER "Build Sourcemeta Core with an undefined behavior sanitizer" OFF) +option(SOURCEMETA_CORE_CONTRIB_GOOGLETEST "Build the GoogleTest library for downstream consumers" OFF) +option(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK "Build the GoogleBenchmark library for downstream consumers" OFF) include(Sourcemeta) @@ -94,9 +96,17 @@ if(PROJECT_IS_TOP_LEVEL) endif() # Testing + +if(SOURCEMETA_CORE_CONTRIB_GOOGLETEST OR SOURCEMETA_CORE_TESTS) + find_package(GoogleTest REQUIRED) +endif() + +if(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK OR SOURCEMETA_CORE_BENCHMARK) + find_package(GoogleBenchmark REQUIRED) +endif() + if(SOURCEMETA_CORE_TESTS) enable_testing() - find_package(GoogleTest REQUIRED) if(SOURCEMETA_CORE_REGEX) add_subdirectory(test/regex) @@ -137,9 +147,8 @@ if(SOURCEMETA_CORE_TESTS) add_subdirectory(test/packaging) endif() endif() +endif() - if(SOURCEMETA_CORE_BENCHMARK) - find_package(GoogleBenchmark REQUIRED) - add_subdirectory(benchmark) - endif() +if(SOURCEMETA_CORE_BENCHMARK) + add_subdirectory(benchmark) endif()