I've attached a sample project which includes 2 external projects, where the executable links with the library from its build tree. After it is built, you can run it from the build tree ./app-prefix/src/app-build/app
Clint ----- Original Message ----- > When using @rpath, the proper way to the executable to find it at runtime is > for the executable to have an rpath with a directory that contains the > dylib. > When compiling the executable, the linker flag "-rpath /path/to/dylib" should > be given. This should be automatic with CMake when building the executable, > and if it isn't doing that for you, please give us an example. > To verify, the executable has the rpath, you can run "otool -l <executable> | > grep LC_RPATH -A2" > Clint > ----- Original Message ----- > > So I noticed the CMAKE_MACOSX_RPATH variable, and tried setting it, which > > does result in the install name of the dylib being set to > > @rpath/dylibname.so BUT when I link it in an executable tool -L just shows > > the dylib as @rpath/dylibname.so and the linker fails to find it at run > > time. What is the proper way to get CMake to build the executable linking > > against the dylib and be able to run it in the build tree and install tree? > > > Izaak Beekman > > > =================================== > > > (301)244-9367 > > > UMD-CP Visiting Graduate Student > > > Aerospace Engineering > > > ibeek...@umiacs.umd.edu > > > ibeek...@umd.edu > > > On Sat, May 3, 2014 at 10:54 AM, Dan Kegel < d...@kegel.com > wrote: > > > > On Sat, May 3, 2014 at 7:17 AM, < clin...@elemtech.com > wrote: > > > > > > > Use at least CMake 2.8.12 and in your library project add this: > > > > > > > set(CMAKE_MACOSX_RPATH 1) > > > > > > > ... > > > > > > > For more details: > > > > > > > http://www.kitware.com/blog/home/post/510 > > > > > > What he said. See also past discussion at > > > > > > http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP > > > > > > I put together some tiny demos showing various ways to do it, with > > > > > > walkthroughs, at > > > > > > http://kegel.com/macosx/rpath/ > > > > -- > Powered by www.kitware.com > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake
test-rpath.tar.gz
Description: application/compressed-tar
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake