{
  "id": "cmake/cuda-architectures-empty-with-cuda-language",
  "signature": "CMake Error: CUDA_ARCHITECTURES is empty for target \"mytarget\". This is not allowed when enabling CUDA language.",
  "signature_zh": "CMake 错误：目标“mytarget”的 CUDA_ARCHITECTURES 为空。启用 CUDA 语言时不允许这样做。",
  "regex": "CUDA_ARCHITECTURES is empty for target \".*\"",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "When project() enables CUDA (e.g., enable_language(CUDA) or project(MyProject LANGUAGES CUDA)), CMake requires setting CUDA_ARCHITECTURES for each target to specify GPU architecture, but it is left empty.",
  "root_cause_type": "generic",
  "root_cause_zh": "当 project() 启用 CUDA（例如 enable_language(CUDA) 或 project(MyProject LANGUAGES CUDA)）时，CMake 要求为每个目标设置 CUDA_ARCHITECTURES 来指定 GPU 架构，但该值为空。",
  "versions": [
    {
      "version": "cmake 3.18",
      "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.26",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Setting CMAKE_CUDA_ARCHITECTURES to empty string hoping CMake picks a default",
      "why_fails": "CMake treats empty string the same as unset, still triggering the error.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disabling CUDA language completely by removing it from project()",
      "why_fails": "This may break compilation if the project uses CUDA source files (.cu), leading to 'unknown file type' errors.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set CUDA_ARCHITECTURES on the target: set_property(TARGET mytarget PROPERTY CUDA_ARCHITECTURES \"75;80\") or set(CMAKE_CUDA_ARCHITECTURES \"75;80\") globally before add_executable/add_library.",
      "success_rate": 0.95,
      "how": "Set CUDA_ARCHITECTURES on the target: set_property(TARGET mytarget PROPERTY CUDA_ARCHITECTURES \"75;80\") or set(CMAKE_CUDA_ARCHITECTURES \"75;80\") globally before add_executable/add_library.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you don't care about specific architectures, set it to native: set(CMAKE_CUDA_ARCHITECTURES \"native\") in CMakeLists.txt.",
      "success_rate": 0.85,
      "how": "If you don't care about specific architectures, set it to native: set(CMAKE_CUDA_ARCHITECTURES \"native\") in CMakeLists.txt.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在目标上设置 CUDA_ARCHITECTURES：set_property(TARGET mytarget PROPERTY CUDA_ARCHITECTURES \"75;80\")，或者在 add_executable/add_library 之前全局设置 set(CMAKE_CUDA_ARCHITECTURES \"75;80\")。",
    "如果不在意特定架构，设置为 native：在 CMakeLists.txt 中 set(CMAKE_CUDA_ARCHITECTURES \"native\")。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-06-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}