[CMake] TARGET_LINK_LIBRARIES with full path libraries

Volker Pilipp volker.pilipp at dectris.com
Wed Sep 17 07:50:17 EDT 2014


I did so and found the following strange behaviour

link_directories(  /opt/XXX/lib ) -> no effect
but
link_directories(  /opt/ ) -> -L/opt (?!)

Volker


On Wed, Sep 17, 2014 at 1:32 PM, J Decker <d3ck0r at gmail.com> wrote:

> can't just add link_directories(  /opt/XXX/lib ) ?
>
> On Wed, Sep 17, 2014 at 3:58 AM, Nils Gladitz <nilsgladitz at gmail.com>
> wrote:
>
>> On 09/17/2014 12:29 PM, Volker Pilipp wrote:
>>
>>> I have encountered the following problem with cmake 3.0.1.
>>> Under certain circumstances TARGET_LINK_LIBRARIES replaces
>>> "/path/to/libXXX.so" by "-lXXX". The problem occurred when I used a
>>> non-standard compiler at /opt/XXX/bin/g++ and added the library
>>> /opt/XXX/lib/libXXX.so to TARGET_LINK_LIBRARIES.
>>> In particular CMakeLists.txt reads:
>>>
>>> "SET(CMAKE_CXX_COMPILER /opt/XXX/bin/g++)
>>> CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
>>> PROJECT(XXX)
>>> add_executable(xxx xxx.cpp)
>>> target_link_libraries(xxx /opt/XXX/lib/libXXX.so)"
>>>
>>> When running make VERBOSE=1 produces output like
>>>
>>> /opt/XXX/bin/g++ (...) -lXXX
>>>
>>> which is not the same as
>>> /opt/XXX/bin/g++ (...) /opt/XXX/lib/libXXX.so
>>>
>>
>> I think CMake reverts to linking by name if either the library is in an
>> implicit linker directory (e.g. a directory the linker searches by default)
>> or if the shared library does not have an SONAME.
>>
>> Which library does -lXXX resolve to?
>> e.g. why aren't the two command lines equivalent for you?
>>
>> Specifically which library does the linker (ld) pick up;
>> not the runtime loader (ld.so).
>>
>> Nils
>>
>>
>> --
>>
>> 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
>>
>
>


-- 
**************************************************
Volker Pilipp
Software & IT Technologies

DECTRIS Ltd.
Neuenhoferstr. 107
5400 Baden
Switzerland

+41 56 500 2100 general
+41 56 500 2101 fax
+41 56 500 2115 direct
volker.pilipp at dectris.com
www.dectris.com
**************************************************

Confidentiality Note
This message is intended only for the use of the named recipient(s)
and may contain confidential and/or privileged information. If you are
not the intended recipient, please contact the sender and delete the
message. Any unauthorized use of the information contained in this
message is prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140917/d192f04c/attachment-0001.html>


More information about the CMake mailing list