# How to detect misspelled variable names on command line

**URL:** <https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016>\
**Category:** Code\
**Created:** [February 15, 2022, 10:26pm UTC](https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016 "2022-02-15T22:26:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Post date:** [February 15, 2022, 10:26pm UTC](https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016/1 "2022-02-15T22:26:16Z")

</div>

My CMakeLists.txt can take variables and values specified on the command line in the usual form -Dname=value. E.g.

`% cmake -DmyVariable=someValue ..`

How can CMakeLists.txt detect variables that aren’t actually relevant, e.g. in case the user mispells them:

`% cmake -Dmyxvarble=someValue ..`

For example, can CMakeLists.txt process each defined variable on the command line sequentially, thereby spotting misspelled variable names?

I’m running cmake version 3.18.0-rc2

---

<div class="post-metadata">

**Author:** ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)\
**Post date:** [February 16, 2022, 1:30am UTC](https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016/2 "2022-02-16T01:30:48Z")

</div>

CMake already warns when a variable set on the command line is not subsequently used by the program. Cache entries also get rendered in the ccmake and cmake-gui interfaces, which make spelling a name wrong impossible.

CMake also allows you to dereference unset variables and specifies the semantics: you get an empty string. So what it would mean for a variable to be “misspelled” in the first place is unclear.
