Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a configuration variable to my CMake script?

Tags:

cmake

I'd like to add a variable that the user must set after clicking "Configure" in cmake-gui. Is there a way to do this?

like image 512
May Oakes Avatar asked Sep 03 '11 16:09

May Oakes


People also ask

How do I add a variable in CMake?

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.

What is configure in CMake?

CMAKE_CONFIGURATION_TYPES. Specifies the available build types (configurations) on multi-config generators (e.g. Visual Studio, Xcode , or Ninja Multi-Config ). Typical values include Debug , Release , RelWithDebInfo and MinSizeRel , but custom build types can also be defined.

How do I configure CMake options?

There are two different ways to configure with cmake ; one is to run cmake in a fresh directory passing some options on the command line, and the other is to run ccmake and use its editor to change options. For both, assume you are in a directory called debug and the IMP source is in a directory at ../imp .

Where is CMake config?

cmake the corresponding version file is located next to it and named either <config-file>-version. cmake or <config-file>Version. cmake . If no such version file is available then the configuration file is assumed to not be compatible with any requested version.


1 Answers

Using the set command, specify CACHE parameters, e.g.

set(NAME_INCLUDE "default value" CACHE FILEPATH "description") set(NAME_LIB "default value" CACHE FILEPATH "description") 

In the GUI CMake will group all variables with the same prefix.

See the CMake documentation for set.

like image 120
4 revs, 3 users 86% Avatar answered Oct 15 '22 10:10

4 revs, 3 users 86%