-D <var>:<type>=<value>
: Create a cmake cache entry.
ok, but what can <type>
be? I've seen BOOL, STRING, PATH, FILEPATH. What else can that type be?
Options and variables are defined on the CMake command line like this: $ cmake -DVARIABLE=value path/to/source You can set a variable after the initial `CMake` invocation to change its value. You can also undefine a variable: $ cmake -UVARIABLE path/to/source Variables are stored in the `CMake` cache.
The CMake cache may be thought of as a configuration file. The first time CMake is run on a project, it produces a CMakeCache. txt file in the top directory of the build tree. CMake uses this file to store a set of global cache variables, whose values persist across multiple runs within a project build tree.
Every process (e.g. your bash) that creates a child process (your cmake) provides the newly process a copy of its environment. You cannot change the environment of the parent process later. But you can start a intermediate process that sets the environment variables and then starts cmake.
Provide a boolean option that the user can optionally select. If no initial <value> is provided, boolean OFF is the default value. If <variable> is already set as a normal or cache variable, then the command does nothing (see policy CMP0077 ).
From the CMake man page, under "Properties on Cache Entries":
TYPE Widget type for entry in GUIs.
Cache entry values are always strings, but CMake GUIs present widgets to help users set values. The GUIs use this property as a hint to determine the widget type. Valid TYPE values are:
BOOL = Boolean ON/OFF value.
PATH = Path to a directory.
FILEPATH = Path to a file.
STRING = Generic string value.
INTERNAL = Do not present in GUI at all.
STATIC = Value managed by CMake, do not change.
UNINITIALIZED = Type not yet specified.
Generally the TYPE of a cache entry should be set by the command which creates it (set, option, find_library, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With