Using conan and CMake 3.6, I have a conanfile.txt like this:
[requires]
boost/1.73.0@myProject-3rd-party-dependencies/rhel7
xerces-c/3.2.3@myProject-3rd-party-dependencies/rhel7
[generators]
cmake
cmake_find_package
virtualenv
virtualrunenv
This generates Findboost.cmake and Findxerces-c.cmake files. My CMakeLists.txt contains the line:
link_libraries(boost::boost xerces-c::xerces-c)
When the makefile generated by cmake links my target the link command looks like this:
/usr/local/bin/g++ -g CMakeFiles/xsd-packager.dir/xsd-packager/src/main/c++/Main.cpp.o
-o xsd-packager
-L/home/lindbjs1/.conan/data/boost/1.73.0/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib
-L/home/lindbjs1/.conan/data/xerces-c/3.2.3/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib
-Wl,-rpath,/home/lindbjs1/.conan/data/boost/1.73.0/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib:/home/lindbjs1/.conan/data/xerces-c/3.2.3/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib:::::::::::::::::::::::::::::::::::::::::::::::::
/home/lindbjs1/.conan/data/boost/1.73.0/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib/libboost_system.so
… and so on for the other boost libraries…
/home/lindbjs1/.conan/data/xerces-c/3.2.3/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib/libxerces-c.so
/home/lindbjs1/.conan/data/xerces-c/3.2.3/myProject-3rd-party-dependencies/rhel7/package/87fb0b451a964f931487412a0e21bdef04c50390/lib/libxerces-c-3.2.so
The behavior is the same if I use target_link_libraries for the individual targets instead of the global link_libraries. The -L options are correct. (I haven't looked into why the -Wl,-rpath option ends with a multitude of colons.) How do I, or can I, get cmake to use, e.g., -lboost_system, instead of the full pathnames to the imported libraries?