Exporting cmake-gui options

元气小坏坏 提交于 2021-02-03 16:37:49

问题


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?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/30310562/exporting-cmake-gui-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!