[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] getting the rpath right on osx
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2015-11-02 15:08:55
Message-ID: CAExHGmTF4QRXeJ7cSxe0q18_SNsKzmsSgVxf1=EReiWZxct48g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

On Mon, Nov 2, 2015 at 2:49 PM, Boudewijn Rempt <boud@valdyas.org> wrote:

> On Mon, 2 Nov 2015, Andreas Pakulat wrote:
>
> I think the idea of using @rpath as install name of the Qt libraries is
>> geared towards the usecase
>> of shipping Qt within the application bundle of the application. In that
>> case all you need is set
>> the rpath @executable_path/../Frameworks or so in the executable and thus
>> the app-bundle is
>> relocatable. In order to get that with CMake you'll likely need to use
>> the BundleUtilities, though
>> its been so long since I used those I don't know if they can handle this
>> scenario out of the box.
>>
>>
> Yes, that's what I'm trying to do -- well, I'm trying to do two
> things. One is setup a build environment where kde apps like desktoptojson
> can run, the other is creating a bundle, preferably using the same
> Qt. I got quite far by manually fixing up the applications built as part
> of kcoreaddons


That would be fixed in kcoreaddons by extending the linker flags to include
the mentioned -Wl,-rpath,<qtlibdir>. There's no provisioning for this
inside CMake afaik since its hard for it to guess what the intention is. My
understanding (not a OSX expert yet here) is also that having the install
name of a framework on OSX be something like @rpath is quite unusual. Thats
usually something that users are 'patching' when they bundle their
application via install_name_tool. And thats what CMake supports doing via
the BundleUtilities module.


> and then manually patching up the executable inside the
> bundle to have the @executable_path/../Frameworks rpath added. But I'm
> still not sure why with a really simple example things don't work out
> of the box: I guess I had better build Qt with -norpath.


See above, I think the way the Qt frameworks are setup when using -rpath is
simply not expected/anticipated so far by CMake (or the people maintaining
the qt5 cmake modules inside Qt).

However I never tried to use BundleUtilities with such a framework, maybe
they do manage to 'fixup' things for that as well. For a Qt4-based project
I'm using INSTALL_QT4_EXECUTABLE which eventually forwards to fixup_bundle
from BundleUtilities, so may be worth a try to avoid the manual steps.

Even a Qt built with -norpath would require doing some 'manual' things to
get a all-in-one app bundle for the application (or use of
BundleUtilities), to copy things around and adjust the install and link
names in all the frameworks and executables to be related and thus make the
application relocatable.

Andreas

[Attachment #5 (text/html)]

<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov \
2, 2015 at 2:49 PM, Boudewijn Rempt <span dir="ltr">&lt;<a \
href="mailto:boud@valdyas.org" target="_blank">boud@valdyas.org</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><span class="">On Mon, 2 Nov 2015, Andreas Pakulat \
wrote:<br> <br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> I think the idea of using @rpath as install name of the Qt \
libraries is geared towards the usecase<br> of shipping Qt within the application \
bundle of the application. In that case all you need is set<br> the rpath \
@executable_path/../Frameworks or so in the executable and thus the app-bundle is<br> \
relocatable. In order to get that with CMake you&#39;ll likely need to use the \
BundleUtilities, though<br> its been so long since I used those I don&#39;t know if \
they can handle this scenario out of the box.<br> <br>
</blockquote>
<br></span>
Yes, that&#39;s what I&#39;m trying to do -- well, I&#39;m trying to do two<br>
things. One is setup a build environment where kde apps like desktoptojson<br>
can run, the other is creating a bundle, preferably using the same<br>
Qt. I got quite far by manually fixing up the applications built as part<br>
of kcoreaddons</blockquote><div><br></div><div>That would be fixed in kcoreaddons by \
extending the linker flags to include the mentioned -Wl,-rpath,&lt;qtlibdir&gt;. \
There&#39;s no provisioning for this inside CMake afaik since its hard for it to \
guess what the intention is. My understanding (not a OSX expert yet here) is also \
that having the install name of a framework on OSX be something like @rpath is quite \
unusual. Thats usually something that users are &#39;patching&#39; when they bundle \
their application via install_name_tool. And thats what CMake supports doing via the \
BundleUtilities module.</div><div>  </div><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">and then \
manually patching up the executable inside the<br> bundle to have the \
@executable_path/../Frameworks rpath added. But I&#39;m<br> still not sure why with a \
really simple example things don&#39;t work out<br> of the box: I guess I had better \
build Qt with -norpath.</blockquote><div><br></div><div>See above, I think the way \
the Qt frameworks are setup when using -rpath is simply not expected/anticipated so \
far by CMake (or the people maintaining the qt5 cmake modules inside \
Qt).</div><div><br></div><div>However I never tried to use BundleUtilities with such \
a framework, maybe they do manage to &#39;fixup&#39; things for that as well. For a \
Qt4-based project I&#39;m using INSTALL_QT4_EXECUTABLE which eventually forwards to \
fixup_bundle from BundleUtilities, so may be worth a try to avoid the manual \
steps.</div><div><br></div><div>Even a Qt built with -norpath would require doing \
some &#39;manual&#39; things to get a all-in-one app bundle for the application (or \
use of BundleUtilities), to copy things around and adjust the install and link names \
in all the frameworks and executables to be related and thus make the application \
relocatable.</div><div><br></div><div>Andreas</div></div></div></div>



-- 

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://public.kitware.com/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic