Ugh ! It gets messier. I'm beginning to understand why it is the way it is. The cmake developers have probably already been round this loop and decided it wasn't worth the effort :-)
On 1 May 2014 19:41, Nils Gladitz <nilsglad...@gmail.com> wrote: > On 01.05.2014 20:38, Glenn Coombs wrote: > >> Okay, I think I understand what you're saying. Variables set in a >> CMakeLists.txt file added by add_subdirectory are only visible in that >> CMakeLists.txt and any further ones it adds via add_subdirectory. The >> higher level CMakeLists.txt files would not have the necessary visibility, >> hence the need to cache the project source directory variable. To make it >> behave consistently it would be necessary for cmake to be able to set a >> variable in the scope of the top level CMakeLists.txt. Similar to the >> PARENT_SCOPE that the set() command already has, something like >> set(foo_SOURCE_PROJECT "path/to/source" ROOT_SCOPE). >> >> I suspect that the reason cmake is caching these variable is because the >> set() command doesn't have a ROOT_SCOPE ability and using cache variables >> was the easiest way to simulate that. And we have to live with the >> unfortunate side effect that the cached variables don't exist on the first >> run but do on subsequent runs. >> >> > I don't think it would be sufficient to set it in the root scope either > since I think each scope has its own copy of the variable. > It would have to be set for all scopes between the root and the current > scope. > > Nils >
-- 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://www.cmake.org/mailman/listinfo/cmake