# CMake Error: Target "mylib" has INTERFACE_LIBRARY type but target_link_libraries was called with non-INTERFACE keyword.

- **ID:** `cmake/target-link-libraries-interface-mismatch`
- **Domain:** cmake
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

An INTERFACE library target can only be linked using INTERFACE keyword in target_link_libraries, but PUBLIC or PRIVATE was used instead.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.12 | active | — | — |
| CMake 3.18 | active | — | — |
| CMake 3.27 | active | — | — |

## Workarounds

1. **Replace target_link_libraries(mylib PUBLIC some_dep) with target_link_libraries(mylib INTERFACE some_dep). Example: target_link_libraries(mylib INTERFACE some_dep).** (95% success)
   ```
   Replace target_link_libraries(mylib PUBLIC some_dep) with target_link_libraries(mylib INTERFACE some_dep). Example: target_link_libraries(mylib INTERFACE some_dep).
   ```
2. **If the target should have source files, change its type to STATIC or SHARED: add_library(mylib STATIC source.cpp). Then use PUBLIC/PRIVATE as needed.** (80% success)
   ```
   If the target should have source files, change its type to STATIC or SHARED: add_library(mylib STATIC source.cpp). Then use PUBLIC/PRIVATE as needed.
   ```

## Dead Ends

- **** — INTERFACE libraries are meant for header-only or pure-interface targets; changing type alters build semantics and may require source files. (85% fail)
- **** — The dependency is required for consuming targets to find headers or propagate compile definitions. (95% fail)
