[cmake-developers] Recommended use of imported targets...

Brad King brad.king at kitware.com
Thu Feb 28 07:38:07 EST 2013


On 02/27/2013 04:37 PM, Alexander Neundorf wrote:
> 1) we should continue to recommend to use the variables (which will now be set 
> to the name of the target). In case of typos, this will lead to an empty 
> variable (as it did before with Find-modules), and undefined references when 
> linking. This is at least no regression.
> Also, it shields users somewhat from potential renaming of the imported 
> targets.

This is up to individual projects based on their own requirements.
Some interface may be more stable than others.  I do not think any
general recommendation can be made without lots of contingencies.

> safe_target_link_libraries(hello TARGET:foox
>                                  FILE:/opt/lib/libbar.a
>                                  LIBRARY:png)

Sure, it is possible to make interfaces typo-resistant by adding lots
of syntax.  Part of the simplicity tll() is that it has little syntax.

Note that FILE: and LIBRARY: do not need to be distinguished from
one another because files always have paths (/) and library names
never do.  For TARGET: we already have $<TARGET_NAME:foox>, which
IIUC can be used in tll already (Steve?).

There is only so much CMake can do.  There are plenty of places
that typos in CMake code can lead to breakage at build time.

-Brad



More information about the cmake-developers mailing list