# CMake Error: INTERFACE_LIBRARY targets may only have INTERFACE properties. The SOURCES property of target "mylib" is not INTERFACE.

- **ID:** `cmake/interface-library-sources-property`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

An INTERFACE library target was mistakenly given source files via set_target_properties or add_library with source arguments, which is not allowed because INTERFACE libraries are header-only and have no build artifacts.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.10+ | active | — | — |
| CMake 3.20+ | active | — | — |
| CMake 3.28+ | active | — | — |

## Workarounds

1. **Remove source files from add_library call and use target_sources with INTERFACE scope if needed, or convert to a STATIC library if sources are required.** (85% success)
   ```
   Remove source files from add_library call and use target_sources with INTERFACE scope if needed, or convert to a STATIC library if sources are required.
   ```
2. **Define the target as an OBJECT library if you need to collect object files, then link with other targets.** (75% success)
   ```
   Define the target as an OBJECT library if you need to collect object files, then link with other targets.
   ```
3. **Use target_include_directories with INTERFACE scope to propagate headers without sources.** (90% success)
   ```
   Use target_include_directories with INTERFACE scope to propagate headers without sources.
   ```

## Dead Ends

- **Adding SOURCES property via set_property with INTERFACE scope** — The SOURCES property is inherently non-INTERFACE; even setting it as INTERFACE fails because CMake rejects it for INTERFACE libraries. (95% fail)
- **Changing library type to STATIC and linking sources** — This changes the library's purpose and may break header-only design, causing unnecessary compilation and link errors. (70% fail)
- **Ignoring the error and using add_library with sources anyway** — CMake will abort the configuration; the build cannot proceed without fixing the target definition. (100% fail)
