Cmake Set Variable
Cmake uses many variables that are officially documented.
Cmake set variable. To extend the scope of a variable there are two possibilities. The syntax for declaring a variable and setting it if it is not already set is. In which case the environment variable will be set. In fact defining your own custom variables makes your cmakelists txt file.
A lot of variables used by cmake are set with the project and enable language calls. Example set my variable the value is a string by default a local variable is only defined in the current directory and any subdirectories added through the add subdirectory command. Set my cache variable value cache string description this will not replace an existing value. To see the available variables for an environment open the corresponding command prompt and type set.
If you want to set a variable from the command line cmake offers a variable cache. The include command executes another cmake script in the same scope as the calling script. When we faced the same issue you have a toolkit which produces a script so set the compile environment we changed the toolkit in a way that it produces a toolchain file along with the script. It s typically used to define a common set of functions or macros in the calling script.
So it could get important to set some variables before those commands are used. Placeholder expect zero or more arguments. Environment variables may differ from where cmake generated the make environment and when the the make files are put to use. See the cmake language 7 variables documentation for the scopes and interaction of normal variables and cache entries.
Some variables are already here like cmake build type. You are allowed to change the value of these variables in your cmakelists txt. Multiple arguments will be joined as a semicolon separated list to form the actual variable value to be set. Some of the information in environment variables is also available through cmake system introspection variables but you may find it more convenient to use the environment variable.
Set a normal cache or environment variable to a given value. Normal variables are meant for the internal use of the script just like variables in most programming languages. In addition you can also define any variables you need. It s a lot like the include directive in c c.
Mostly you will use normal variables. They are not persisted across cmake runs. The only way to set a compiler and flags to do cross compilation reliably with cmake is with a toolchain file as done in the tutorial you have found. It uses the variable cmake module path as a search path.
Cmake variables are defined at file scope. These have default values or values that are based on your project environment. Signatures of this command that specify a value.