[CMake] Link different libraries in different targets
Hi there ! I'm quite new to CMake, so please forgive me if the question seems obvious. My project has lines like : link_directories(/path/to/libA/) add_library(my_project SHARED my_file.cpp) target_link_libraries(my_project A) I browsed help and googled a few, but I still wonder how I could set /path/to/libA/ to be different according to targets. Something like /path/to/libA/Foo/ for some targets /path/to/libA/Bar/ for others. But my targets are not the basic Release/Debug/... ones, more diverse. Info : I'm working with VS2008, but trying CMake for Mac/Linux/iOS ports. Thanks Domé -- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Link different libraries in different targets
A few ideas: Set the targets' LINK_FLAGS separately to specify the linker dirs. Use target_link_libraries on the file path rather than the lib name. Make an imported library target for the libs in each dir and then link with those targets. (I'm assuming these are not libs you're building) -- Cheers, Leif On Tue, Apr 2, 2013 at 12:08 PM, domenico the.seca...@gmail.com wrote: Hi there ! I'm quite new to CMake, so please forgive me if the question seems obvious. My project has lines like : link_directories(/path/to/libA/) add_library(my_project SHARED my_file.cpp) target_link_libraries(my_project A) I browsed help and googled a few, but I still wonder how I could set /path/to/libA/ to be different according to targets. Something like /path/to/libA/Foo/ for some targets /path/to/libA/Bar/ for others. But my targets are not the basic Release/Debug/... ones, more diverse. Info : I'm working with VS2008, but trying CMake for Mac/Linux/iOS ports. Thanks Domé-- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Link different libraries in different targets
Just add more link_directories commands or put more arguments in the one your have: link_directories(/path/to/libA path/to/libB) -- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Link different libraries in different targets
On 2013-04-02 12:08, domenico wrote: I'm quite new to CMake, so please forgive me if the question seems obvious. My project has lines like : link_directories(/path/to/libA/) add_library(my_project SHARED my_file.cpp) target_link_libraries(my_project A) I browsed help and googled a few, but I still wonder how I could set /path/to/libA/ to be different according to targets. Something like /path/to/libA/Foo/ for some targets /path/to/libA/Bar/ for others. But my targets are not the basic Release/Debug/... ones, more diverse. Don't do that :-). In general, using link_directories is discouraged. It is preferred to give only targets or full paths to target_link_libraries(). (Use find_library as needed to resolve 'pretty' names to full names with platform-specific prefixes and suffixes.) So to have B link to /path/to/Foo/libA, and C link to /path/to/Bar/libA, just do: target_link_libraries(B /path/to/Foo/libA) target_link_libraries(C /path/to/Bar/libA) -- Matthew -- 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://www.cmake.org/mailman/listinfo/cmake