From be3c15dca4fdf1fbd671b5c0fb59e6f9d0fd28d5 Mon Sep 17 00:00:00 2001 From: Gigon Bae Date: Wed, 31 Jul 2024 18:47:41 -0700 Subject: [PATCH] Fix abseil.cmake for building from source code Signed-off-by: Gigon Bae --- cpp/cmake/deps/abseil.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpp/cmake/deps/abseil.cmake b/cpp/cmake/deps/abseil.cmake index 98476217..0e3d5b9e 100644 --- a/cpp/cmake/deps/abseil.cmake +++ b/cpp/cmake/deps/abseil.cmake @@ -44,6 +44,16 @@ if (NOT TARGET deps::abseil) message(STATUS "Fetching abseil sources - done") endif () + # Create static library + cucim_set_build_shared_libs(OFF) + set(BUILD_TESTING FALSE) # Disable BUILD_TESTING (cmake-build-debug/_deps/deps-abseil-src/CMakeLists.txt:97) + add_subdirectory(${deps-abseil_SOURCE_DIR} ${deps-abseil_BINARY_DIR} EXCLUDE_FROM_ALL) + + # Set PIC to prevent the following error message + # : /usr/bin/ld: ../lib/libabsl_strings.a(escaping.cc.o): relocation R_X86_64_PC32 against symbol `_ZN4absl14lts_2020_02_2516numbers_internal8kHexCharE' can not be used when making a shared object; recompile with -fPIC + set_target_properties(absl_strings absl_strings_internal absl_int128 absl_raw_logging_internal PROPERTIES POSITION_INDEPENDENT_CODE ON) + cucim_restore_build_shared_libs() + add_library(deps::abseil INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::abseil INTERFACE absl::strings) set(abseil_INCLUDE_DIR ${deps-deps-abseil_SOURCE_DIR} CACHE INTERNAL "" FORCE)