Skip to content

Commit

Permalink
Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac
Browse files Browse the repository at this point in the history
On Mac, the libvtkWrapping-8.1.1 library fails to link to libpython when
configuring with VTK_WRAP_PYTHON and VTK_ENABLE_KITS enabled.

This fixes the following error:

FAILED: lib/libvtkWrapping-8.1.1.dylib
Undefined symbols for architecture x86_64:
  "_PyCallable_Check", referenced from:
      vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
  "_PyErr_Clear", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PyErr_Fetch", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PyImport_ImportModule", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PyInt_AsLong", referenced from:
      vtkPythonAlgorithm::CheckResult(char const*, vtkSmartPyObject const&) in vtkPythonAlgorithm.cxx.o
  "_PyInt_FromLong", referenced from:
      vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
  "_PyObject_Call", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
  "_PyObject_GetAttrString", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
  "_PyObject_Str", referenced from:
      vtkPythonAlgorithm::PrintSelf(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, vtkIndent) in vtkPythonAlgorithm.cxx.o
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PySequence_Fast", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PySequence_Size", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PyString_AsString", referenced from:
      vtkPythonAlgorithm::PrintSelf(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, vtkIndent) in vtkPythonAlgorithm.cxx.o
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
  "_PyTuple_New", referenced from:
      GetPythonErrorString() in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::SetPythonObject(_object*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillInputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
      vtkPythonAlgorithm::FillOutputPortInformation(int, vtkInformation*) in vtkPythonAlgorithm.cxx.o
  • Loading branch information
msmolens committed Jul 25, 2017
1 parent 87f014b commit 8a60be1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMake/vtkModuleTop.cmake
Expand Up @@ -353,13 +353,19 @@ macro(_vtk_build_module _module)
add_subdirectory("${${_module}_SOURCE_DIR}" "${${_module}_BINARY_DIR}")
endmacro()

include(vtkTargetLinkLibrariesWithDynamicLookup)

# Build all modules.
foreach(kit IN LISTS vtk_modules_and_kits)
if(_${kit}_is_kit)
set(_vtk_build_as_kit ${kit})
set(kit_srcs)
set(_optional_python_link)
foreach(kit_module IN LISTS _${kit}_modules)
list(APPEND kit_srcs $<TARGET_OBJECTS:${kit_module}Objects>)
if(${kit_module}_OPTIONAL_PYTHON_LINK)
set(_optional_python_link 1)
endif()
endforeach()

configure_file("${_VTKModuleMacros_DIR}/vtkKit.cxx.in"
Expand Down Expand Up @@ -398,6 +404,10 @@ foreach(kit IN LISTS vtk_modules_and_kits)
target_link_libraries(${kit}
LINK_PRIVATE ${kit_priv}
LINK_PUBLIC ${kit_pub})
if(_optional_python_link)
vtk_module_load(vtkPython)
vtk_target_link_libraries_with_dynamic_lookup(${kit} LINK_PUBLIC ${vtkPython_LIBRARIES})
endif()
vtk_target(${kit})
else()
if(VTK_ENABLE_KITS)
Expand Down

0 comments on commit 8a60be1

Please sign in to comment.