Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 2eef344

Browse files
authored
CMake: don't pull in benchmark dep if BUILD_TESTING=OFF. (#318)
Also display status as deps are being processed.
1 parent 3aa11f2 commit 2eef344

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

cmake/OpenCensusDeps.cmake

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ fetchcontent_declare(benchmark
3838
fetchcontent_getproperties(googletest)
3939
if(BUILD_TESTING)
4040
message(STATUS "Dependency: googletest (BUILD_TESTING=${BUILD_TESTING})")
41-
4241
if(NOT googletest_POPULATED)
4342
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
4443
# All the libraries in the build must use either /MD or /MT (runtime
@@ -61,12 +60,14 @@ endif()
6160

6261
fetchcontent_getproperties(abseil)
6362
if(NOT abseil_POPULATED)
63+
message(STATUS "Dependency: abseil")
6464
fetchcontent_populate(abseil)
6565
add_subdirectory(${abseil_SOURCE_DIR} ${abseil_BINARY_DIR} EXCLUDE_FROM_ALL)
6666
endif()
6767

6868
fetchcontent_getproperties(prometheus)
6969
if(NOT prometheus_POPULATED)
70+
message(STATUS "Dependency: prometheus")
7071
set(ENABLE_PUSH OFF CACHE BOOL "Build prometheus-cpp push library" FORCE)
7172
set(ENABLE_PULL OFF CACHE BOOL "Build prometheus-cpp pull library" FORCE)
7273
set(ENABLE_COMPRESSION OFF
@@ -79,14 +80,17 @@ if(NOT prometheus_POPULATED)
7980
endif()
8081

8182
fetchcontent_getproperties(benchmark)
82-
if(NOT benchmark_POPULATED)
83-
set(BENCHMARK_ENABLE_TESTING OFF
84-
CACHE BOOL "Enable testing of the benchmark library."
85-
FORCE)
86-
set(BENCHMARK_ENABLE_GTEST_TESTS OFF
87-
CACHE BOOL "Enable building the unit tests which depend on gtest"
88-
FORCE)
89-
fetchcontent_populate(benchmark)
90-
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}
91-
EXCLUDE_FROM_ALL)
83+
if(BUILD_TESTING)
84+
message(STATUS "Dependency: benchmark (BUILD_TESTING=${BUILD_TESTING})")
85+
if(NOT benchmark_POPULATED)
86+
set(BENCHMARK_ENABLE_TESTING OFF
87+
CACHE BOOL "Enable testing of the benchmark library."
88+
FORCE)
89+
set(BENCHMARK_ENABLE_GTEST_TESTS OFF
90+
CACHE BOOL "Enable building the unit tests which depend on gtest"
91+
FORCE)
92+
fetchcontent_populate(benchmark)
93+
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}
94+
EXCLUDE_FROM_ALL)
95+
endif()
9296
endif()

0 commit comments

Comments
 (0)