[CMake] Rebuild target when external library changes?

Bill Hoffman bill.hoffman at kitware.com
Wed Dec 3 12:02:47 EST 2008


Lezz Giles wrote:
> One question, one suggestion:
> 
>If I do specify full paths, doesn't that mean that I'm forcing cmake to
use static linking? Doesn't this preclude one of the advantages of cmake
- that it's easy to switch from static to dynamic linking? (Not that I'm
complaining! I'm definitely going to use Bill's solution.)
> 

You are forcing CMake to use one or the other which ever is found/specified.

> And how about this behaviour:
> - if TARGET_LINK_LIBRARIES() is given a full path or the name of a
> library that it knows about, the dependency is created (in other
> words, no change),

> - if it is given a library name that it doesn't know about, it uses
> the standard method to find the library and adds the dependency (new
> behaviour),
> - if it can't find the library then it prints a warning (new
> behaviour), and finally
> - this behaviour is added to the documentation (which currently
> doesn't show TARGET_LINK_LIBRARIES being given pathnames, just
> library names, and which also doesn't mention TARGET_LINK_LIBRARIES
> adding dependencies at all).

CMake is not a linker.

If you say target_link_libraries(foo A), and A is not a CMake target, 
then CMake will add -lA (unix) or A.lib on windows.  I don't think we 
really want to get into the linker emulation game.

Certainly, the documentation can be changed to recommend using a full 
path in target_link_libraries.

-Bill


More information about the CMake mailing list