# CMake Error: Error evaluating generator expression:
    $<TARGET_FILE:mylib>
  The expression does not start with a generator expression token.

- **ID:** `cmake/generator-expression-missing-dollar`
- **Domain:** cmake
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A generator expression was used outside of a context that supports them (e.g., in a regular set() command or a comment), or the expression is malformed (missing leading $).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| cmake 3.18 | active | — | — |
| cmake 3.22 | active | — | — |
| cmake 3.26 | active | — | — |
| cmake 3.30 | active | — | — |

## Workarounds

1. **Move the generator expression into a target property or a command that supports it, e.g., target_compile_definitions(mylib PRIVATE "$<TARGET_FILE:mylib>")** (85% success)
   ```
   Move the generator expression into a target property or a command that supports it, e.g., target_compile_definitions(mylib PRIVATE "$<TARGET_FILE:mylib>")
   ```
2. **If used in a file write, use file(GENERATE ...) with the expression: file(GENERATE OUTPUT output.txt CONTENT "$<TARGET_FILE:mylib>")** (90% success)
   ```
   If used in a file write, use file(GENERATE ...) with the expression: file(GENERATE OUTPUT output.txt CONTENT "$<TARGET_FILE:mylib>")
   ```

## Dead Ends

- **** — Generator expressions are not shell variables; escaping breaks the syntax. (50% fail)
- **** — message() does not evaluate generator expressions at configure time; use file(GENERATE) instead. (70% fail)
