如何使用命令行在cmake中取消设置变量?

时间:2018-04-23 22:46:26

标签: c++ cmake

我知道为了设置变量,我们会-DVARIABLE=VALUE,但是如果我需要取消它会怎么样?

我尝试了-DVARIABLE=FALSE但是它没有用,编译器抱怨FALSE意味着什么

1 个答案:

答案 0 :(得分:4)

神奇的旗帜是-U。修剪输出:

$ grep DOCS CMakeCache.txt 
HOUSEGUEST_BUILD_DOCS:BOOL=OFF
$ cmake -UHOUSEGUEST_BUILD_DOCS .
-- Configuring done
-- Generating done
-- Build files have been written to: /my/build/folder
$ !grep
grep DOCS CMakeCache.txt 
HOUSEGUEST_BUILD_DOCS:BOOL=ON

来自cmake --help

-U <globbing_expr>           = Remove matching entries from CMake cache.