[CMake] Does INSTALL_RPATH work on OS X?

Matthew LeRoy MLeRoy at minitab.com
Fri Jan 25 14:29:48 EST 2013


Hi,

I'm trying to convince CMake to do my bidding with regard to setting the RPATH
on one of my executables, and it doesn't seem to be working as I think it should
be (according to my understanding of the documentation).

I'm running CMake 2.8.10.2 on OS X 10.8.2, and using the Xcode generator.
What I'm trying to accomplish is to set the RPATH of my executable to a custom
value, say "../foo/bar/", and I understand that INSTALL_RPATH is the correct
property to set. I also want this RPATH set immediately after building in the build
tree, not just after installation, so I gather that I need to set
BUILD_WITH_INSTALL_RPATH to true. So, I've tried something like this:

  add_executable(fizzbang ${HEADERS} ${SOURCES})
  set_target_properties(fizzbang PROPERTIES
    INSTALL_RPATH "../foo/bar/"
    BUILD_WITH_INSTALL_RPATH ON)

However, this doesn't seem to be having any effect; my executable does not have
my custom RPATH set after building. Looking at the properties of the generated
Xcode project and at the link line that Xcode executes for my executable, my custom
RPATH value doesn't appear anywhere.

The same exact CMake code yields the expected results on Linux using the Makefile
generator.

So, I'm wondering… does CMake's RPATH support (CMAKE_INSTALL_RPATH,
CMAKE_BUILD_WITH_INSTALL_RPATH, etc., and the associated target-specific
variants without the CMAKE_ prefix) work on OS X at all?

Thanks!
Matt


More information about the CMake mailing list