[CMake] TARGET_LINK_LIBRARIES with full path libraries

Volker Pilipp volker.pilipp at dectris.com
Wed Sep 17 06:29:10 EDT 2014


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 am wondering if this is a cmake bug and if there exists a workaround.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140917/b59e9b9f/attachment-0001.html>


More information about the CMake mailing list