-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use namespaced absl::abseil_dll imported target instead of abseil_dll…
… to correctly propagate CMake usage requirements defined in abseil build on Windows (#162) automerged PR by conda-forge/automerge-action
- Loading branch information
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
project(cf_dummy LANGUAGES C CXX) | ||
cmake_minimum_required(VERSION 3.12) | ||
# CMake seems to prefer its own FindProtobuf to the | ||
# protobuf-config.cmake being distributed by this | ||
# feedstock; make sure things work | ||
find_package(Protobuf REQUIRED) | ||
# We need to specify CONFIG to make sure that CMake | ||
# uses protobuf-config.cmake instead of relying on its | ||
# own FindProtobuf.cmake that does not know about | ||
# abseil transitive depedendency and about C++ version | ||
# required, see https://github.com/conda-forge/conda-forge-pinning-feedstock/issues/4075#issuecomment-1569242816 | ||
find_package(Protobuf CONFIG REQUIRED) | ||
|
||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/struct_example.cc | ||
" | ||
#include <iostream> | ||
#include <google/protobuf/struct.pb.h> | ||
int main() | ||
{ | ||
google::protobuf::Struct myStruct; | ||
} | ||
" | ||
) | ||
|
||
add_executable(struct_example ${CMAKE_CURRENT_BINARY_DIR}/struct_example.cc) | ||
target_link_libraries(struct_example PRIVATE protobuf::libprotobuf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
recipe/patches/0007-use-namespaced-abseil-dll-imported-target-backport-12978.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake | ||
index e7bfb2b15f8..c668f4d9b01 100644 | ||
--- a/cmake/abseil-cpp.cmake | ||
+++ b/cmake/abseil-cpp.cmake | ||
@@ -39,8 +39,19 @@ set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFI | ||
|
||
if (BUILD_SHARED_LIBS AND MSVC) | ||
# On MSVC Abseil is bundled into a single DLL. | ||
- set(protobuf_ABSL_USED_TARGETS abseil_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) | ||
+ else() | ||
+ set(protobuf_ABSL_USED_TARGETS abseil_dll) | ||
+ endif() | ||
+ # Not all build of abseil found by find_package provide the absl::abseil_test_dll target, so for | ||
+ # it we stick to the non-namespaced definition | ||
set(protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll) | ||
else() | ||
set(protobuf_ABSL_USED_TARGETS |