# CMake Error: CPack component "runtime" has version 1.0.0 but component "headers" has version 2.0.0. All components must have the same version.

- **ID:** `cmake/cpack-component-version-mismatch`
- **Domain:** cmake
- **Category:** install_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

When using CPack with components, each component's version must match the project version; a mismatch occurs when CPACK_COMPONENT_<compName>_VERSION is set inconsistently across components.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.10 | active | — | — |
| CMake 3.18 | active | — | — |
| CPack 3.20 | active | — | — |

## Workarounds

1. **Set all component versions to the same value, e.g., `set(CPACK_COMPONENT_RUNTIME_VERSION "2.0.0")` and `set(CPACK_COMPONENT_HEADERS_VERSION "2.0.0")` to match the project version.** (90% success)
   ```
   Set all component versions to the same value, e.g., `set(CPACK_COMPONENT_RUNTIME_VERSION "2.0.0")` and `set(CPACK_COMPONENT_HEADERS_VERSION "2.0.0")` to match the project version.
   ```
2. **Remove explicit version settings for components and rely on the project version by not setting any CPACK_COMPONENT_*_VERSION variables.** (85% success)
   ```
   Remove explicit version settings for components and rely on the project version by not setting any CPACK_COMPONENT_*_VERSION variables.
   ```
3. **Use `set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON)` to combine all components into a single package, bypassing version checks.** (80% success)
   ```
   Use `set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON)` to combine all components into a single package, bypassing version checks.
   ```

## Dead Ends

- **Deleting all CPACK_COMPONENT_*_VERSION variables** — Removing version specifications from all components may default to the project version, but CPack may still fail if any component has an explicit version set elsewhere. (70% fail)
- **Setting only CPACK_PACKAGE_VERSION without adjusting component versions** — Setting a global CPACK_PACKAGE_VERSION may not override component-specific versions, leading to persistent mismatches. (80% fail)
- **Disabling component grouping in CPack** — Using CPack without components (GROUPING IGNORE) may suppress the error but creates a monolithic package that defeats the purpose of component-based installation. (75% fail)
