Based on the thread "cmake variable scope, add_subdirectory", the CMake set command will set the variable in the current scope only, unless the PARENT_SCOPE
parameter is specified.
Recently when I was looking at the project command, per CMake doc, variables <PROJECT-NAME>_SOURCE_DIR
and <PROJECT-NAME>_BINARY_DIR
will be set. But it didn't mention what is the scope of these variables. Can these variable be used in other subdirectory? For example:
|- root
| |- CMakeLists.txt // add_subdirectory(proj1); add_subdirectory(proj2)
| |
| |- proj1
| | |- CMakeLists.txt // project(proj1)
| |
| |- proj2
| | |- CMakeLists.txt // Does this have access to proj1_SOURCE_DIR or
// poj1_BINARY_DIR?
What about variables for other command like Find_Package
? What is the scope of the <Module>_FOUND
variable? Thanks!