Skip to content

Commit ed738f3

Browse files
committed
cmake: cleanup
* make re2 mandatory * rework check_deps and system_deps
1 parent 79cf92b commit ed738f3

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,18 @@ message(STATUS "Build abseil-cpp: ${BUILD_absl}")
8585
option(BUILD_Protobuf "Build the Protobuf dependency Library" ON)
8686
message(STATUS "Build protobuf: ${BUILD_Protobuf}")
8787

88-
if(BUILD_TESTING)
89-
option(BUILD_re2 "Build the re2 dependency Library" ON)
90-
message(STATUS "Build re2: ${BUILD_re2}")
88+
option(BUILD_re2 "Build the re2 dependency Library" ON)
89+
message(STATUS "Build re2: ${BUILD_re2}")
9190

91+
if(BUILD_TESTING)
9292
option(BUILD_googletest "Build googletest" ON)
93-
message(STATUS "Build googletest: ${BUILD_googletest}")
94-
9593
option(BUILD_benchmark "Build benchmark" ON)
96-
message(STATUS "Build benchmark: ${BUILD_benchmark}")
9794
else()
98-
set(BUILD_re2 OFF)
9995
set(BUILD_googletest OFF)
10096
set(BUILD_benchmark OFF)
10197
endif()
98+
message(STATUS "Build googletest: ${BUILD_googletest}")
99+
message(STATUS "Build benchmark: ${BUILD_benchmark}")
102100

103101
# Find system deps
104102
include(system_deps)

cmake/check_deps.cmake

+7-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ if(NOT TARGET protobuf::libprotobuf)
4545
message(FATAL_ERROR "Target protobuf::libprotobuf not available.")
4646
endif()
4747

48+
if(NOT TARGET re2::re2)
49+
message(FATAL_ERROR "Target re2::re2 not available.")
50+
endif()
51+
4852
# CXX Test
4953
if(BUILD_TESTING)
50-
if(NOT TARGET re2::re2)
51-
message(FATAL_ERROR "Target re2::re2 not available.")
52-
endif()
53-
5454
if(NOT TARGET GTest::gtest_main)
5555
message(FATAL_ERROR "Target GTest::gtest_main not available.")
5656
endif()
57+
if(NOT TARGET benchmark::benchmark)
58+
message(FATAL_ERROR "Target benchmark::benchmark not available.")
59+
endif()
5760
endif()

cmake/system_deps.cmake

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,29 @@ find_package(Threads REQUIRED)
99
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
1010

1111
# libprotobuf force us to depends on ZLIB::ZLIB target
12-
if(NOT BUILD_ZLIB)
12+
if(NOT BUILD_ZLIB AND NOT TARGET ZLIB::ZLIB)
1313
find_package(ZLIB REQUIRED)
1414
endif()
1515

16-
if(NOT BUILD_absl)
16+
if(NOT BUILD_absl AND NOT TARGET absl::base)
1717
find_package(absl REQUIRED)
1818
endif()
1919

20-
if(NOT BUILD_Protobuf)
20+
if(NOT BUILD_Protobuf AND NOT TARGET protobuf::libprotobuf)
2121
find_package(Protobuf REQUIRED)
2222
endif()
2323

24+
if(NOT BUILD_re2 AND NOT TARGET re2::re2)
25+
find_package(re2 REQUIRED)
26+
endif()
27+
2428
# CXX Test
2529
if(BUILD_TESTING)
26-
if(NOT BUILD_re2)
27-
find_package(re2 REQUIRED)
30+
if(NOT BUILD_googletest AND NOT TARGET GTest::gtest_main)
31+
find_package(GTest REQUIRED)
2832
endif()
2933

30-
if(NOT BUILD_googletest)
31-
find_package(GTest REQUIRED)
34+
if(NOT BUILD_benchmark AND NOT TARGET benchmark::benchmark)
35+
find_package(benchmark REQUIRED)
3236
endif()
3337
endif()

0 commit comments

Comments
 (0)