[CMake] What are the actual benefits of namespaced targets?
Nils Gladitz
nilsgladitz at gmail.com
Thu Mar 8 14:05:48 EST 2018
On 08.03.2018 19:50, Alan W. Irwin wrote:
> So what are the actual benefits of namespacing the exported targets
> associated with libraries?
On the consumer side it makes linking to targets less error prone.
When you link to a library target without a namespace and e.g. get the
name or scope wrong CMake will silently assume that you want to link a
library by name (e.g. in context of gcc "foo" becomes "-lfoo").
When the library and its headers happens to be in the compiler's
standard search directories this might not even get caught at build time
right away.
When the library target has a namespace CMake will require the given
name to be a target and will fail during generation if the target is not
actually available.
Nils
More information about the CMake
mailing list