CMake:添加命令行选项 [英] CMake: Adding command line options
问题描述
我正在使用CMake构建一个大型图书馆,我希望用户能够选择性地启用/禁用我的构建过程的某些部分。
I'm building a large library using CMake and I would like users to be able to selectively enable/disable certain parts of my build process.
我如何添加命令行选项到我的CMake构建,例如以便用户可以输入类似 cmake --build-partone --nobuild-parttwo --dothis = true --dothat = false ..
How can I add command line options to my CMake build, e.g. so that users may type something like cmake --build-partone --nobuild-parttwo --dothis=true --dothat=false ..
显然,OPTION关键字将创建可以从CMake GUI设置的变量,但是我不知道如何从命令行执行此操作。
Apparently the OPTION keyword will create variables that can be set from the CMake GUI, but I can't figure out how to do this from the command line.
推荐答案
是的,你使用选项
命令。您可以通过这种方式从命令行设置选项:
Yeah, you shoud use option
command. You can set options from command line this way:
//CMakeLists.txt
option(MyOption "MyOption" OFF)
//Command line
cmake -DMyOption=ON MyProjectFolder
请注意,-DMyOption必须在路径之前。
Note that -DMyOption must come before the path.
这篇关于CMake:添加命令行选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!