<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>I've attached a sample project which includes 2 external projects, where the executable links with the library from its build tree.<br></div><div>After it is built, you can run it from the build tree <span style="font-family: Menlo; font-size: 11px;">./app-prefix/src/app-build/app</span></div><div><br></div><div>Clint</div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>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.</div><div><br></div><div>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.</div><div>To verify, the executable has the rpath, you can run "otool -l <executable> | grep LC_RPATH -A2"</div><div><br></div><div><span style="font-size: 12pt;">Clint</span></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr">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?</div><div class="gmail_extra"><br clear="all"><div>Izaak Beekman<br>===================================<br>(301)244-9367<br>UMD-CP Visiting Graduate Student<br>Aerospace Engineering<br><a href="mailto:ibeekman@umiacs.umd.edu" target="_blank">ibeekman@umiacs.umd.edu</a><br> <a href="mailto:ibeekman@umd.edu" target="_blank">ibeekman@umd.edu</a></div><br><div><br></div><div class="gmail_quote">On Sat, May 3, 2014 at 10:54 AM, Dan Kegel <span dir="ltr"><<a href="mailto:dank@kegel.com" target="_blank">dank@kegel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Sat, May 3, 2014 at 7:17 AM, <<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>> wrote:<br> > Use at least CMake 2.8.12 and in your library project add this:<br> > set(CMAKE_MACOSX_RPATH 1)<br></div>> ...<br><div class="">> For more details:<br> > <a href="http://www.kitware.com/blog/home/post/510" target="_blank">http://www.kitware.com/blog/home/post/510</a><br> <br></div>What he said. See also past discussion at<br> <a href="http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP" target="_blank">http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP</a><br> I put together some tiny demos showing various ways to do it, with<br> walkthroughs, at<br> <a href="http://kegel.com/macosx/rpath/" target="_blank">http://kegel.com/macosx/rpath/</a><br></blockquote></div><br></div></blockquote><div><br></div></div><br>-- <br><div><br></div>Powered by www.kitware.com<br><div><br></div>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br><div><br></div>Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br><div><br></div>CMake Support: http://cmake.org/cmake/help/support.html<br>CMake Consulting: http://cmake.org/cmake/help/consulting.html<br>CMake Training Courses: http://cmake.org/cmake/help/training.html<br><div><br></div>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><div><br></div>Follow this link to subscribe/unsubscribe:<br>http://www.cmake.org/mailman/listinfo/cmake</blockquote><div><br></div></div></body></html>