# CMake Error: install(EXPORT "MyTargets") includes target "mylib" which is not in the export set.

- **ID:** `cmake/export-import-target-not-found`
- **Domain:** cmake
- **Category:** install_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

An install(EXPORT) command references a target that was not previously registered with install(TARGETS) and the same EXPORT name.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.10 | active | — | — |
| CMake 3.15 | active | — | — |
| CMake 3.22 | active | — | — |

## Workarounds

1. **Ensure the target is installed with the same EXPORT name: install(TARGETS mylib EXPORT MyTargets DESTINATION lib). Then install(EXPORT MyTargets DESTINATION lib/cmake). Example: install(TARGETS mylib EXPORT MyTargets DESTINATION lib) and install(EXPORT MyTargets DESTINATION lib/cmake/MyProject).** (95% success)
   ```
   Ensure the target is installed with the same EXPORT name: install(TARGETS mylib EXPORT MyTargets DESTINATION lib). Then install(EXPORT MyTargets DESTINATION lib/cmake). Example: install(TARGETS mylib EXPORT MyTargets DESTINATION lib) and install(EXPORT MyTargets DESTINATION lib/cmake/MyProject).
   ```
2. **If the target should not be exported, remove it from the install(EXPORT) call or create a separate export set for it.** (85% success)
   ```
   If the target should not be exported, remove it from the install(EXPORT) call or create a separate export set for it.
   ```

## Dead Ends

- **** — CMake uses the EXPORT name to group targets; mismatched names cause the target to be omitted from the set. (90% fail)
- **** — Without the export, other projects cannot use find_package to locate the installed targets. (95% fail)
