<div dir="ltr"><div>Let's try again...</div><div><br></div><div>I submitted a question last week but got no responses so I have assumed my question and/or example was not explicit enough. I have stripped out all unnecessary structure from the code and am posing the question better (I hope)...</div><div><br></div><div>The functionality that I am using is expressed in this old bug: <a href="http://public.kitware.com/Bug/view.php?id=10395">http://public.kitware.com/Bug/view.php?id=10395</a>. I am adding dependencies in my project based on an imported library which is built by ExternalProject_add. Everything works but the linking is not as I would expect. I add my imported library like so (see code for ExternalProject_add statement):</div><div><br></div><div><div>add_library(ExtLib SHARED IMPORTED)</div><div>set_property(TARGET ExtLib PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/${EXT_LIB_NAME}")</div><div>add_dependencies(ExtLib ExtLibBuild)</div></div><div><br>I then link against this in my binary like so:</div><div><br></div><div><div>add_executable(testApp testApp.cpp)</div><div>target_link_libraries(testApp LINK_PUBLIC TestLib ExtLib)</div><div><br></div><div>However, when I do this, the binray that comes out has a relative path to the 'ExtLib' which means I can only run it from the directory CMake builds it in. When I change the linking to be the below with the full path to ExtLib, it works just fine and I can run it from anywhere:</div><div><br></div><div>target_link_libraries(testApp LINK_PUBLIC TestLib "${CMAKE_BINARY_DIR}/${EXT_LIB_NAME}")<br></div></div><div><br></div><div>I gave the full path to the imported library in the "set_property..IMPORTED_LOCATION..." so I am unsure why the first one does not work?</div><div><br></div><div>In this previous post from Brad in 2010 (<a href="http://www.cmake.org/pipermail/cmake/2010-September/039639.html">http://www.cmake.org/pipermail/cmake/2010-September/039639.html</a>), it seems that the first way should work like I want, correct?</div><div><br></div><div>A few other notes:</div><div>* I have my RPATH properties set which has been a factor in getting this to work but I haven't tested enough to known which ones are actually helping or not.</div><div>* The (more) SSCCE project is here: <a href="https://github.com/calebwherry/cmake-SO-question-main.git">https://github.com/calebwherry/cmake-SO-question-main.git</a><br></div><div>* I have also attached a tar'ed version.<br></div><div>* System specs: Debian Wheezy 64-bit, CMake 3.0.2, GCC 4.9.2.<br></div><div><br></div><div>Thanks,</div><div>Caleb</div><div><br></div>-- <br><div class="gmail_signature"><div>J. Caleb Wherry</div><i>Scientific Software Engineer</i><div><br><a href="http://www.calebwherry.com" target="_blank"></a><div><a href="http://www.calebwherry.com" target="_blank">http://www.calebwherry.com</a><br><span><span title="Call with Google Voice"><span title="Call with Google Voice">+1 (615) 708-5651</span></span></span><div><a href="mailto:calebwherry@gmail.com" target="_blank">calebwherry@gmail.com</a></div></div></div></div>
</div>