# CMake Error: Cannot find source file: /path/to/src/module.cpp. Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx .f .f90 .F .F90 .s .S .asm

- **ID:** `cmake/source-file-not-found-alternate-extensions`
- **Domain:** cmake
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The source file listed in add_executable() or add_library() does not exist on disk. Common causes: file was moved, renamed, deleted, or the path is relative to a wrong directory.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.20 | active | — | — |
| 3.22 | active | — | — |
| 3.24 | active | — | — |
| 3.26 | active | — | — |
| 3.28 | active | — | — |

## Workarounds

1. **Verify the file exists at the exact path. Use absolute paths or correct relative paths from CMAKE_CURRENT_SOURCE_DIR. Example:
  set(MY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/module.cpp)
  add_executable(myapp ${MY_SRC})** (90% success)
   ```
   Verify the file exists at the exact path. Use absolute paths or correct relative paths from CMAKE_CURRENT_SOURCE_DIR. Example:
  set(MY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/module.cpp)
  add_executable(myapp ${MY_SRC})
   ```
2. **If the file was moved, update the CMakeLists.txt to point to the new location. Run 'cmake --build . --clean-first' after fixing.** (85% success)
   ```
   If the file was moved, update the CMakeLists.txt to point to the new location. Run 'cmake --build . --clean-first' after fixing.
   ```
3. **If using generated files, ensure they are generated before the target is defined. Use add_custom_command with OUTPUT and add the output to the target's sources.** (80% success)
   ```
   If using generated files, ensure they are generated before the target is defined. Use add_custom_command with OUTPUT and add the output to the target's sources.
   ```

## Dead Ends

- **** — The stale CMake cache may still reference the old path, causing the same error. A full reconfigure is needed. (60% fail)
- **** — The error is about a missing source file, not about target existence. Adding to another target doesn't create the missing file. (90% fail)
- **** — If the file doesn't exist on disk, no extension change will help. The file must be present and the path must match exactly. (75% fail)
