# Setup our dependency on Abseil.
if ( protobuf_BUILD_TESTS )
# Tell Abseil to build test-only helpers.
set ( ABSL_BUILD_TEST_HELPERS ON )
# We depend on googletest too, so just tell Abseil to use the same one we've
# already setup.
set ( ABSL_USE_EXTERNAL_GOOGLETEST ON )
set ( ABSL_FIND_GOOGLETEST OFF )
endif ( )
if ( TARGET absl::strings )
# If Abseil is included already, skip including it.
# (https://github.com/protocolbuffers/protobuf/issues/10435)
elseif ( protobuf_ABSL_PROVIDER STREQUAL "module" )
if ( NOT ABSL_ROOT_DIR )
set ( ABSL_ROOT_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /third_party/abseil-cpp )
endif ( )
if ( EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt" )
if ( protobuf_INSTALL )
# When protobuf_INSTALL is enabled and Abseil will be built as a module,
# Abseil will be installed along with protobuf for convenience.
set ( ABSL_ENABLE_INSTALL ON )
endif ( )
add_subdirectory ( ${ ABSL_ROOT_DIR } third_party/abseil-cpp )
else ( )
message ( WARNING "protobuf_ABSL_PROVIDER is \" module\ " but ABSL_ROOT_DIR is wrong" )
endif ( )
if ( protobuf_INSTALL AND NOT _protobuf_INSTALL_SUPPORTED_FROM_MODULE )
message ( WARNING "protobuf_INSTALL will be forced to FALSE because protobuf_ABSL_PROVIDER is \" module\ " and CMake version (${CMAKE_VERSION}) is less than 3.13." )
set ( protobuf_INSTALL FALSE )
endif ( )
elseif ( protobuf_ABSL_PROVIDER STREQUAL "package" )
# Use "CONFIG" as there is no built-in cmake module for absl.
find_package ( absl REQUIRED CONFIG )
endif ( )
set ( _protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()" )
if ( BUILD_SHARED_LIBS AND MSVC )
# On MSVC Abseil is bundled into a single DLL.
# This condition is necessary as of abseil 20230125.3 when abseil is consumed
# via add_subdirectory, the abseil_dll target is named abseil_dll, while if
# abseil is consumed via find_package, the target is called absl::abseil_dll
# Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released
# in the minimum version of abseil required by protobuf, it is possible to
# always link absl::abseil_dll and absl::abseil_test_dll and remove the if
if ( protobuf_ABSL_PROVIDER STREQUAL "package" )
set ( protobuf_ABSL_USED_TARGETS absl::abseil_dll )
set ( protobuf_ABSL_USED_TEST_TARGETS absl::abseil_test_dll )
else ( )
set ( protobuf_ABSL_USED_TARGETS abseil_dll )
set ( protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll )
endif ( )
else ( )
set ( protobuf_ABSL_USED_TARGETS
a b s l : : a b s l _ c h e c k
a b s l : : a b s l _ l o g
a b s l : : a l g o r i t h m
a b s l : : b a s e
a b s l : : b i n d _ f r o n t
a b s l : : b i t s
a b s l : : b t r e e
a b s l : : c l e a n u p
a b s l : : c o r d
a b s l : : c o r e _ h e a d e r s
a b s l : : d e b u g g i n g
a b s l : : d i e _ i f _ n u l l
a b s l : : d y n a m i c _ a n n o t a t i o n s
a b s l : : f l a g s
a b s l : : f l a t _ h a s h _ m a p
a b s l : : f l a t _ h a s h _ s e t
a b s l : : f u n c t i o n _ r e f
a b s l : : h a s h
a b s l : : i f _ c o n s t e x p r
a b s l : : l a y o u t
a b s l : : l o g _ i n i t i a l i z e
a b s l : : l o g _ g l o b a l s
a b s l : : l o g _ s e v e r i t y
a b s l : : m e m o r y
a b s l : : n o d e _ h a s h _ m a p
a b s l : : n o d e _ h a s h _ s e t
a b s l : : o p t i o n a l
a b s l : : s p a n
a b s l : : s t a t u s
a b s l : : s t a t u s o r
a b s l : : s t r i n g s
a b s l : : s y n c h r o n i z a t i o n
a b s l : : t i m e
a b s l : : t y p e _ t r a i t s
a b s l : : u t i l i t y
a b s l : : v a r i a n t
)
set ( protobuf_ABSL_USED_TEST_TARGETS
a b s l : : s c o p e d _ m o c k _ l o g
)
endif ( )