Debian Codegraph @

extra/protobuf/protobuf-24.4/cmake/abseil-cpp.cmake

raw
1 # Setup our dependency on Abseil.
2
3 if(protobuf_BUILD_TESTS)
4 # Tell Abseil to build test-only helpers.
5 set(ABSL_BUILD_TEST_HELPERS ON)
6
7 # We depend on googletest too, so just tell Abseil to use the same one we've
8 # already setup.
9 set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
10 set(ABSL_FIND_GOOGLETEST OFF)
11 endif()
12
13 if(TARGET absl::strings)
14 # If Abseil is included already, skip including it.
15 # (https://github.com/protocolbuffers/protobuf/issues/10435)
16 elseif(protobuf_ABSL_PROVIDER STREQUAL "module")
17 if(NOT ABSL_ROOT_DIR)
18 set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp)
19 endif()
20 if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt")
21 if(protobuf_INSTALL)
22 # When protobuf_INSTALL is enabled and Abseil will be built as a module,
23 # Abseil will be installed along with protobuf for convenience.
24 set(ABSL_ENABLE_INSTALL ON)
25 endif()
26 add_subdirectory(${ABSL_ROOT_DIR} third_party/abseil-cpp)
27 else()
28 message(WARNING "protobuf_ABSL_PROVIDER is \"module\" but ABSL_ROOT_DIR is wrong")
29 endif()
30 if(protobuf_INSTALL AND NOT _protobuf_INSTALL_SUPPORTED_FROM_MODULE)
31 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.")
32 set(protobuf_INSTALL FALSE)
33 endif()
34 elseif(protobuf_ABSL_PROVIDER STREQUAL "package")
35 # Use "CONFIG" as there is no built-in cmake module for absl.
36 find_package(absl REQUIRED CONFIG)
37 endif()
38 set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()")
39
40 if (BUILD_SHARED_LIBS AND MSVC)
41 # On MSVC Abseil is bundled into a single DLL.
42 # This condition is necessary as of abseil 20230125.3 when abseil is consumed via add_subdirectory,
43 # the abseil_dll target is named abseil_dll, while if abseil is consumed via find_package, the target
44 # is called absl::abseil_dll
45 # Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released in the minimum version of
46 # abseil required by protobuf, it is possible to always link absl::abseil_dll and absl::abseil_test_dll
47 # and remove the if
48 if(protobuf_ABSL_PROVIDER STREQUAL "package")
49 set(protobuf_ABSL_USED_TARGETS absl::abseil_dll)
50 set(protobuf_ABSL_USED_TEST_TARGETS absl::abseil_test_dll)
51 else()
52 set(protobuf_ABSL_USED_TARGETS abseil_dll)
53 set(protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll)
54 endif()
55 else()
56 set(protobuf_ABSL_USED_TARGETS
57 absl::absl_check
58 absl::absl_log
59 absl::algorithm
60 absl::base
61 absl::bind_front
62 absl::bits
63 absl::btree
64 absl::cleanup
65 absl::cord
66 absl::core_headers
67 absl::debugging
68 absl::die_if_null
69 absl::dynamic_annotations
70 absl::flags
71 absl::flat_hash_map
72 absl::flat_hash_set
73 absl::function_ref
74 absl::hash
75 absl::layout
76 absl::log_initialize
77 absl::log_severity
78 absl::memory
79 absl::node_hash_map
80 absl::node_hash_set
81 absl::optional
82 absl::span
83 absl::status
84 absl::statusor
85 absl::strings
86 absl::synchronization
87 absl::time
88 absl::type_traits
89 absl::utility
90 absl::variant
91 )
92 set(protobuf_ABSL_USED_TEST_TARGETS
93 absl::scoped_mock_log
94 )
95 endif ()