[CMake] ExternalProject with target_link_library produces incorrect linking?
J. Caleb Wherry
calebwherry at gmail.com
Tue Dec 9 16:05:22 EST 2014
Works like a charm, I knew I was overlooking something small. Thanks, Brad!
-Caleb
On Tue, Dec 9, 2014 at 2:30 PM, Brad King <brad.king at kitware.com> wrote:
> On 12/09/2014 12:26 PM, J. Caleb Wherry wrote:
> > add_library(ExtLib SHARED IMPORTED)
> > set_property(TARGET ExtLib PROPERTY IMPORTED_LOCATION
> "${CMAKE_BINARY_DIR}/${EXT_LIB_NAME}")
> > add_dependencies(ExtLib ExtLibBuild)
>
> Thanks for the complete/simple example. The problem is that
> the libExtLib.so file built by the external project does not
> have DT_SONAME set by the linker. When a linker is given a
> path to a shared library file that has no soname then the path
> is copied into the DT_NEEDED field of the consumer since it
> has no soname to use for that.
>
> There are two solutions:
>
> 1. Make sure DT_SONAME gets set properly by the external build system.
>
> 2. Tell CMake that the imported library file has no soname:
>
> set_property(TARGET ExtLib PROPERTY IMPORTED_NO_SONAME 1)
>
> CMake will then link it via -lExtLib and the linker will not
> store the path to the file in DT_NEEDED but only the file name.
>
> Either of these should resolve the issue. Number 1 is cleaner.
>
> -Brad
>
>
--
J. Caleb Wherry
*Scientific Software Engineer*
<http://www.calebwherry.com>
http://www.calebwherry.com
+1 (615) 708-5651
calebwherry at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141209/d7ce31d9/attachment.html>
More information about the CMake
mailing list