CMake: How to access a variable from a subdirectory without explicitly setting it in parent scope
box2d, cmake
Solution
If the variable is a plain variable (as opposed to a cache variable), there is no way to access it from the parent scope.
Cache variables (those set with `set(... CACHE ...)`) can be accessed regardless of scope, as can global properties (`set_property(GLOBAL ...)`).
Problem
I have added a subdirectory in `CMake` by using `add_subdirectory`. How can I access a variable from the scope of that subdirectory without explicitly setting the variable by using `set` in combination with `PARENT_SCOPE` ? ``` set(BOX2D_BUILD_STATIC 1) set(BOX2D_BUILD_EXAMPLES 0) set(BOX2D_INSTALL_BY_DEFAULT 0) add_subdirectory(Box2D_v2.2.1) message(STATUS "Using Box2D version ${BOX2D_VERSION}") # how to get ${BOX2D_VERSION} variable without modifying CMakeLists.txt in Box2D_v2.2.1? ``` Is this possible?