Skip to content

Commit e35529c

Browse files
committed
Identify the basic issues with ExtProject_Target
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...)
1 parent ba45fa6 commit e35529c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/other/ext/CMake/ExternalProject_Target.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ endfunction(ET_Origin_Path)
249249
# /usr/bin/baz -> bin/baz
250250
# /usr/bin/mypkg/baz -> bin/mypkg/baz
251251
#
252+
find_program(CHRPATH_EXEC chrpath)
252253
function(ET_RPath OFILE)
253254
get_filename_component(OFPATH "${OFILE}" DIRECTORY)
254255
get_filename_component(RRPATH "${CMAKE_INSTALL_PREFIX}/${OFPATH}" REALPATH)
@@ -272,7 +273,16 @@ function(ET_RPath OFILE)
272273
execute_process(COMMAND install_name_tool -delete_rpath \"${CMAKE_BUILD_RPATH}\" \"\${WPATH}\")
273274
execute_process(COMMAND install_name_tool -add_rpath \"${NEW_RPATH}\" \"\${WPATH}\")
274275
")
275-
else (APPLE)
276+
elseif (CHRPATH_EXEC)
277+
# Looks like CMake's built in RPATH logic isn't quite enough for our
278+
# purposes here - it leaves the build RPATH in place even after assigning
279+
# the new path.
280+
# TODO Need to bundle chrpath so we can reliably do this...
281+
install(CODE "
282+
set(WPATH \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\")
283+
execute_process(COMMAND chrpath -r \"${NEW_RPATH}\" \"\${WPATH}\")
284+
")
285+
else ()
276286
install(CODE "
277287
file(RPATH_CHANGE
278288
FILE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\"

src/other/ext/itcl.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ if (BRLCAD_ENABLE_TCL)
134134
ExternalProject_Target(SHARED itcl ITCL_BLD ${ITCL_INSTDIR}
135135
itcl${ITCL_VERSION}/${ITCL_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
136136
SUBDIR itcl${ITCL_VERSION}
137+
RPATH
137138
)
138139

139140
ExternalProject_Target(STATIC itclstub ITCL_BLD ${ITCL_INSTDIR}

src/other/ext/itk.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ if (BRLCAD_ENABLE_TK)
107107
ExternalProject_Target(SHARED itk ITK_BLD ${ITK_INSTDIR}
108108
itk${ITK_VERSION}/${ITK_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
109109
SUBDIR itk${ITK_VERSION}
110+
RPATH
110111
)
111112

112113
ExternalProject_ByProducts(itk ITK_BLD ${ITK_INSTDIR} ${INCLUDE_DIR}

0 commit comments

Comments
 (0)