From f3c6d2440280303f847fe336d1cd3ac990080964 Mon Sep 17 00:00:00 2001 From: David Sisson Date: Mon, 10 Jul 2023 10:57:20 -0700 Subject: [PATCH] Only load absl from third party if we do not use the bundled version from protobuf. --- CMakeLists.txt | 8 +++++--- third_party/CMakeLists.txt | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f07d574b..a3085102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,10 +23,12 @@ include_directories(src) add_subdirectory(third_party) # Due to packaging changes we use the combined protobuf/absl packaging if -# available otherwise we fallback to the older protobuf method. -# TODO: Simplify once we can require cmake 3.27 (where CONFIG is default). +# available otherwise we fallback to the older protobuf method. TODO: Simplify +# once we can require cmake 3.27 (where CONFIG is default). find_package(Protobuf QUIET CONFIG) -if(NOT ${Protobuf_FOUND}) +if(${Protobuf_FOUND}) + set(PROTOBUF_LOADED_AS_CONFIG) +else() find_package(Protobuf REQUIRED) include_directories(${Protobuf_INCLUDE_DIRS}) endif() diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 6ace2da8..f1b01cc0 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -1,7 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 -set(ABSL_PROPAGATE_CXX_STD ON) -add_subdirectory(abseil-cpp) +if(NOT ${PROTOBUF_LOADED_AS_CONFIG}) + set(ABSL_PROPAGATE_CXX_STD ON) + add_subdirectory(abseil-cpp) +endif() set(BUILD_TZ_LIB ON) add_subdirectory(datetime)