When a Project is defined some project specific variables are set:
<PROJECT-NAME>_SOURCE_DIR
<PROJECT-NAME>_BINARY_DIR
<PROJECT-NAME>_VERSION
<PROJECT-NAME>_DESCRIPTION
The scope of this variables seems to be inconsistent.
<PROJECT-NAME>_SOURCE_DIR and <PROJECT-NAME>_BINARY_DIR have global scope where the other variables only are defined within the current directory and its sub-directories.
Does someone know, if this is the intended behavior?
I want to use <PROJECT-NAME>_DESCRIPTION and others in another top-level CMake-Directory, where it isn’t available anymore.
In contrast the CMAKE_PROJECT_DESCRIPTION (which is linked to the very first project-call) is available globally.
It is very important that the PROJECT_... variables are limited to the scope they currently have. It ensures you can use them and have confidence that you are referring to the most recent project() call in the current directory stack. There are techniques that rely on this.
If you need the top level details, that’s what the CMAKE_PROJECT_... variables are for. I think only a couple of those are defined though, not the full set equivalents of PROJECT_... variables.
FYI you can retrieve the value of a variable from a different directory scope as follows: