user6791424
user6791424

Reputation:

How to unset a variable in cmake using command line?

I know that in order to set a variable, we do -DVARIABLE=VALUE, but what if I need to unset it?

I tried -DVARIABLE=FALSE but it didn't work, the compiler complains about what does FALSE means

Upvotes: 10

Views: 8189

Answers (1)

Stephen Newell
Stephen Newell

Reputation: 7873

The magic flag is -U. Trimmed output:

$ 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

From cmake --help:

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

Upvotes: 13

Related Questions