[CMake] link only with targets feature

Alexander Neundorf neundorf at kde.org
Tue Feb 12 15:23:35 EST 2019


On 2019 M02 12, Tue 08:02:43 CET Starka Tomáš wrote:
> tldr;
> It would be wonderful to have function or signature for
> target_link_libraries tha would link only to a targets. Did I overlook
> something?
> 
> like target_link_libraries(name [PUBLIC...] TARGETS myFavouriteLib ...
> QUIET/VERBOSE)
> 
...
> But then I guess it wouldn't hurt to have something like
> target_link_libraries(name [PUBLIC...] TARGETS myFavouriteLib ...
> QUIET/VERBOSE) which would not try to give linker myFavouriteLib.lib
> if there was no target of that name in question. Or
> target_link_targets... realy doesn't matter as long as it does that
> and maybe when asked by the last parameter it gives an error if the
> one of the target is non-existent or ill-formed. 

I agree to target_link_targets().
Additionally I would prefer if (maybe with a policy) include directories would 
be only applied when using target_link_targets(), but not when using 
target_link_libraries().
This would make it more obvious IMO.

Alex



More information about the CMake mailing list