{
  "id": "cmake/target-links-interface-libraries-with-non-interface-keyword",
  "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": "CMake Error: Target '[^']+' has INTERFACE_LIBRARY type but target_link_libraries was called with non-INTERFACE keyword",
  "domain": "cmake",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A target defined as INTERFACE (header-only) library must only use INTERFACE keyword in target_link_libraries, but PRIVATE or PUBLIC was used.",
  "root_cause_type": "generic",
  "root_cause_zh": "定义为INTERFACE（仅头文件）库的目标必须在target_link_libraries中仅使用INTERFACE关键字，但使用了PRIVATE或PUBLIC。",
  "versions": [
    {
      "version": "CMake 3.20",
      "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.28",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Change the target type to STATIC or SHARED",
      "why_fails": "Changing target type may break the build if the library is meant to be header-only.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use PUBLIC keyword but add dummy source files",
      "why_fails": "PUBLIC is still not allowed for INTERFACE libraries; only INTERFACE keyword is valid.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove all target_link_libraries calls",
      "why_fails": "This may lose necessary link dependencies for consumers of the header-only library.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace PUBLIC with INTERFACE in target_link_libraries for the INTERFACE library",
      "success_rate": 1.0,
      "how": "Replace PUBLIC with INTERFACE in target_link_libraries for the INTERFACE library",
      "condition": "",
      "sources": []
    },
    {
      "action": "Convert the INTERFACE library to a STATIC library with a dummy source file if link dependencies are needed",
      "success_rate": 0.8,
      "how": "Convert the INTERFACE library to a STATIC library with a dummy source file if link dependencies are needed",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use target_link_options instead of target_link_libraries for compiler-specific flags",
      "success_rate": 0.7,
      "how": "Use target_link_options instead of target_link_libraries for compiler-specific flags",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Replace PUBLIC with INTERFACE in target_link_libraries for the INTERFACE library",
    "Convert the INTERFACE library to a STATIC library with a dummy source file if link dependencies are needed",
    "Use target_link_options instead of target_link_libraries for compiler-specific flags"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}