# CMake Error: CMake Error in CMakeLists.txt: Unknown CMake command "my_custom_function".

- **ID:** `cmake/unknown-cmake-command`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

A CMakeLists.txt calls a function or macro that is not defined, due to a missing include, typo, or unsupported module.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| cmake 2.8 | active | — | — |
| cmake 3.0 | active | — | — |
| cmake 3.16 | active | — | — |
| cmake 3.28 | active | — | — |

## Workarounds

1. **Check for typos: ensure the command is spelled correctly (e.g., 'target_link_libraries' not 'target_link_library').** (95% success)
   ```
   Check for typos: ensure the command is spelled correctly (e.g., 'target_link_libraries' not 'target_link_library').
   ```
2. **If the command is from a custom module, add include(MyModule) before the call, or use include(path/to/module.cmake).** (90% success)
   ```
   If the command is from a custom module, add include(MyModule) before the call, or use include(path/to/module.cmake).
   ```
3. **If the command is from an older CMake version, upgrade CMake or use a compatibility wrapper: cmake_minimum_required(VERSION 3.10).** (80% success)
   ```
   If the command is from an older CMake version, upgrade CMake or use a compatibility wrapper: cmake_minimum_required(VERSION 3.10).
   ```

## Dead Ends

- **Typing the command name in a different case (e.g., 'My_Function' vs 'my_function')** — CMake commands are case-insensitive but must match exactly; case issues rarely cause this error. (30% fail)
- **Adding the command as a comment to suppress the error** — Comments are ignored; the command must be defined or removed. (100% fail)
- **Installing a third-party module without including it** — The module must be included with include() or find_package() before use. (80% fail)
