[cmake-developers] Namespaces

Pau Garcia i Quiles pgquiles at elpauer.org
Thu Jan 28 15:07:13 EST 2016


On Thu, Jan 28, 2016 at 8:21 PM, Stephen Kelly <steveire at gmail.com> wrote:


Pau Garcia i Quiles wrote:
>
> > CMake should wrap every variable defined under the directory added with
> > add_subdirectory(QtZeroConf NAMESPACE QTZEROCONF)
>
> So, CMake needs to first determine what variables are used in the
> QtZeroConf
> directory (presumably without executing the cmake code there) and then wrap
> the variables, then execute the cmake code?
>
I must be missing something. I don't think that's possible.
>
>
I think it's just a matter of adding an "internal note" saying "OK, I'm
going to namespace variables from now on" in cmAddSubdirectoryCommand when
add_subdirectory contains NAMESPACE, and then modifying the literal of the
variable in cmSetCommand.cxx (first argument to AddDefinition here in line
165):

this->Makefile->AddDefinition(variable, value.c_str());

https://github.com/Kitware/CMake/blob/master/Source/cmSetCommand.cxx#L165


> 3rdparty/CMakeLists.txt contains ExternalProject_Add(QtZeroConf ...)
> >
> > and
> >
> > server/CMakeLists.txt contains find_package(QtZeroConf)
>
> I think you need:
>
>  ExternalProject_Add(3rdparty/Whatever ...)
>  ExternalProject_Add(3rdparty/QtZeroConf ...)
>  ExternalProject_Add(server ...)
>
> and pass appropriate args to the latter, including where to look for
> dependencies etc (and dependencies among the ExternalProjects).
>
> You might not like this solution, but as far as I know it is the only
> correct solution built into CMake.
>
>
The only thing I like about that solution is it's doable today with CMake.
But I think my approach would prove much easier and direct for developers
using CMake: add_subdirectory(dir NAMESPACE blah) and find_package(whatever
EXTERNAL_PROJECT epwhatever).

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160128/9b463020/attachment.html>


More information about the cmake-developers mailing list