CMake:VariablesListsStrings: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
==Scope of variables in CMake==
==Scope of variables in CMake==
In CMake variables don't have to be declared, they are created upon their first usage:
src/foo/CMakeLists.txt:
  set(SomeVariable "Hello world")
This creates (if it didn't exist yet) the variable <tt>SomeVariable</tt>.
In CMake all variables in CMake are '''global'''.
Global means that the variables exist in the file where they have been created, in all subdirectories connected using ADD_SUBDIRECTORY() or SUBDIRS(), and in all included files in any of these directories. They don't propagate up to the parent directories.
Also if the value of a variable is changed in a subdirectory, the change doesn't propagate up to the variable in the parent directory.


==Strings vs. lists==
==Strings vs. lists==

Revision as of 15:46, 2 January 2008

Scope of variables in CMake

In CMake variables don't have to be declared, they are created upon their first usage:

src/foo/CMakeLists.txt:

 set(SomeVariable "Hello world")

This creates (if it didn't exist yet) the variable SomeVariable. In CMake all variables in CMake are global. Global means that the variables exist in the file where they have been created, in all subdirectories connected using ADD_SUBDIRECTORY() or SUBDIRS(), and in all included files in any of these directories. They don't propagate up to the parent directories. Also if the value of a variable is changed in a subdirectory, the change doesn't propagate up to the variable in the parent directory.

Strings vs. lists

Emulating maps

Boolean values in CMake

Using CMake regexps

Escaping

The CMake cache