[CMake] link_libraries() deprecated. Why?
Philip Lowman
philip at yhbt.com
Wed Apr 1 23:50:26 EDT 2009
On Wed, Apr 1, 2009 at 5:35 PM, Marcel Loose <loose at astron.nl> wrote:
> Hi all,
>
> I was wondering why the link_libraries() command has been deprecated.
> Commands like include_directories() and link_directories() which have the
> same "scope" have not been deprecated. I think that link_libraries() has its
> virtues too.
>
> My reason for asking this, is that I wonder what's the proper way to add a
> library to *all* targets in a project; for example, a logging library or a
> threads library. Here, link_libraries() provides IMHO a much cleaner
> solution, than target_link_libraries(). The latter requires me to keep track
> of the globally used library in a variable that must be passed around; and
> for each target I must explicitly specify its dependency on this library by
> using target_link_libraries().
>
> Or, am I missing something, and is there a cleaner way to do this, without
> using a deprecated feature?
Often I have seen people write functions to help with this especially if you
have more than one common library.
function(link_target_against_common_libs _target)
target_link_libraries(${_target} ${WHATEVER_LIBRARY})
endfunction()
Another approach is if you have a low level library as part of your codebase
that everyone depends upon you can simply make it dependent on your
threading or logging libraries and anyone that is dependent against it will
automatically link against the threading or logging library.
--
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090401/8ccb9337/attachment-0001.htm>
More information about the CMake
mailing list