[cmake-developers] Make it easier for beginners

Nicholas Devenish ndevenish at gmail.com
Thu Oct 26 04:46:20 EDT 2017


On Thu, Oct 26, 2017 at 12:49 AM, Wesley Smith <wesley.hoke at gmail.com>
wrote:

> I still don't understand the scoped syntax in Daniel Pfeifer's talk (e.g.
> boost::boost)
>

Easy: It doesn't mean anything special, it's almost entirely just a name
(think of :: as any other character).

The advantage is,
a) bookkeeping e.g. cleanly namespacing stuff (which admittedly could be
done with _/prefixes)
and more importantly
b) If you give an undefined name e.g. "boost_notalib" (or something
mis-spelled) to target_link_libraries it'll just add "-lboost_notalib" to
the link command - because it doesn't know if it's a custom library that it
doesn't know about,  or an undefined target. A name like "Boost::NotALib"
can never be a library name, so if it's not a defined target you'll get an
error at configuration time rather than build time.

(Caveat: I am not an expert so could be completely wrong in incomplete or
subtle ways, but this is definitely one way it makes a difference)

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20171026/1c9d7d81/attachment.html>


More information about the cmake-developers mailing list