Feature Request: Make `<projectName>_VERSION` available in the parent (or global) scope
When integrating a dependency with find_package
and a version config file is available, find_package
provides a variable <PackageName>_VERSION
variable.
When integrating a dependency with add_subdirectory
(e.g. with FetchContent_MakeAvailable
) and the project
call contains a VERSION
, a variable <projectName>_VERSION
is set but only in the scope of the directory.
Would it make sense to set this variable in the parent scope or even in the cache? Currently there is no easy way to retrieve the version of a dependency integrated with add_subdirectory
, and having the variable would allow writing code that works regardless of whether the dependency is "found" or "added". Also, it would be consistent with <projectName>_SOURCE_DIR
and <projectName>_BINARY_DIR
, which are already cache variables (see #25714).