[CMake] How to declare global variables

Denis Scherbakov denis_scherbakov at yahoo.com
Mon Mar 23 05:17:53 EDT 2009


I also have a very big project with sub-projects lying in different tree leafs. And when I started to learn CMake I also had a question, how to define variables that can be seen on other project in other tree leaf.

What I also learned from a newsgroup is that most of the time, when you need variables to be seen in other project, you are doing something wrong.

If you need to define a global variable like HAVE_SOMETHING, use your top level CMakeLists.txt file.

Denis



> > Currently I'm having a bit of trouble making
> variables defined in the
> > following directory:
> > 
> > C:\a\b\c\d\e\CMakeLists.txt
> > 
> > Available to another script in a distant directory,
> located here:
> > 
> > C:\a\b\x\y\z\CMakeLists.txt
> > 
> > I've tried using PARENT_SCOPE, but this
> doesn't declare it "high"
> > enough. The only possible way I've been able to
> make this work is by
> > making it an internal cache variable. However, I do
> not want to
> > persist the contents of the variable. Do I have any
> other options?



      


More information about the CMake mailing list