# CMake 错误：目标 "mycudatarget" 的 CUDA_ARCHITECTURES 为空

- **ID:** `cmake/cuda-architectures-empty`
- **领域:** cmake
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

CMake 3.18+ 要求为所有启用 CUDA 的目标设置 CUDA_ARCHITECTURES；空值或未设置变量会触发此错误，以防止不支持的架构代码。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CMake 3.18 | active | — | — |
| CMake 3.19 | active | — | — |
| CMake 3.20 | active | — | — |

## 解决方案

1. ```
   set_target_properties(mycudatarget PROPERTIES CUDA_ARCHITECTURES "75;80")
# Or use the native arch detection:
set(CMAKE_CUDA_ARCHITECTURES "native")
   ```
2. ```
   set(CMAKE_CUDA_ARCHITECTURES "75;80")
add_library(mycudatarget CUDA mycuda.cu)
   ```

## 无效尝试

- **** — CMake interprets OFF as an empty string, still triggering the error. (100% 失败率)
- **** — An empty string is still empty; CMake requires a non-empty list of architectures. (100% 失败率)
