<div dir="ltr">>> A strategy I've seen used before is to arrange for all the build outputs (libraries, executables) to end up in a directory structure that mimics the installed layout. This can be helpful if the applications expect to find things at some specific <span class="gmail-il">location</span> relative to themselves at run time.<div><br></div><div>We're doing this already, but this doesn't solve the problem. The project is a collection of libraries and binaries and until now (i.e. using LOCATION), we could compute the relative paths from binary to its libraries in the makefiles and append to rpath in linker flags (i.e. see above)</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 2:31 PM Craig Scott <<a href="mailto:craig.scott@crascit.com">craig.scott@crascit.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 8:18 AM Hendrik Greving <<a href="mailto:hendrik.greving.smi@gmail.com" target="_blank">hendrik.greving.smi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is there a good place to record the feature request (- if ack'd -)? gitlab issue?<div>Thanks!</div></div></blockquote><div><br></div><div>Gitlab is the place to record feature requests (and to check for existing ones):</div><div><br></div><div><a href="https://gitlab.kitware.com/cmake/cmake" target="_blank">https://gitlab.kitware.com/cmake/cmake</a></div><div><br></div><div>Relocating build trees is not supported in general by CMake, it embeds absolute paths in various places. I doubt this is likely to change. If you want to relocate an <i>install</i> directory, you should either:</div><div><ul><li>Ensure the installed products themselves are relocatable (which is a good goal in itself), or</li><li>Simply install again to the new location rather than move the installed directory.</li></ul></div><div>A strategy I've seen used before is to arrange for all the build outputs (libraries, executables) to end up in a directory structure that mimics the installed layout. This can be helpful if the applications expect to find things at some specific location relative to themselves at run time. It can be a bit finicky and doesn't play well with multi-config generators like Xcode or Visual Studio (due to them adding a config-specific directory to the directory structure), but maybe it is an option to consider (I'd personally avoid it if I can though).</div><div><br></div><div>Not sure if it is relevant here, but there has also been some recent discussions going on regarding the use of relative RPATH in the build tree, but that's more to do with making builds reproducible:</div><div><br></div><div><a href="https://gitlab.kitware.com/cmake/cmake/issues/18413" target="_blank">https://gitlab.kitware.com/cmake/cmake/issues/18413</a><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 4, 2018 at 2:24 PM Hendrik Greving <<a href="mailto:hendrik.greving.smi@gmail.com" target="_blank">hendrik.greving.smi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, we would like to..<div>(*) keep modularity and flexibility (i.e. avoid hard-coding relative paths) w/ binaries and libraries in build tree at flexible locations.</div><div>(*) update rpath in the target binary based on relative paths from $ORIGIN, such that a user or any other script can move the build (and later install) tree.</div><div>The project (DynamoRIO) has multiple libraries and multiple target binaries such that the CMAKE* solution (and thanks for that in any case) above would not work for all of them. LOCATION and file(RELATIVE..) provided that functionality. With CMP0026 and LOCATION going away, there seems to be no substitute for this, even w/ 3.13 it sounds like we still couldn't compute the relative path(s). Would it be feasible for me to put in a feature request in cmake?</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 3, 2018 at 11:28 PM Hendrik Sattler <<a href="mailto:post@hendrik-sattler.de" target="_blank">post@hendrik-sattler.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
Hi,<br>
<br>
You can use the following cmake snippet right below the project() <br>
command to add proper RPATH values:<br>
include ( GNUInstallDirs )<br>
if ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )<br>
list ( APPEND CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" )<br>
endif ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )<br>
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )<br>
<br>
This assumes, libraries are installed to CMAKE_INSTALL_LIBDIR and <br>
programs to CMAKE_INSTALL_BINDIR.<br>
Additionally you may add the following line to disable a change in the <br>
binary files during install target run:<br>
set ( CMAKE_BUILD_WITH_INSTALL_RPATH ON )<br>
<br>
<br>
The latter might be useful when splitting of debug symbols on ELF <br>
platforms in post-build. However, it disables running the binaries in <br>
the build tree.<br>
<br>
<br>
CMake supports PDB files but split dbgsym file are (strangely) not <br>
supported out-of-the-box.<br>
<br>
HS<br>
<br>
<br>
Zitat von Hendrik Greving <<a href="mailto:hendrik.greving.smi@gmail.com" target="_blank">hendrik.greving.smi@gmail.com</a>>:<br>
<br>
> By the way, the new generator expression support in 3.13, is this for<br>
> LINK_FLAGS or LINK_OPTIONS. And regardless of the former, will it be<br>
> possible to compute a relative path based on generator expressions, i.e.<br>
> file(RELATIVE $<TARGET_FILE_DIR:mytarget> $<TARGET_FILE_DIR:mytargetlib>)?<br>
><br>
> On Thu, Sep 27, 2018 at 5:03 PM Hendrik Greving <<br>
> <a href="mailto:hendrik.greving.smi@gmail.com" target="_blank">hendrik.greving.smi@gmail.com</a>> wrote:<br>
><br>
>> Thanks. Ok one step back. What we want is to have the same relative path<br>
>> from binary/executable to linked library in build and install tree (which<br>
>> we assume is the same for us). Looks like by default, e.g. cmake 3.9, puts<br>
>> in an absolute path. The current (c-)makefiles compute the relative part of<br>
>> an executable -> library by using LOCATION and add this to<br>
>> -Wl,-rpath=$ORIGIN/[relative part]. We want to do the same w/o LOCATION<br>
>> (i.e. resolving CMP0026)<br>
>><br>
>> On Thu, Sep 27, 2018 at 7:29 AM Brad King <<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>> wrote:<br>
>><br>
>>> On 09/26/2018 10:23 AM, Hendrik Greving wrote:<br>
>>> > Is there any way before 3.13 to achieve what I need? Right now we<br>
>>> > modify LINK_FLAGS based on something that is computed with values<br>
>>> > from LOCATION.<br>
>>> [snip]<br>
>>> > our cmake setup is using LOCATION property for two targets to compute<br>
>>> > a relative path from these two, and adds this to LINK_FLAGS<br>
>>> > (for rpath, but irrelevant in this context).<br>
>>><br>
>>> To at least see if 3.13 will support your use case, you could<br>
>>> try a nightly binary from here:<br>
>>><br>
>>> <a href="https://cmake.org/files/dev/?C=M;O=D" rel="noreferrer" target="_blank">https://cmake.org/files/dev/?C=M;O=D</a><br>
>>><br>
>>> Use `$<TARGET_FILE_DIR:mytarget>/..` to refer to a path relative<br>
>>> to the target file location.<br>
>>><br>
>>> I've never seen a need to adjust link flags based on the target<br>
>>> location. CMake has several features for RPATH support. What<br>
>>> are you really trying to do?<br>
>>><br>
>>> -Brad<br>
>>><br>
>><br>
<br>
<br>
<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>
</blockquote></div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-6165834634716558755gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>New book released: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div>
</blockquote></div>