Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer using system Abseil if available #347

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 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 @@ -244,26 +253,6 @@ add_library(libbloaty STATIC
src/util.cc
src/util.h
src/webassembly.cc
# Until Abseil has a proper CMake build system
third_party/abseil-cpp/absl/base/internal/raw_logging.cc # Grrrr...
third_party/abseil-cpp/absl/base/internal/throw_delegate.cc
third_party/abseil-cpp/absl/debugging/internal/demangle.cc
third_party/abseil-cpp/absl/numeric/int128.cc
third_party/abseil-cpp/absl/strings/ascii.cc
third_party/abseil-cpp/absl/strings/charconv.cc
third_party/abseil-cpp/absl/strings/escaping.cc
third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc
third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc
third_party/abseil-cpp/absl/strings/internal/escaping.cc
third_party/abseil-cpp/absl/strings/internal/memutil.cc
third_party/abseil-cpp/absl/strings/internal/utf8.cc
third_party/abseil-cpp/absl/strings/match.cc
third_party/abseil-cpp/absl/strings/numbers.cc
third_party/abseil-cpp/absl/strings/str_cat.cc
third_party/abseil-cpp/absl/strings/string_view.cc
third_party/abseil-cpp/absl/strings/str_split.cc
third_party/abseil-cpp/absl/strings/substitute.cc
third_party/abseil-cpp/absl/types/bad_optional_access.cc
# One source file, no special build system needed.
third_party/demumble/third_party/libcxxabi/cxa_demangle.cpp
)
Expand Down Expand Up @@ -315,6 +304,14 @@ if(UNIX OR MINGW)
endif()
endif()

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)

if(DEFINED ENV{LIB_FUZZING_ENGINE})
Expand Down