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

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

## Root Cause

A target listed in install(EXPORT ...) was not previously registered with install(TARGETS ...) for that export set.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.14 | active | — | — |
| CMake 3.16 | active | — | — |
| CMake 3.22 | active | — | — |
| CMake 3.27 | active | — | — |

## Workarounds

1. **Ensure every target in install(EXPORT ...) is also installed with install(TARGETS ... EXPORT ...) using the same export set name.** (90% success)
   ```
   Ensure every target in install(EXPORT ...) is also installed with install(TARGETS ... EXPORT ...) using the same export set name.
   ```
2. **If the target is header-only, use install(TARGETS mylib EXPORT MyTargets) with an INTERFACE library.** (85% success)
   ```
   If the target is header-only, use install(TARGETS mylib EXPORT MyTargets) with an INTERFACE library.
   ```

## Dead Ends

- **Adding the target to the export set by adding it to install(EXPORT ...) without install(TARGETS ...)** — The target must be explicitly installed with install(TARGETS ...) first; just listing it in install(EXPORT ...) does not register it. (95% fail)
- **Removing the target from the export list, assuming it's not needed** — If the target is required by downstream projects, removing it breaks the export and causes missing dependencies. (70% fail)
- **Using install(TARGETS ... EXPORT MyTargets) but misspelling the export set name** — Mismatched export set names cause the target to be registered under a different set, leading to the same error. (80% fail)
