On 11/28/2013 08:58 AM, Samuel Martin wrote: > When I try to link against it, "find_libray" correctly found it: > --- > CMakeCache.txt: > FOO_LIBRARIES:INTERNAL=general;/usr/lib/foo.so > --- > > But the generated linker flags are wrong: > --- > link.txt: > /usr/bin/c++ -g CMakeFiles/bar.dir/main.cpp.o -o bin/bar -rdynamic -lfoo
Unfortunately we currently convert libraries in implicit directories (like /usr/lib) to the "-lx" form because some toolchains substitute per-architecture alternatives under the hood so "/usr/lib/libx.a" actually needs to be "/usr/lib/$arch/libx.a". I've posted similar explanations on the CMake mailing lists a few times before. It cannot be fixed without teaching find_library how to parse binaries of all forms on all platforms to detect compatible architectures. That is very difficult. To force CMake to use a given path, create an imported target and set the location to the desired path. For example: add_library(foo SHARED IMPORTED) set_property(TARGET foo IMPORTED_LOCATION /usr/lib/foo.so) target_link_libraries(bar foo) -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
