[CMake] Exporting variables

Brad King brad.king at kitware.com
Fri May 27 16:35:29 EDT 2005


Shishir Ramam wrote:
> Consider the case when projects are nested as below
> root/    # PROJECT(root)
>      subproj1/..   # PROJECT(proj1)
>      subproj2/..   # PROJECT(proj2)
> 
> Proj1 does some local checking to figure out variables local to subproj1. 
> (For example version number and setting appropriate subdir settings).
> 
> In my case, I'd like this variable to be available to the parent
> project "root" and
> external project "proj2". Is there a way to export the variable value from 
> proj1 such that it is visible outside proj1? 

For now you have to use a CACHE variable:

SET(PROJ1_EXPORTED_VARIABLE "some_value" CACHE INTERNAL "doc string")

A future CMake release will probably provide a nicer way to do this but 
it is not yet implemented.

-Brad


More information about the CMake mailing list