diff --git a/CMake/vtkMacroKitPythonWrap.cmake b/CMake/vtkMacroKitPythonWrap.cmake index 3d03454..6f48852 100644 --- a/CMake/vtkMacroKitPythonWrap.cmake +++ b/CMake/vtkMacroKitPythonWrap.cmake @@ -159,6 +159,7 @@ macro(vtkMacroKitPythonWrap) endif() if(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS) + set(VTK_WRAP_PYTHON_FIND_LIBS 1) include(vtkWrapPython) set(TMP_WRAP_FILES ${MY_KIT_SRCS} ${MY_KIT_WRAP_HEADERS}) @@ -280,6 +281,7 @@ macro(vtkMacroKitPythonWrap) ${MY_KIT_NAME}PythonD ${MY_KIT_NAME} ${VTK_PYTHON_CORE} + ${VTK_Python3_LIBRARIES} ${VTK_KIT_PYTHON_LIBRARIES} ${MY_KIT_PYTHON_LIBRARIES} ) @@ -340,6 +342,7 @@ macro(vtkMacroKitPythonWrap) target_link_libraries(${MY_KIT_NAME}Python PRIVATE ${MY_KIT_NAME} + ${VTK_Python3_LIBRARIES} VTK::WrappingPythonCore VTK::Python ) diff --git a/CMake/vtkWrapPython.cmake b/CMake/vtkWrapPython.cmake index 76f48da..c1c8f0c 100644 --- a/CMake/vtkWrapPython.cmake +++ b/CMake/vtkWrapPython.cmake @@ -233,7 +233,18 @@ $<$>: endmacro() if(VTK_WRAP_PYTHON_FIND_LIBS) - find_package(Python3 COMPONENTS Development.Module REQUIRED) + # Development.Module leaves the Python C-API symbols undefined for the host + # interpreter to provide. That is fine where the linker allows undefined + # symbols (macOS -undefined dynamic_lookup), but on Linux the wrapped modules + # link with -Wl,--no-undefined and must resolve the Python symbols at link + # time, so the full library (Python3::Python) is required there. + if(VTK_UNDEFINED_SYMBOLS_ALLOWED) + find_package(Python3 COMPONENTS Development.Module REQUIRED) + set(VTK_Python3_LIBRARIES "") + else() + find_package(Python3 COMPONENTS Development REQUIRED) + set(VTK_Python3_LIBRARIES Python3::Python) + endif() endif() # Determine the location of the supplied header in the include_dirs supplied.