{
  "id": "cmake/interface-library-sources-property",
  "signature": "CMake Error: INTERFACE_LIBRARY targets may only have INTERFACE properties. The SOURCES property of target \"mylib\" is not INTERFACE.",
  "signature_zh": "CMake 错误：INTERFACE_LIBRARY 目标只能包含 INTERFACE 属性。目标 \"mylib\" 的 SOURCES 属性不是 INTERFACE 类型。",
  "regex": "CMake Error: INTERFACE_LIBRARY targets may only have INTERFACE properties\\. The SOURCES property of target \".*\" is not INTERFACE\\.",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "An INTERFACE library target was mistakenly given source files via set_target_properties or add_library with source arguments, which is not allowed because INTERFACE libraries are header-only and have no build artifacts.",
  "root_cause_type": "generic",
  "root_cause_zh": "INTERFACE 库目标被错误地通过 set_target_properties 或 add_library 赋予源文件参数，这是不允许的，因为 INTERFACE 库是仅头文件的，没有构建产物。",
  "versions": [
    {
      "version": "CMake 3.10+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.20+",
      "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": "Adding SOURCES property via set_property with INTERFACE scope",
      "why_fails": "The SOURCES property is inherently non-INTERFACE; even setting it as INTERFACE fails because CMake rejects it for INTERFACE libraries.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing library type to STATIC and linking sources",
      "why_fails": "This changes the library's purpose and may break header-only design, causing unnecessary compilation and link errors.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the error and using add_library with sources anyway",
      "why_fails": "CMake will abort the configuration; the build cannot proceed without fixing the target definition.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove source files from add_library call and use target_sources with INTERFACE scope if needed, or convert to a STATIC library if sources are required.",
      "success_rate": 0.85,
      "how": "Remove source files from add_library call and use target_sources with INTERFACE scope if needed, or convert to a STATIC library if sources are required.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Define the target as an OBJECT library if you need to collect object files, then link with other targets.",
      "success_rate": 0.75,
      "how": "Define the target as an OBJECT library if you need to collect object files, then link with other targets.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use target_include_directories with INTERFACE scope to propagate headers without sources.",
      "success_rate": 0.9,
      "how": "Use target_include_directories with INTERFACE scope to propagate headers without sources.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove source files from add_library call and use target_sources with INTERFACE scope if needed, or convert to a STATIC library if sources are required.",
    "Define the target as an OBJECT library if you need to collect object files, then link with other targets.",
    "Use target_include_directories with INTERFACE scope to propagate headers without sources."
  ],
  "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.85,
  "resolvable": "true",
  "first_seen": "2023-05-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}