Skip to content

Commit 724b49f

Browse files
Fix pybind add module segv on macos.
1 parent fd199b1 commit 724b49f

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

CMake/SofaPython3Tools.cmake

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -114,44 +114,9 @@ function(SP3_add_python_module)
114114

115115
find_package(pybind11 CONFIG QUIET REQUIRED)
116116

117-
# We are doing manually what's usually done with pybind11_add_module(${A_TARGET} SHARED "${A_SOURCES}")
118-
# since we got some problems on MacOS using recent versions of pybind11 where the SHARED argument wasn't taken
119-
# into account
120-
python_add_library(${A_TARGET} SHARED "${A_SOURCES}")
117+
pybind11_add_module(${A_TARGET} SHARED "${A_SOURCES}")
121118
add_library(SofaPython3::${A_TARGET} ALIAS ${A_TARGET})
122119

123-
if ("${pybind11_VERSION}" VERSION_GREATER_EQUAL "2.6.0")
124-
target_link_libraries(${A_TARGET} PRIVATE pybind11::headers)
125-
target_link_libraries(${A_TARGET} PRIVATE pybind11::embed)
126-
target_link_libraries(${A_TARGET} PRIVATE pybind11::lto)
127-
if(MSVC)
128-
target_link_libraries(${A_TARGET} PRIVATE pybind11::windows_extras)
129-
endif()
130-
131-
pybind11_extension(${A_TARGET})
132-
pybind11_strip(${A_TARGET})
133-
else()
134-
target_link_libraries(${A_TARGET} PRIVATE pybind11::module)
135-
136-
# Equivalent to pybind11_extension(${A_TARGET}) which doesn't exists on pybind11 versions < 5
137-
set_target_properties(${A_TARGET} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}")
138-
139-
if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
140-
# Equivalent to pybind11_strip(${A_TARGET}) which doesn't exists on pybind11 versions < 5
141-
# Strip unnecessary sections of the binary on Linux/macOS
142-
if(CMAKE_STRIP)
143-
if(APPLE)
144-
set(x_opt -x)
145-
endif()
146-
147-
add_custom_command(
148-
TARGET ${A_TARGET}
149-
POST_BUILD
150-
COMMAND ${CMAKE_STRIP} ${x_opt} $<TARGET_FILE:${A_TARGET}>)
151-
endif()
152-
endif()
153-
endif()
154-
155120
set_target_properties(${A_TARGET}
156121
PROPERTIES
157122
CXX_VISIBILITY_PRESET "hidden"

0 commit comments

Comments
 (0)