@@ -43,9 +43,70 @@ SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${CYRUS_SASL_DIR};${GSASL_DIR};$ENV{
4343# Specify PROTOBUF_HOME so that find_package picks up the correct version
4444SET (CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH} ;$ENV{PROTOBUF_HOME} " )
4545
46+ if (BUILD_SHARED_LIBS AND MSVC )
47+ # On MSVC Abseil is bundled into a single DLL.
48+ # This condition is necessary as of abseil 20230125.3 when abseil is consumed via add_subdirectory,
49+ # the abseil_dll target is named abseil_dll, while if abseil is consumed via find_package, the target
50+ # is called absl::abseil_dll
51+ # Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released in the minimum version of
52+ # abseil required by protobuf, it is possible to always link absl::abseil_dll and absl::abseil_test_dll
53+ # and remove the if
54+ if (protobuf_ABSL_PROVIDER STREQUAL "package" )
55+ set (protobuf_ABSL_USED_TARGETS absl::abseil_dll)
56+ set (protobuf_ABSL_USED_TEST_TARGETS absl::abseil_test_dll)
57+ else ()
58+ set (protobuf_ABSL_USED_TARGETS abseil_dll)
59+ set (protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll)
60+ endif ()
61+ else ()
62+ set (protobuf_ABSL_USED_TARGETS
63+ absl::absl_check
64+ absl::absl_log
65+ absl::algorithm
66+ absl::base
67+ absl::bind_front
68+ absl::bits
69+ absl::btree
70+ absl::cleanup
71+ absl::cord
72+ absl::core_headers
73+ absl::debugging
74+ absl::die_if_null
75+ absl::dynamic_annotations
76+ absl::flags
77+ absl::flat_hash_map
78+ absl::flat_hash_set
79+ absl::function_ref
80+ absl::hash
81+ absl::layout
82+ absl::log_initialize
83+ absl::log_severity
84+ absl::memory
85+ absl::node_hash_map
86+ absl::node_hash_set
87+ absl::optional
88+ absl::span
89+ absl::status
90+ absl::statusor
91+ absl::strings
92+ absl::synchronization
93+ absl::time
94+ absl::type_traits
95+ absl::utility
96+ absl::variant
97+ utf8_range::utf8_validity
98+ utf8_range::utf8_range
99+ )
100+ set (protobuf_ABSL_USED_TEST_TARGETS
101+ absl::scoped_mock_log
102+ )
103+ endif ()
104+
46105find_package (Doxygen)
47106find_package (OpenSSL REQUIRED)
48107find_package (Protobuf REQUIRED)
108+ find_package (absl REQUIRED)
109+ find_package (utf8_range REQUIRED)
49110find_package (CyrusSASL)
50111find_package (GSasl)
51112find_package (Threads)
@@ -89,7 +150,10 @@ endif (NOT THREAD_LOCAL_SUPPORTED)
89150# to compile some dummy code
90151unset (PROTOC_IS_COMPATIBLE CACHE )
91152set (CMAKE_REQUIRED_INCLUDES ${PROTOBUF_INCLUDE_DIRS} )
92- set (CMAKE_REQUIRED_LIBRARIES ${PROTOBUF_LIBRARY} ${PROTOBUF_PROTOC_LIBRARY} )
153+ set (CMAKE_REQUIRED_LIBRARIES
154+ ${PROTOBUF_LIBRARY}
155+ ${PROTOBUF_PROTOC_LIBRARY}
156+ ${protobuf_ABSL_USED_TARGETS} )
93157check_cxx_source_compiles(
94158 "#include <google/protobuf/io/printer.h>
95159 #include <string>
@@ -280,6 +344,7 @@ if (HADOOP_BUILD AND NOT MSVC)
280344 hadoop_target_link_dual_libraries(hdfspp
281345 ${LIB_DL}
282346 ${PROTOBUF_LIBRARY}
347+ ${protobuf_ABSL_USED_TARGETS}
283348 ${OPENSSL_LIBRARIES}
284349 ${SASL_LIBRARIES}
285350 ${CMAKE_THREAD_LIBS_INIT}
@@ -291,6 +356,7 @@ else (HADOOP_BUILD AND NOT MSVC)
291356 target_link_libraries (hdfspp_static PUBLIC
292357 ${LIB_DL}
293358 ${PROTOBUF_LIBRARY}
359+ ${protobuf_ABSL_USED_TARGETS}
294360 ${OPENSSL_LIBRARIES}
295361 ${SASL_LIBRARIES}
296362 ${CMAKE_THREAD_LIBS_INIT}
0 commit comments