# CMake Error: CUDA_ARCHITECTURES is empty for target "mytarget"

- **ID:** `cmake/cuda-architecture-unknown`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

CMake 3.18+ requires explicit CUDA architectures; when CMAKE_CUDA_ARCHITECTURES is not set or set to empty, compilation fails.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.18 | active | — | — |
| CMake 3.19 | active | — | — |
| CMake 3.20 | active | — | — |
| CMake 3.21 | active | — | — |
| CMake 3.22 | active | — | — |
| CMake 3.23 | active | — | — |
| CMake 3.24 | active | — | — |
| CMake 3.25 | active | — | — |
| CMake 3.26 | active | — | — |
| CMake 3.27 | active | — | — |
| CMake 3.28 | active | — | — |
| CMake 3.29 | active | — | — |
| CMake 3.30 | active | — | — |
| CUDA 11.0 | active | — | — |
| CUDA 11.8 | active | — | — |
| CUDA 12.0 | active | — | — |

## Workarounds

1. **Set CMAKE_CUDA_ARCHITECTURES globally before project() call: set(CMAKE_CUDA_ARCHITECTURES "75;80")** (90% success)
   ```
   Set CMAKE_CUDA_ARCHITECTURES globally before project() call: set(CMAKE_CUDA_ARCHITECTURES "75;80")
   ```
2. **Use target property: set_property(TARGET mytarget PROPERTY CUDA_ARCHITECTURES "75;80")** (85% success)
   ```
   Use target property: set_property(TARGET mytarget PROPERTY CUDA_ARCHITECTURES "75;80")
   ```
3. **Set environment variable: export CMAKE_CUDA_ARCHITECTURES=75;80 before running cmake** (75% success)
   ```
   Set environment variable: export CMAKE_CUDA_ARCHITECTURES=75;80 before running cmake
   ```

## Dead Ends

- **Setting CMAKE_CUDA_ARCHITECTURES to empty string in CMakeLists.txt** — CMake interprets empty string as no architectures specified, triggering the same error. (95% fail)
- **Removing all CUDA-related lines from CMakeLists.txt** — Without any architecture, CMake defaults to empty, causing the error. (80% fail)
- **Setting CMAKE_CUDA_ARCHITECTURES to 'all' on older CUDA versions** — 'all' may include unsupported architectures, leading to compilation failures. (60% fail)
