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

-- 

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

Reply via email to