On Thu, Jan 28, 2016 at 21:07:13 +0100, Pau Garcia i Quiles wrote:
> 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());

This is not the only place variables are created.

> 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).

As mentioned elsewhere, what about things like find_package() in the
subdirectory? Do they get namespaced as well? Is a cache overflowing
with png_ZLIB_LIBRARY, sqlite3_ZLIB_LIBRARY, and so on sensible? Is
having to set all of them if the library is in a weird place something
you want users to have to do? What about custom properties (be it on
targets, directories, global)? Do they also get namespaced?

Functions are globally scoped, so what namespace do they apply? What if
they have controlling variables from their module which is now
namespaced, but called from a non-namespaced location?

I think the solution to your problem is to use INTERNAL cache variables
(for cache variables created by the third party project) or local
variables to override the cache variables in scope (which would likely
work for BUILD_SHARED_LIBS or ENABLE_TESTING).

--Ben
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to