{
  "id": "cmake/interface-library-sources-ignored",
  "signature": "CMake Error: INTERFACE_LIBRARY targets may only have INTERFACE properties. The SOURCES property of target \"mylib\" is not allowed.",
  "signature_zh": "CMake 错误：INTERFACE_LIBRARY 目标只能具有 INTERFACE 属性。目标 \"mylib\" 的 SOURCES 属性是不允许的。",
  "regex": "CMake Error: INTERFACE_LIBRARY targets may only have INTERFACE properties\\. The SOURCES property of target \".*\" is not allowed\\.",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Attempting to set source files on an INTERFACE library target, which by definition cannot have compile sources.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在 INTERFACE 库目标上设置源文件，而根据定义，INTERFACE 库不能有编译源文件。",
  "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 SOURCES property with set_property(TARGET mylib PROPERTY SOURCES ...) to work around the error",
      "why_fails": "INTERFACE libraries are header-only or pure-interface; they have no compiled sources, so setting SOURCES violates the target type.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing the target type to STATIC or SHARED but keeping the same interface logic",
      "why_fails": "Changing target type changes the build semantics; INTERFACE libraries are intended for header-only or transitive dependencies, not compiled code.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Deleting the target entirely and re-adding it with sources as a different target",
      "why_fails": "This loses the interface propagation properties and may break dependency chains.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove SOURCES from the INTERFACE library. If you need compiled sources, use add_library(mylib STATIC ...) or add_library(mylib SHARED ...) instead.",
      "success_rate": 0.9,
      "how": "Remove SOURCES from the INTERFACE library. If you need compiled sources, use add_library(mylib STATIC ...) or add_library(mylib SHARED ...) instead.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need both interface properties and compiled sources, create two targets: an INTERFACE library for headers and a STATIC/SHARED library for sources, then link them.",
      "success_rate": 0.85,
      "how": "If you need both interface properties and compiled sources, create two targets: an INTERFACE library for headers and a STATIC/SHARED library for sources, then link them.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove SOURCES from the INTERFACE library. If you need compiled sources, use add_library(mylib STATIC ...) or add_library(mylib SHARED ...) instead.",
    "If you need both interface properties and compiled sources, create two targets: an INTERFACE library for headers and a STATIC/SHARED library for sources, then link them."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#interface-libraries",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}