cmake: Fix pybind11_protobuf patch

* get rid of ${Python_LIBRARIES} (ed unavailable on manylinux)
note: module shouldn't link against libpython.so but only depends on python.h
since it will be dynamic loaded in the python process which already have
the python symbols loaded...
This commit is contained in:
Corentin Le Molgat
2023-07-24 15:52:24 +02:00
parent 49aceccc93
commit afcffe1bef

View File

@@ -1,8 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e936f66..5461aaf 100644
index e936f66..eaac571 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,7 +57,7 @@ target_include_directories(
@@ -21,7 +21,7 @@ option(BUILD_TESTS "Build tests." OFF)
# ============================================================================
# Find Python
-find_package(Python COMPONENTS Interpreter Development)
+find_package(Python3 COMPONENTS Interpreter Development.Module)
# ============================================================================
# Build dependencies
@@ -47,8 +47,10 @@ pybind11_add_module(
pybind11_protobuf/proto_utils.h)
target_link_libraries(
- pybind11_proto_utils PRIVATE absl::strings protobuf::libprotobuf
- ${Python_LIBRARIES})
+ pybind11_proto_utils PRIVATE
+ absl::strings
+ protobuf::libprotobuf
+ Python3::Module)
target_include_directories(
pybind11_proto_utils PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS}
@@ -57,7 +59,7 @@ target_include_directories(
# ============================================================================
# pybind11_native_proto_caster shared library
add_library(
@@ -11,7 +33,12 @@ index e936f66..5461aaf 100644
# bazel: pybind_library: native_proto_caster
pybind11_protobuf/native_proto_caster.h
# bazel: pybind_library: enum_type_caster
@@ -83,6 +83,8 @@ target_link_libraries(
@@ -79,10 +81,12 @@ target_link_libraries(
absl::optional
protobuf::libprotobuf
pybind11::pybind11
- ${Python_LIBRARIES})
+ Python3::Module)
target_include_directories(
pybind11_native_proto_caster
@@ -20,6 +47,15 @@ index e936f66..5461aaf 100644
PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS} ${protobuf_SOURCE_DIR}
${pybind11_INCLUDE_DIRS})
@@ -109,7 +113,7 @@ target_link_libraries(
absl::optional
protobuf::libprotobuf
pybind11::pybind11
- ${Python_LIBRARIES})
+ Python3::Module)
target_include_directories(
pybind11_wrapped_proto_caster
diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc
index 06bde44..1cc6a30 100644
--- a/pybind11_protobuf/proto_cast_util.cc