{
  "id": "cmake/target-link-libraries-interface-mismatch",
  "signature": "CMake Error: Target \"mylib\" has INTERFACE_LIBRARY type but target_link_libraries was called with non-INTERFACE keyword.",
  "signature_zh": "CMake 错误：目标 \"mylib\" 具有 INTERFACE_LIBRARY 类型，但 target_link_libraries 使用了非 INTERFACE 关键字。",
  "regex": "Target \".*\" has INTERFACE_LIBRARY type but target_link_libraries was called with non-INTERFACE keyword",
  "domain": "cmake",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "An INTERFACE library target can only be linked using INTERFACE keyword in target_link_libraries, but PUBLIC or PRIVATE was used instead.",
  "root_cause_type": "generic",
  "root_cause_zh": "INTERFACE 库目标只能使用 INTERFACE 关键字在 target_link_libraries 中链接，但使用了 PUBLIC 或 PRIVATE。",
  "versions": [
    {
      "version": "CMake 3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.18",
      "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": "",
      "why_fails": "INTERFACE libraries are meant for header-only or pure-interface targets; changing type alters build semantics and may require source files.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The dependency is required for consuming targets to find headers or propagate compile definitions.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace target_link_libraries(mylib PUBLIC some_dep) with target_link_libraries(mylib INTERFACE some_dep). Example: target_link_libraries(mylib INTERFACE some_dep).",
      "success_rate": 0.95,
      "how": "Replace target_link_libraries(mylib PUBLIC some_dep) with target_link_libraries(mylib INTERFACE some_dep). Example: target_link_libraries(mylib INTERFACE some_dep).",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the target should have source files, change its type to STATIC or SHARED: add_library(mylib STATIC source.cpp). Then use PUBLIC/PRIVATE as needed.",
      "success_rate": 0.8,
      "how": "If the target should have source files, change its type to STATIC or SHARED: add_library(mylib STATIC source.cpp). Then use PUBLIC/PRIVATE as needed.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将 target_link_libraries(mylib PUBLIC some_dep) 替换为 target_link_libraries(mylib INTERFACE some_dep)。示例：target_link_libraries(mylib INTERFACE some_dep)。",
    "如果目标应有源文件，将其类型更改为 STATIC 或 SHARED：add_library(mylib STATIC source.cpp)。然后根据需要使用 PUBLIC/PRIVATE。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/target_link_libraries.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}