简体   繁体   中英

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 .

eg
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 ?

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.

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

ps I used cmake 3.11.1

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.

只需在构建目录的根目录中读取名为 CMakeCache.txt (iirc) 的文件,并在那里查看变量名称

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM