Mike Kruskal | cac9765 | 2022-08-12 16:41:00 -0700 | [diff] [blame] | 1 | # Setup our dependency on Abseil. |
| 2 | |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 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 | |
Christian Blichmann | 6affd51 | 2022-08-22 22:51:28 +0200 | [diff] [blame] | 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") |
Mike Kruskal | cac9765 | 2022-08-12 16:41:00 -0700 | [diff] [blame] | 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 | |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 40 | if (BUILD_SHARED_LIBS AND MSVC) |
| 41 | # On MSVC Abseil is bundled into a single DLL. |
Protobuf Team Bot | f5a2255 | 2024-02-05 16:44:49 -0800 | [diff] [blame] | 42 | # This condition is necessary as of abseil 20230125.3 when abseil is consumed |
| 43 | # via add_subdirectory, the abseil_dll target is named abseil_dll, while if |
| 44 | # abseil is consumed via find_package, the target is called absl::abseil_dll |
| 45 | # Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released |
| 46 | # in the minimum version of abseil required by protobuf, it is possible to |
| 47 | # always link absl::abseil_dll and absl::abseil_test_dll and remove the if |
Silvio Traversaro | 87b3bc7 | 2023-06-05 15:01:50 -0700 | [diff] [blame] | 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() |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 55 | else() |
| 56 | set(protobuf_ABSL_USED_TARGETS |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 57 | absl::absl_check |
| 58 | absl::absl_log |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 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 |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 68 | absl::die_if_null |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 69 | absl::dynamic_annotations |
| 70 | absl::flags |
| 71 | absl::flat_hash_map |
| 72 | absl::flat_hash_set |
| 73 | absl::function_ref |
| 74 | absl::hash |
Protobuf Team Bot | 578e07e | 2023-11-27 11:26:16 -0800 | [diff] [blame] | 75 | absl::if_constexpr |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 76 | absl::layout |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 77 | absl::log_initialize |
Protobuf Team Bot | f5a2255 | 2024-02-05 16:44:49 -0800 | [diff] [blame] | 78 | absl::log_globals |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 79 | absl::log_severity |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 80 | absl::memory |
| 81 | absl::node_hash_map |
| 82 | absl::node_hash_set |
| 83 | absl::optional |
Mike Kruskal | b6032d7 | 2024-03-12 12:37:29 -0700 | [diff] [blame] | 84 | absl::random_distributions |
| 85 | absl::random_random |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 86 | absl::span |
| 87 | absl::status |
| 88 | absl::statusor |
| 89 | absl::strings |
| 90 | absl::synchronization |
| 91 | absl::time |
Mike Kruskal | 1aef0a4 | 2023-01-03 15:51:30 -0800 | [diff] [blame] | 92 | absl::type_traits |
Mike Kruskal | 983fc2d | 2022-11-02 23:24:26 -0700 | [diff] [blame] | 93 | absl::utility |
| 94 | absl::variant |
| 95 | ) |
Mike Kruskal | a9f1ea6 | 2023-01-24 21:49:33 -0800 | [diff] [blame] | 96 | set(protobuf_ABSL_USED_TEST_TARGETS |
| 97 | absl::scoped_mock_log |
| 98 | ) |
Mike Kruskal | 7930cd1 | 2023-01-20 21:38:59 -0800 | [diff] [blame] | 99 | endif () |