blob: 24d13f59917f15e165ac655f6d29097b76c84dcc [file] [log] [blame]
Mike Kruskalcac97652022-08-12 16:41:00 -07001# Setup our dependency on Abseil.
2
3set(ABSL_PROPAGATE_CXX_STD ON)
4
5if(protobuf_ABSL_PROVIDER STREQUAL "module")
6 if(NOT ABSL_ROOT_DIR)
7 set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp)
8 endif()
9 if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt")
10 if(protobuf_INSTALL)
11 # When protobuf_INSTALL is enabled and Abseil will be built as a module,
12 # Abseil will be installed along with protobuf for convenience.
13 set(ABSL_ENABLE_INSTALL ON)
14 endif()
15 add_subdirectory(${ABSL_ROOT_DIR} third_party/abseil-cpp)
16 else()
17 message(WARNING "protobuf_ABSL_PROVIDER is \"module\" but ABSL_ROOT_DIR is wrong")
18 endif()
19 if(protobuf_INSTALL AND NOT _protobuf_INSTALL_SUPPORTED_FROM_MODULE)
20 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.")
21 set(protobuf_INSTALL FALSE)
22 endif()
23elseif(protobuf_ABSL_PROVIDER STREQUAL "package")
24 # Use "CONFIG" as there is no built-in cmake module for absl.
25 find_package(absl REQUIRED CONFIG)
26endif()
27set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()")
28
29set(protobuf_ABSL_USED_TARGETS
30 absl::strings
31 absl::strings_internal
32)