[英]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.我们通常使用
cmake-gui
配置构建并勾选几个复选框。
I want to automate this into a .sh
script using just cmake
.我想仅使用
cmake
将其自动化为.sh
脚本。
eg例如
In GUI -> selects a bunch of different options在 GUI -> 选择一堆不同的选项
equivalent cmake command -> cmake -D CMAKE_XXX=X -D CMAKE_XXY=XXY [a bunch of options here] ..
等效的 cmake 命令 ->
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 ?如何找到与我从 GUI 中选择的任意配置的“等效”
cmake
命令行命令?
The equivalent cmake command to cache a variable is explained here ( -D
option).此处解释了缓存变量的等效 cmake 命令(
-D
选项)。 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.您还必须指定类型以与通过 cmake-gui 过程相同的方式缓存变量。 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 ps我用的是cmake 3.11.1
cmake-gui generates CMakeVars.txt and CMakeCache.txt files in the build directory once you click "Configure" button.单击“配置”按钮后,cmake-gui 在构建目录中生成 CMakeVars.txt 和 CMakeCache.txt 文件。 They cache all variables you configured through the GUI.
它们缓存您通过 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
:您可以编写一个包含要使用
set(<var_name> <value>)
设置的所有变量的文件,并通过-C
将此文件传递给 CMake 调用:
cmake -C <fileWithInitialValues> <pathToSrcDir>
Documentation:文档:
https://cmake.org/cmake/help/v3.3/manual/cmake.1.html https://cmake.org/cmake/help/v3.3/manual/cmake.1.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.