{
  "id": "cmake/generator-expression-syntax-error-in-condition",
  "signature": "CMake Error: Error evaluating generator expression:\n  $<IF:$<CONFIG:Debug>,debug_flag,release_flag>\n  Expression syntax error: unexpected token after $<IF:",
  "signature_zh": "CMake 错误：评估生成器表达式时出错：\n  $<IF:$<CONFIG:Debug>,debug_flag,release_flag>\n 表达式语法错误：$<IF: 后出现意外标记",
  "regex": "CMake Error: Error evaluating generator expression:\\n.*\\n.*Expression syntax error",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The generator expression has a syntax error, such as a missing comma, mismatched parentheses, or incorrect nesting. In this example, $<IF: requires exactly three arguments separated by commas, but the condition itself contains a nested expression that wasn't properly closed.",
  "root_cause_type": "generic",
  "root_cause_zh": "生成器表达式存在语法错误，例如缺少逗号、括号不匹配或嵌套不正确。在此示例中，$<IF: 需要三个由逗号分隔的参数，但条件本身包含未正确关闭的嵌套表达式。",
  "versions": [
    {
      "version": "3.15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.24",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The issue is usually incorrect nesting or missing closing angle brackets, not comma count. Extra commas create more syntax errors.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "String concatenation with set() doesn't work per-configuration. The error will be replaced by incorrect build flags.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This bypasses per-configuration logic, potentially breaking Debug/Release distinctions. It also makes the build less maintainable.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the generator expression syntax. For $<IF:>, ensure the condition is a single expression. Use $<IF:$<CONFIG:Debug>,debug_flag,release_flag> correctly. The nested expression must be self-contained. Example:\n  target_compile_definitions(mytarget PRIVATE $<IF:$<CONFIG:Debug>,DEBUG_MODE,RELEASE_MODE>)",
      "success_rate": 0.85,
      "how": "Fix the generator expression syntax. For $<IF:>, ensure the condition is a single expression. Use $<IF:$<CONFIG:Debug>,debug_flag,release_flag> correctly. The nested expression must be self-contained. Example:\n  target_compile_definitions(mytarget PRIVATE $<IF:$<CONFIG:Debug>,DEBUG_MODE,RELEASE_MODE>)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use $<STREQUAL:> or $<EQUAL:> for comparisons. For boolean conditions, use $<BOOL:>. Break complex expressions into simpler parts using set() with generator expressions.",
      "success_rate": 0.8,
      "how": "Use $<STREQUAL:> or $<EQUAL:> for comparisons. For boolean conditions, use $<BOOL:>. Break complex expressions into simpler parts using set() with generator expressions.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Test the generator expression in a minimal CMakeLists.txt to isolate the issue. Use message() to print the evaluated expression at configure time.",
      "success_rate": 0.75,
      "how": "Test the generator expression in a minimal CMakeLists.txt to isolate the issue. Use message() to print the evaluated expression at configure time.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "修复生成器表达式语法。对于 $<IF:>，确保条件是一个单一表达式。正确使用 $<IF:$<CONFIG:Debug>,debug_flag,release_flag>。嵌套表达式必须是自包含的。示例：\n  target_compile_definitions(mytarget PRIVATE $<IF:$<CONFIG:Debug>,DEBUG_MODE,RELEASE_MODE>)",
    "使用 $<STREQUAL:> 或 $<EQUAL:> 进行比较。对于布尔条件，使用 $<BOOL:>。使用 set() 将复杂表达式分解为更简单的部分。",
    "在最小的 CMakeLists.txt 中测试生成器表达式以隔离问题。使用 message() 在配置时打印评估后的表达式。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}