Skip to content

Commit

Permalink
COMP: Ensure full path ID for macOS libraries installed for fix-up
Browse files Browse the repository at this point in the history
This commit resolves an issue in Slicer's fix-up process, specifically when
updating the installed executable and plugins using `@rpath`. To align with
this process, both the installed libraries and their dependent libraries must
have a full path. Consequently, we consistently clear `CMAKE_INSTALL_NAME_TOOL`
in all external projects. This adjustment is crucial due to the lack of an
explicit option in CMake to skip the "install_name_tool" call unless the variable
is cleared. Please refer to `cmInstallTargetGenerator::AddInstallNamePatchRule`
C++ function found in the CMake source code for a comprehensive understanding.

For historical context, the forceful setting of `CMAKE_INSTALL_NAME_TOOL` to an
empty value was originally introduced in commit 4c441a2 ("COMP: Fix MacOSX
packaging fixup associated with loadable module", 2012-10-25). Subsequently, the
comment "XXX Probably not needed anymore" was added in commit d276165 ("BUG:
Extension packaging: Ensure @rpath is not applied at build time", 2016-06-10) and
is now removed, as forcing the value is indispensable to support packaging of
external projects like VTK modules built externally.
  • Loading branch information
jcfr committed Jan 12, 2024
1 parent d8c2d88 commit 52b238d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions CMake/SlicerCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ else()
#------------------------------------------------------------------------------
# macOS specific configuration used by the "fix-up" script
#------------------------------------------------------------------------------
set(CMAKE_INSTALL_NAME_TOOL "" CACHE FILEPATH "" FORCE)

if(Slicer_USE_PYTHONQT)
include(${Slicer_CMAKE_DIR}/SlicerBlockInstallExternalPythonModules.cmake)
endif()
Expand Down
5 changes: 4 additions & 1 deletion CMake/UseSlicer.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ endif()
set(Slicer_BUNDLE_EXTENSIONS_LOCATION "")
if(APPLE)
set(Slicer_BUNDLE_EXTENSIONS_LOCATION "${Slicer_EXTENSIONS_DIRBASENAME}-${Slicer_REVISION}/${EXTENSION_NAME}/")
set(CMAKE_INSTALL_NAME_TOOL "" CACHE FILEPATH "" FORCE) # XXX Probably not needed anymore

set(CMAKE_INSTALL_NAME_TOOL "" CACHE FILEPATH "" FORCE)
mark_as_superbuild(VARS CMAKE_INSTALL_NAME_TOOL:FILEPATH ALL_PROJECTS)

set(CMAKE_MACOSX_RPATH 0 CACHE BOOL "" FORCE)
mark_as_superbuild(VARS CMAKE_MACOSX_RPATH:BOOL ALL_PROJECTS)
endif()
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ if(APPLE)
ALL_PROJECTS
)

set(CMAKE_INSTALL_NAME_TOOL "" CACHE FILEPATH "" FORCE)
mark_as_superbuild(VARS CMAKE_INSTALL_NAME_TOOL:FILEPATH ALL_PROJECTS)

set(CMAKE_MACOSX_RPATH 0)
mark_as_superbuild(VARS CMAKE_MACOSX_RPATH:BOOL ALL_PROJECTS)
endif()
Expand Down

0 comments on commit 52b238d

Please sign in to comment.