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

List:       cmake
Subject:    Re: [CMake] MacOS and shared libraries from imported targets
From:       Eric Doenges <doenges () mvtec ! com>
Date:       2019-09-25 7:50:06
Message-ID: 0f29b6ee-94a1-dade-ce37-7877b3f018e3 () mvtec ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


As far as I am aware, the macOS linker simply records the install name 
of the dynamic library you link against in your executable (similar to 
how the Linux linker records the Elf SONAME, if present). So, the first 
step would be to check the install name of the external dynamic library 
by running 'otool -L' on it (the install name should be at the top of 
the output). You can change the install name using the install_name_tool 
(but if you build the external dynamic library yourself I think it is 
better to build the library with the correct install name in the first 
place).

Am 24.09.19 um 18:02 schrieb Michael Welsh Duggan:
> I have a project that links against an external dynamic library for
> which I have written a Find module that creates an import target.  I do
> this, in part, by setting the IMPORTED_LOCATION property of the target
> to the location of the dynamic library.
>
> Unfortunately, on OSX the library shows up in the executable load
> commands as an LC_LOAD_DYLIB of the raw filename (no directory) of the
> shared library.  I expected it to use the whole path.  I tried setting
> the INSTALL_NAME_DIR property to the directory containing the shared
> library, but this changed nothing.
>
> I will note that this is all still in the build location, as opposed to
> post-install.  I am using the following settings currently:
>
> set(CMAKE_SKIP_BUILD_RPATH false)
> set(CMAKE_BUILD_WITH_INSTALL_RPATH false)
> set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)
> set(CMAKE_MACOSX_RPATH true)
>
> I'm not 100% confident with how these options interact, so I am more
> than prepared for someone to tell me that I am doing something wrong.
> Any hints would be appreciated.
>
-- 

*Dr. Eric Dönges*
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
doenges@mvtec.com <mailto:mustermann@mvtec.com> | Tel: +49 89 457 695-0 
| www.mvtec.com <http://www.mvtec.com>

Find our privacy policy here <https://www.mvtec.com/imprint>.

Sign up <https://www.mvtec.com/newsletter> for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

MVTec Software GmbH Logo

[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>As far as I am aware, the macOS linker simply records the install
      name of the dynamic library you link against in your executable
      (similar to how the Linux linker records the Elf SONAME, if
      present). So, the first step would be to check the install name of
      the external dynamic library by running 'otool -L' on it (the
      install name should be at the top of the output). You can change
      the install name using the install_name_tool (but if you build the
      external dynamic library yourself I think it is better to build
      the library with the correct install name in the first place).</p>
    Am 24.09.19 um 18:02 schrieb Michael Welsh Duggan:<br>
    <blockquote type="cite"
      cite="mid:y2tdef8sqdfzt3.fsf@lx-birch.ad.sei.cmu.edu">
      <pre class="moz-quote-pre" wrap="">I have a project that links against an \
external dynamic library for which I have written a Find module that creates an \
import target.  I do this, in part, by setting the IMPORTED_LOCATION property of the \
target to the location of the dynamic library.

Unfortunately, on OSX the library shows up in the executable load
commands as an LC_LOAD_DYLIB of the raw filename (no directory) of the
shared library.  I expected it to use the whole path.  I tried setting
the INSTALL_NAME_DIR property to the directory containing the shared
library, but this changed nothing.

I will note that this is all still in the build location, as opposed to
post-install.  I am using the following settings currently:

set(CMAKE_SKIP_BUILD_RPATH false)
set(CMAKE_BUILD_WITH_INSTALL_RPATH false)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)
set(CMAKE_MACOSX_RPATH true)

I'm not 100% confident with how these options interact, so I am more
than prepared for someone to tell me that I am doing something wrong.
Any hints would be appreciated.

</pre>
    </blockquote>
    <div class="moz-signature">-- <br>
      <div style="width:480px; text-align: left; font-family: Arial,
        Helvetica, sans-serif;">
        <p style="color: #062d64; font-size: 14px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;">
          <b>Dr. Eric Dönges</b>
          <br>
          Senior Software Engineer
        </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;">MVTec Software
          GmbH | Arnulfstr. 205 | 80634 Munich | Germany
          <br>
          <a style="font-size: 12px; font-family: Arial, Helvetica,
            sans-serif; color: #062d64;"
            href="mailto:mustermann@mvtec.com">doenges@mvtec.com</a> |
          Tel: +49 89 457 695-0 | <a style="font-size: 12px;
            font-family: Arial, Helvetica, sans-serif; color: #062d64;"
            href="http://www.mvtec.com">www.mvtec.com</a>
          <br>
        </p>
        <p>
          <span style="font-size: 12px; font-family: Arial, Helvetica,
            sans-serif; color: #062d64;">Find our privacy policy <a
              style="font-size: 12px; font-family: Arial, Helvetica,
              sans-serif; color: #062d64;"
              href="https://www.mvtec.com/imprint">here</a>.</span> </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;"><img
src="https://mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/newsletter-icon.png"
  valign="bottom" width="16" height="16"> <a style="font-size:
            12px; font-family: Arial, Helvetica, sans-serif; color:
            #062d64; font-weight: bold;"
            href="https://www.mvtec.com/newsletter">Sign up</a> for our
          MVTec Newsletter!</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;">Geschäftsführer:
          Dr. Wolfgang Eckstein, Dr. Olaf Munkelt<br>
          Amtsgericht München HRB 114695</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;"> </p>
        <img
src="https://www.mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/mvtec-logo-line.png"
  alt="MVTec Software GmbH Logo"></div>
    </div>
  </body>
</html>



-- 

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:
https://cmake.org/mailman/listinfo/cmake



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

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