From 51205fd9b1bc409fa2fec15edb807cc172626e0c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sun, 2 Jul 2023 21:51:44 +0800 Subject: [PATCH] Prefer system Abseil if available Newer versions of Protobuf (22+) pull in Abseil as a dependency. We want to avoid using our bundled copy for these cases, as this will likely conflict with the version of Abseil that Protobuf uses. The simplest way to do this seems to be to just prefer a system installation of Abseil if it's available. Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13ae120..cd2ce5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,13 @@ else() endif() endif() +find_package(absl CONFIG) +if(absl_FOUND) + MESSAGE(STATUS "System absl found, using") +else() + MESSAGE(STATUS "System absl not found, using bundled version") +endif() + # Set default build type. if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") @@ -157,7 +164,9 @@ endif() include_directories(.) include_directories(src) -include_directories(third_party/abseil-cpp) +if(NOT absl_FOUND) + include_directories(third_party/abseil-cpp) +endif() include_directories("${CMAKE_CURRENT_BINARY_DIR}/src") # Baseline build flags. @@ -295,7 +304,9 @@ if(UNIX OR MINGW) endif() endif() -add_subdirectory(third_party/abseil-cpp) +if(NOT absl_FOUND) + add_subdirectory(third_party/abseil-cpp) +endif() list(APPEND LIBBLOATY_LIBS absl::strings) list(APPEND LIBBLOATY_LIBS absl::optional) list(APPEND LIBBLOATY_LIBS Threads::Threads)