[CMake] CMake Error: RPATH CHANGE
Jim Leek
leek2 at llnl.gov
Tue Sep 10 17:16:38 EDT 2013
> Having said that, if cmake knows that the executable is static, it shouldn't
> try to change the RPATH.
> Is the RPATH in the uninstalled executable empty ?
Yes, the RPATH in the static build is empty. There's isn't a dynamic
section at all, so there is no RPATH in the file.
That said, this issue was my fault, at least sort of. I had a section
in my CMakeLists.txt file to force some RPATH stuff. (See below.
Without it I had some sort of issue with using the program from the
build tree.) I just needed to bracket that in an if(BUILD_SHARED)
statement, so I wouldn't be forcing RPATH behavior on a static build.
# use, i.e. don't skip the full RPATH for the build tree
if(BUILD_SHARED)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system
directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
endif(BUILD_SHARED)
More information about the CMake
mailing list