# CMake Error: if given arguments: "VAR" "STREQUAL" "value" Unknown arguments specified

- **ID:** `cmake/variable-not-defined-in-if`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Using a variable name without ${} in a CMake if() condition, causing CMake to treat it as a literal string instead of expanding it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.10 | active | — | — |
| CMake 3.16 | active | — | — |
| CMake 3.22 | active | — | — |
| CMake 3.27 | active | — | — |

## Workarounds

1. **Use ${VAR} in the if() condition to expand the variable.** (95% success)
   ```
   Use ${VAR} in the if() condition to expand the variable.
   ```
2. **Alternatively, use if(DEFINED VAR) to check if the variable is defined, then use ${VAR} in comparisons.** (90% success)
   ```
   Alternatively, use if(DEFINED VAR) to check if the variable is defined, then use ${VAR} in comparisons.
   ```

## Dead Ends

- **Adding quotes around the variable: if("${VAR}" STREQUAL "value")** — Quoting the variable expansion is fine, but the real issue is forgetting ${}. This workaround actually works if the variable is defined, but it's a style issue. (10% fail)
- **Removing the STREQUAL keyword and using if(VAR value) thinking it's a different syntax** — CMake does not support if(VAR value) as a comparison; it will either error or give unexpected results. (95% fail)
- **Defining the variable with set(VAR "value") but still using bare VAR in if()** — Even if the variable is defined, bare VAR in if() checks if the literal string 'VAR' is defined, not the variable's value. (80% fail)
