{
  "id": "cmake/add-executable-no-sources",
  "signature": "CMake Error: add_executable cannot create target \"myapp\" because no source files were specified.",
  "signature_zh": "CMake 错误：add_executable 无法创建目标 \"myapp\"，因为没有指定源文件。",
  "regex": "CMake Error: add_executable cannot create target \".*\" because no source files were specified\\.",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The add_executable command was called without any source file arguments, either due to a missing variable expansion or an empty list.",
  "root_cause_type": "generic",
  "root_cause_zh": "add_executable 命令在未指定任何源文件参数的情况下被调用，可能是由于变量展开缺失或列表为空。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.26",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding a dummy source file like 'main.cpp' without checking if it exists",
      "why_fails": "If the file does not exist, CMake will later fail with 'Cannot find source file'. The root cause (empty variable) remains unaddressed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the add_executable call entirely and relying on add_library",
      "why_fails": "The project needs an executable target; removing it breaks the build logic, and the error shifts to missing target.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting CMAKE_MINIMUM_REQUIRED to a lower version",
      "why_fails": "The error is not version-dependent; it is a syntax/argument error that is caught at parse time regardless of CMake version.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check the variable that holds source files: message(STATUS \"SOURCES=${SOURCES}\") before add_executable. Ensure it is not empty. For example, if SOURCES is set via file(GLOB ...), verify the glob pattern matches files.",
      "success_rate": 0.95,
      "how": "Check the variable that holds source files: message(STATUS \"SOURCES=${SOURCES}\") before add_executable. Ensure it is not empty. For example, if SOURCES is set via file(GLOB ...), verify the glob pattern matches files.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Explicitly list source files in add_executable: add_executable(myapp main.cpp utils.cpp). Avoid using empty variables.",
      "success_rate": 0.9,
      "how": "Explicitly list source files in add_executable: add_executable(myapp main.cpp utils.cpp). Avoid using empty variables.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a macro or function, ensure arguments are passed correctly: function(my_add_executable name) add_executable(${name} ${ARGN}) endfunction(). Call with at least one source.",
      "success_rate": 0.85,
      "how": "If using a macro or function, ensure arguments are passed correctly: function(my_add_executable name) add_executable(${name} ${ARGN}) endfunction(). Call with at least one source.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "检查保存源文件的变量：在 add_executable 之前添加 message(STATUS \"SOURCES=${SOURCES}\")。确保它不为空。例如，如果 SOURCES 是通过 file(GLOB ...) 设置的，请验证 glob 模式与文件匹配。",
    "在 add_executable 中显式列出源文件：add_executable(myapp main.cpp utils.cpp)。避免使用空变量。",
    "如果使用宏或函数，请确保正确传递参数：function(my_add_executable name) add_executable(${name} ${ARGN}) endfunction()。调用时至少提供一个源文件。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/add_executable.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}