[CMake] MacOS and shared libraries from imported targets
Michael Welsh Duggan
mwd at cert.org
Tue Sep 24 12:02:00 EDT 2019
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.
--
Michael Welsh Duggan
(mwd at cert.org)
More information about the CMake
mailing list