pybind11_abseil
pybind11_abseil copied to clipboard
status target conflict with abseil-cpp ones
If a super build project use set(ABSL_ENABLE_INSTALL ON) or modify the pybind11_abseil CMakelists.txt as fallow
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ceb65a8..4f4ed9c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,11 @@ endif()
FetchContent_Declare(
abseil-cpp
URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.tar.gz
URL_HASH
SHA256=59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5)
+ #GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
+ #GIT_TAG "20230802.1"
+)
+set(ABSL_ENABLE_INSTALL ON)
FetchContent_Declare(
pybind11
note: same behaviour with the last abseil-cpp release
we got:
$ cmake -S. -Bbuild
-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- pybind11 v2.12.0 dev1
-- Found Python: /usr/bin/python3.11 (found suitable version "3.11.6", minimum required is "3.6") found components: Interpreter Development.Module Development.Embed
CMake Error at pybind11_abseil/CMakeLists.txt:153 (add_library):
add_library cannot create target "status" because another target with the
same name already exists. The existing target is a static library created
in source directory
"/usr/local/google/home/corentinl/work/pybind11_abseil/build/_deps/abseil-cpp-src/absl/status".
See documentation for policy CMP0002 for more details.
CMake Error at pybind11_abseil/CMakeLists.txt:160 (target_link_libraries):
Attempt to add link library "status_pyinit_google3" to target "status"
which is not built in this directory.
This is allowed only when policy CMP0079 is set to NEW.
-- Configuring incomplete, errors occurred!
The code: https://github.com/pybind/pybind11_abseil/blob/52f27398876a3177049977249e004770bd869e61/pybind11_abseil/CMakeLists.txt#L151-L170
The problem is that cmake TARGET names are not scoped thus the name clash, on my way to provide a patch in google/or-tools then a PR here... would go for
# change logical target name
add_library(status_py_extension_stub SHARED status_py_extension_stub.cc)
# but keep the previous base name, "status" for the output file...
set_target_properties(status_py_extension_stub PROPERTIES LIBRARY_OUTPUT_NAME "status")
# we can keep the ALIAS unchanged to pybind11_abseil::status
add_library(pybind11_abseil::status ALIAS status_py_extension_stub)