Skip to content

Commit 94c8a9c

Browse files
Fix sofapython3 tests linking w/ python.
1 parent 3df3db1 commit 94c8a9c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Plugin/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "-DSOFA_BUILD_SOFAPYTHON3")
3636

3737
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Graph)
3838

39+
# The public linking with pybind lead to have a link with libpython which
40+
# propagates in the python module .so. On macOS, this extra link with libpython
41+
# lead to segv when importing the python module in versions of python that don't
42+
# have a dynamic link with libpython (such as the one provided by conda), but works
43+
# fine with versions that have such link.
3944
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
4045
target_link_libraries(${PROJECT_NAME} PRIVATE pybind11::embed)
4146
else()

Testing/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ set(SOURCE_FILES
1616

1717
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
1818
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Testing SofaPython3::Plugin)
19+
# We wan't the pybind11 dependency to propagate to SofaPython3Testing consumers,
20+
# here Bindings.*.Tests
21+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
22+
target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::embed)
23+
endif()
1924
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DSOFA_BUILD_SOFAPYTHON3")
2025
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Testing)
2126

0 commit comments

Comments
 (0)