Fail cmake if there are unused variables defined

Hi all!

I want make cmake fail if there are some unused variables defined.
Currently I do get a warning, but I couldn’t find a way to cause cmake exit with non-zero return value.

For example, I want the following invocation to fail:

cmake -S . -B build -DSOME_UNUSED_VAR=ON

I tried with both -Wdev -Werror=dev but it did not help.

Any ideas?

The --warn-unused-* flags predate the -Wdev mechanism. It could be converted over to be -W flags with -Werror= alternatives for consistency. I know I don’t have time to work on the change, but an issue and/or MR for it would be the place to start.