{
  "id": "cmake/generator-expression-missing-dollar",
  "signature": "CMake Error: Error evaluating generator expression:\n    $<TARGET_FILE:mylib>\n  The expression does not start with a generator expression token.",
  "signature_zh": "CMake 错误：计算生成器表达式时出错：\n    $<TARGET_FILE:mylib>\n  表达式不以生成器表达式标记开头。",
  "regex": "CMake Error: Error evaluating generator expression:\n.*\n  The expression does not start with a generator expression token",
  "domain": "cmake",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "A generator expression was used outside of a context that supports them (e.g., in a regular set() command or a comment), or the expression is malformed (missing leading $).",
  "root_cause_type": "generic",
  "root_cause_zh": "在支持生成器表达式的上下文之外使用了生成器表达式（例如在普通的 set() 命令或注释中），或者表达式格式错误（缺少开头的 $）。",
  "versions": [
    {
      "version": "cmake 3.18",
      "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.26",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cmake 3.30",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Generator expressions are not shell variables; escaping breaks the syntax.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "message() does not evaluate generator expressions at configure time; use file(GENERATE) instead.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Move the generator expression into a target property or a command that supports it, e.g., target_compile_definitions(mylib PRIVATE \"$<TARGET_FILE:mylib>\")",
      "success_rate": 0.85,
      "how": "Move the generator expression into a target property or a command that supports it, e.g., target_compile_definitions(mylib PRIVATE \"$<TARGET_FILE:mylib>\")",
      "condition": "",
      "sources": []
    },
    {
      "action": "If used in a file write, use file(GENERATE ...) with the expression: file(GENERATE OUTPUT output.txt CONTENT \"$<TARGET_FILE:mylib>\")",
      "success_rate": 0.9,
      "how": "If used in a file write, use file(GENERATE ...) with the expression: file(GENERATE OUTPUT output.txt CONTENT \"$<TARGET_FILE:mylib>\")",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将生成器表达式移到支持它的目标属性或命令中，例如 target_compile_definitions(mylib PRIVATE \"$<TARGET_FILE:mylib>\")",
    "如果在文件写入中使用，请使用 file(GENERATE ...) 配合表达式：file(GENERATE OUTPUT output.txt CONTENT \"$<TARGET_FILE:mylib>\")"
  ],
  "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.84,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}