[CMake] How does :: actually works?

Klaim - Joël Lamotte mjklaim at gmail.com
Mon Jun 15 10:40:10 EDT 2015


On 13 June 2015 at 22:29, Alexander Neundorf <a.neundorf-work at gmx.net>
wrote:

> On Thursday, June 11, 2015 19:18:55 Klaim - Joël Lamotte wrote:
> > On 11 June 2015 at 15:22, Johannes Zarl-Zierl <
> johannes.zarl-zierl at jku.at>
> >
> > wrote:
> > > Hi,
> > >
> > > > I tried several times now to find documentation about how to define
> > > > and use target names which seem to have namespaces, like Qt ones.
> > > >
> > > > For example: add_executable( MyProject::some_target ... )
> > >
> > > AFAIK target namespaces are intended for imported targets, not
> "regular"
> > > targets:
> > >
> > > "A NAMESPACE with double-colons is specified when exporting the targets
> > > for
> > > installation. This convention of double-colons gives CMake a hint that
> the
> > > name is an IMPORTED target when it is used by downstreams with the
> > > target_link_libraries() command. This way, CMake can issue a
> diagnostic if
> > > the
> > > package providing it has not yet been found."
> > > [1]
> > >
> > >
> > > [1]
> > >
> http://www.cmake.org/cmake/help/v3.3/manual/cmake-packages.7.html?highligh
> > > t=namespace
> > >
> > >
> > > I can't find any documentation or even name for this.
> > >
> > > > Is it considered a "namespace"?
> > > > In any way I found nothing specific to this syntax in the wiki.
> > >
> > > The concept is called "namespace" in cmake, just as you assumed. I
> don't
> > > know
> > > if there's anything about it in the wiki, but the official
> documentation
> > > has a
> > > (very) short description in the cmake_packages[1] page, as well as in
> the
> > > documentation for the export command.
> >
> > (sorry I was actually thinking about the documentation and typed "wiki")
> >
> > Thanks, it was not totally clear that the definition of the namespace is
> > done
> > in another operation, so I assumed that it was just a local option, not
> ana
> > actual language feature,
> > and simply dismissed it.
> > Maybe the concept should have it's own section?
> > There is no mention of this in the language page. Or is it really useful
> > only if you are writing exports?
> >
> > Anyway thanks, it's clearer now.
>
>
> What do you actually want to do with the "namespace" ?
> cmake does not really have namespaces, what the documentation talks about
> is
> only used as a hint when using imported targets.
>
Alex
>

I'm trying to figure out better ways to organize my projects which have the
following properties:
 1. cross-platform (that part is covered by cmake)
 2. are composed of a lot of different executables and libraries
 3. have a lot of different dependencies.

I also study the recent wave of dependency managements solutions, but
that's another topic.

One of my projects is open source and is a big set of tools (mostly
libraries uses by one big gui tool)
and I was wondering about the syntax that you can see in some projects like
Qt, which have
lot of tools too, so maybe it could be useful to me.

So far I didn't get what imported targets helps with, so I'm a bit lost on
the usefulness of "namespaces"
but I am sure that I am missing something.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150615/27b03b09/attachment.html>


More information about the CMake mailing list