{
  "id": "cmake/variable-not-defined-in-if",
  "signature": "CMake Error: if given arguments: \"VAR\" \"STREQUAL\" \"value\" Unknown arguments specified",
  "signature_zh": "CMake 错误：if 给定的参数：\"VAR\" \"STREQUAL\" \"value\" 指定了未知参数",
  "regex": "CMake Error: if given arguments: \".*\" Unknown arguments specified",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 CMake if() 条件中使用了变量名但没有加 ${}，导致 CMake 将其视为字面字符串而不是展开变量。",
  "versions": [
    {
      "version": "CMake 3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.27",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding quotes around the variable: if(\"${VAR}\" STREQUAL \"value\")",
      "why_fails": "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.",
      "fail_rate": 0.1,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the STREQUAL keyword and using if(VAR value) thinking it's a different syntax",
      "why_fails": "CMake does not support if(VAR value) as a comparison; it will either error or give unexpected results.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Defining the variable with set(VAR \"value\") but still using bare VAR in if()",
      "why_fails": "Even if the variable is defined, bare VAR in if() checks if the literal string 'VAR' is defined, not the variable's value.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use ${VAR} in the if() condition to expand the variable.",
      "success_rate": 0.95,
      "how": "Use ${VAR} in the if() condition to expand the variable.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Alternatively, use if(DEFINED VAR) to check if the variable is defined, then use ${VAR} in comparisons.",
      "success_rate": 0.9,
      "how": "Alternatively, use if(DEFINED VAR) to check if the variable is defined, then use ${VAR} in comparisons.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use ${VAR} in the if() condition to expand the variable.",
    "Alternatively, use if(DEFINED VAR) to check if the variable is defined, then use ${VAR} in comparisons."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/if.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-08-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}