Packaging SlicerVMTK extension with custom Slicer build

I’m back at this after having to set it aside for some other work. I’m still trying to get SlicerVMTK to work from within a custom application that I started using cookiecutter. Thank you for your previous help.

I made the changes to External_VMTK.cmake described in the previous comment, and I can build and package the application, but I still can’t access the VMTK classes from the Python interpreter. When I try to import one of the VMTK libraries, I get the error:

Python 2.7.13 (default, Oct 24 2018, 15:58:48)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on Darwin
>>> import vtkvmtkMiscPython
Traceback (most recent call last):
File “<console>”, line 1, in <module>
ImportError: dlopen(/Applications/PADPlanner.app/Contents/lib/PADPlanner-4.9/qt-loadable-modules/Python/vtkvmtkMiscPython.so, 2): Library not loaded: libvtkvmtkMiscPythonD.dylib
Referenced from: /Applications/PADPlanner.app/Contents/lib/PADPlanner-4.9/qt-loadable-modules/Python/vtkvmtkMiscPython.so
Reason: image not found

So the vtkvmtkMiscPython.so file can’t find libvtkvmtkMiscPythonD.dylib. Just as a test, I copied the .dylib files to the same file as the .so file, and restarted the app, but that didn’t change anything.

What am I missing to link these libraries?

My External_VMTK.cmake file with changes is here:
https://github.com/mschumak/SlicerExtension-VMTK/blob/Oct24-refixing/SuperBuild/External_VMTK.cmake#L20-L41

The section of the CMakeLists.txt file for my custom application that deals with extensions is:

# Enable/Disable Slicer custom modules: To create a new module, use the SlicerExtensionWizard.
set(Slicer_EXTENSION_SOURCE_DIRS
/Users/michaelschumaker/Development/mschumaker/Slicelets/PADFusion/PADFusion
)
# Add remote extension source directories
#SlicerVMTK
set(extension_name “SlicerVMTK”)
set(${extension_name}_SOURCE_DIR “${CMAKE_BINARY_DIR}/${extension_name}”)

FetchContent_Populate(${extension_name}
SOURCE_DIR ${${extension_name}_SOURCE_DIR}
GIT_REPOSITORY ${EP_GIT_PROTOCOL}://github.com/mschumak/SlicerExtension-VMTK.git
GIT_TAG a847b808cd772ea77992b64a6fb3bdf9388d2171
GIT_PROGRESS 1
)
list(APPEND Slicer_EXTENSION_SOURCE_DIRS ${${extension_name}_SOURCE_DIR})

# Add Slicer sources
add_subdirectory(${slicersources_SOURCE_DIR} ${slicersources_BINARY_DIR})

Thank you for your help!

@jcfr, any thoughts?
Thanks!