To make values available to the whole CMake environment from within a subdirectory one may set a cache variable using the set(VARIABLE_NAME Value CACHE INTERNAL "")
syntax or set a global property using the set_property(GLOBAL PROPERTY VARIABLE_NAME Value)
syntax (see also this very good answer about variables in CMake).
Using the latter has the advantages that you are not "polluting" the CMake cache for something it is not designed for and that you are not dependent on the cache being deleted when not using the FORCE
parameter.
But the syntax to use the variable value is not that user-friendly as you have to retrieve the value using get_property
instead of simply using the ${...}
notation.
Is there a simpler syntax to use instead of get_property
(some kind of syntactic sugar)?