[CMake] link_libraries vs target_link_libraries

Bill Hoffman bill.hoffman at kitware.com
Wed Nov 12 08:11:14 EST 2008

So, I guess I will comment on this...  :)

Originally CMake was directory based.  We are moving towards being 
target based.   For directories, targets, and projects, there should be 
a way to set:

- defines
- includes
- link libraries
- compiler flags

Currently you can set:

compiler flags:

define symbols:

libraries with target_link_libraries.

config based compile defines:

include_directories can only be set on a per directory basis.  At some 
point a target will have all the links, includes, and flags required to 
use it stored somewhere, and that will come with the target.   This can 
be done now with macros and functions, the new CMake build for boost 
does some of this.   If someone wants to a bug entry could be created 
for target specific include files, that would be good.

As for the title of the thread target_link_libraries should be used in 
most cases.  However link_libraries could still be a useful short cut.

Note, CMake does use the link libraries for a target transitively.  If 
you do not want that, you can use:


More information about the CMake mailing list