Skip to content

Commit

Permalink
Prefer system Abseil if available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
carlocab committed May 31, 2024
1 parent e8a40b5 commit 05e1bfd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -295,7 +304,12 @@ if(UNIX OR MINGW)
endif()
endif()

add_subdirectory(third_party/abseil-cpp)
if(NOT absl_FOUND)
set(BLOATY_BUILD_TESTING_SAVE "${BUILD_TESTING}")
set(BUILD_TESTING OFF)
add_subdirectory(third_party/abseil-cpp)
set(BUILD_TESTING "${BLOATY_BUILD_TESTING_SAVE}")
endif()
list(APPEND LIBBLOATY_LIBS absl::strings)
list(APPEND LIBBLOATY_LIBS absl::optional)
list(APPEND LIBBLOATY_LIBS Threads::Threads)
Expand Down

0 comments on commit 05e1bfd

Please sign in to comment.