[CMake] TARGET_LINK_LIBRARIES with full path libraries
Xavier Besseron
xavier.besseron at uni.lu
Thu Sep 18 04:12:10 EDT 2014
Dear all,
I had the same issue some time ago with the Boost library.
The solution for me was to declare this library as "imported".
Here is an example:
add_library( curl UNKNOWN IMPORTED)
set_property(TARGET curl PROPERTY IMPORTED_LOCATION "/opt/XXX/lib/libcurl.so.4")
add_executable(xxx xxx.cpp)
target_link_libraries(xxx curl)
Here are some relevant links:
http://www.cmake.org/pipermail/cmake/2011-June/044790.html
http://www.cmake.org/Wiki/CMake_2.6_Notes#Linking_to_System_Libraries
Regards,
Xavier
2014-09-18 9:05 GMT+02:00 J Decker <d3ck0r at gmail.com>:
> It shouldn't truncate paths if specified... cause of course if we want to
> test against a dev version then maybe the script knows better. But neither
> should it add the full path if it's not specified in the script.
>
> On Wed, Sep 17, 2014 at 11:59 PM, Nils Gladitz <nilsgladitz at gmail.com>
> wrote:
>>
>> On 09/18/2014 07:52 AM, Volker Pilipp wrote:
>>>
>>> That actually does the trick. But it's not nice, because there are many
>>> targets in the project.
>>> Actually, I do not know about any use case, where cmake should replace a
>>> full path to a lib
>>> by its "-l" shortcut.
>>
>>
>> There are as far as I understand two use cases.
>>
>> - The library does not have a SONAME
>> Linking to the library by path would embed the full path of the library
>> in the target rather than just the name (which is what it does with -l or
>> when the library does have a SONAME set)
>>
>> - The second use case I am not familiar with myself but the explanation in
>> the code is:
>> // Many system linkers support multiple architectures by
>> // automatically selecting the implicit linker search path for the
>> // current architecture. If the library appears in an implicit link
>> // directory then just report the file name without the directory
>> // portion. This will allow the system linker to locate the proper
>> // library for the architecture at link time.
>>
>>
>> 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
>
>
--
Dr Xavier BESSERON
Research associate
FSTC, University of Luxembourg
Campus Kirchberg, Office E-007
Phone: +352 46 66 44 5418
http://luxdem.uni.lu/
More information about the CMake
mailing list