ButterDog
ButterDog

Reputation: 5245

Exporting cmake-gui options

I have a library with a bunch of different configuration options. We usually configure the build with cmake-gui and ticking a few checkboxes.

I want to automate this into a .sh script using just cmake.

e.g.
In GUI -> selects a bunch of different options
equivalent cmake command -> cmake -D CMAKE_XXX=X -D CMAKE_XXY=XXY [a bunch of options here] ..

How can I find the "equivalent" cmake command-line command to any arbitrary configuration I choose from the GUI?

Upvotes: 4

Views: 3853

Answers (5)

usr1234567
usr1234567

Reputation: 23422

You can write a file containing all variables you want to set with set(<var_name> <value>) and pass this file to the CMake call via -C:

cmake -C <fileWithInitialValues> <pathToSrcDir>

Documentation:
https://cmake.org/cmake/help/v3.3/manual/cmake.1.html

This should would similar with cmake-gui and ccmake, but it is not a pure solution with the graphic interface.

Upvotes: -1

Stone
Stone

Reputation: 1169

cmake-gui generates CMakeVars.txt and CMakeCache.txt files in the build directory once you click "Configure" button. They cache all variables you configured through the GUI.

Upvotes: 2

JackGrinningCat
JackGrinningCat

Reputation: 510

Had the same question ... and as you asked I looking up some of the options in the menu and found it. Menu Tools -> Show My Changes

Bringing up an Dialog with an edit field with content for command line options or cache file options.

yeah

p.s. I used cmake 3.11.1

Upvotes: 2

Antonio
Antonio

Reputation: 20306

The equivalent cmake command to cache a variable is explained here (-D option). Note that previous documentation was ambiguous, so take care of always checking the latest one.

Basically:

-D<var>:<type>=<value>

You have to specify also the type to have the variable cached in the same way as through your cmake-gui procedure. Note that variable definition is necessary only the first time: if not specified anymore, the cached value will be used.

Upvotes: 4

Peter K
Peter K

Reputation: 1807

just read file named like CMakeCache.txt (iirc) in the root of build directory and see variable names there

Upvotes: 0

Related Questions