Skip to content

Commit

Permalink
Identify the basic issues with ExtProject_Target
Browse files Browse the repository at this point in the history
Three remaining issues surfaced with the RPATH setting - two minor, one
trickier.

Minor #1 - Itcl and Itk didn't have the RPATH flag set in their target
definitions (fixed).

Minor #2 - 3rd party binaries RPATHs don't match those produced by the
main CMake build - using bin instead of lib (investigating).

More significant is the behavior of CMake's RPATH_CHANGE - it is
correctly setting the final path, but it is not clearing the build dir
path.  So far I've not found a way to make the available commands in
CMake do the job, so I'm falling back on a solution similar to that
necessary on Apple and using the chrpath utility.  The code in this
commit works if a system chrpath is present - we'll need to bundle a
version in misc/tools to make sure we have the capabilities we need
reliably.  (chrpath is GPL, so we can't install it or use it as anything
except a build tool - unfortunately I've not found a BSD/MIT licensed
tool for this type of rpath work...)
  • Loading branch information
starseeker committed Mar 22, 2021
1 parent ba45fa6 commit e35529c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/other/ext/CMake/ExternalProject_Target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ endfunction(ET_Origin_Path)
# /usr/bin/baz -> bin/baz
# /usr/bin/mypkg/baz -> bin/mypkg/baz
#
find_program(CHRPATH_EXEC chrpath)
function(ET_RPath OFILE)
get_filename_component(OFPATH "${OFILE}" DIRECTORY)
get_filename_component(RRPATH "${CMAKE_INSTALL_PREFIX}/${OFPATH}" REALPATH)
Expand All @@ -272,7 +273,16 @@ function(ET_RPath OFILE)
execute_process(COMMAND install_name_tool -delete_rpath \"${CMAKE_BUILD_RPATH}\" \"\${WPATH}\")
execute_process(COMMAND install_name_tool -add_rpath \"${NEW_RPATH}\" \"\${WPATH}\")
")
else (APPLE)
elseif (CHRPATH_EXEC)
# Looks like CMake's built in RPATH logic isn't quite enough for our
# purposes here - it leaves the build RPATH in place even after assigning
# the new path.
# TODO Need to bundle chrpath so we can reliably do this...
install(CODE "
set(WPATH \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\")
execute_process(COMMAND chrpath -r \"${NEW_RPATH}\" \"\${WPATH}\")
")
else ()
install(CODE "
file(RPATH_CHANGE
FILE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\"
Expand Down
1 change: 1 addition & 0 deletions src/other/ext/itcl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ if (BRLCAD_ENABLE_TCL)
ExternalProject_Target(SHARED itcl ITCL_BLD ${ITCL_INSTDIR}
itcl${ITCL_VERSION}/${ITCL_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
SUBDIR itcl${ITCL_VERSION}
RPATH
)

ExternalProject_Target(STATIC itclstub ITCL_BLD ${ITCL_INSTDIR}
Expand Down
1 change: 1 addition & 0 deletions src/other/ext/itk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ if (BRLCAD_ENABLE_TK)
ExternalProject_Target(SHARED itk ITK_BLD ${ITK_INSTDIR}
itk${ITK_VERSION}/${ITK_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
SUBDIR itk${ITK_VERSION}
RPATH
)

ExternalProject_ByProducts(itk ITK_BLD ${ITK_INSTDIR} ${INCLUDE_DIR}
Expand Down

0 comments on commit e35529c

Please sign in to comment.