# CMake Error: Found package version 1.2.3 but required version is 2.0.0 (found /usr/lib/cmake/MyPackage/MyPackageConfig.cmake)

- **ID:** `cmake/find-package-config-version-mismatch`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

find_package() found a package configuration file, but its version does not satisfy the version requirements specified in the call.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| cmake 3.20.0 | active | — | — |
| cmake 3.21.0 | active | — | — |
| cmake 3.22.0 | active | — | — |

## Workarounds

1. **Install a newer version of the package that meets the requirement. For example, on Ubuntu:

sudo apt-get install mypackage=2.0.0

Or build from source:

git clone https://github.com/example/mypackage.git -b v2.0.0
cd mypackage && mkdir build && cd build
cmake .. && sudo make install** (90% success)
   ```
   Install a newer version of the package that meets the requirement. For example, on Ubuntu:

sudo apt-get install mypackage=2.0.0

Or build from source:

git clone https://github.com/example/mypackage.git -b v2.0.0
cd mypackage && mkdir build && cd build
cmake .. && sudo make install
   ```
2. **Specify a lower version requirement in find_package if the API is backward-compatible:

find_package(MyPackage 1.2.3 REQUIRED)

Or use EXACT to pin to a specific version:

find_package(MyPackage 2.0.0 EXACT REQUIRED)** (85% success)
   ```
   Specify a lower version requirement in find_package if the API is backward-compatible:

find_package(MyPackage 1.2.3 REQUIRED)

Or use EXACT to pin to a specific version:

find_package(MyPackage 2.0.0 EXACT REQUIRED)
   ```

## Dead Ends

- **Delete the package config file and let CMake search again** — CMake will find the same file again if it's the only one; deleting it may break other projects that depend on it. (80% fail)
- **Modify MyPackageConfigVersion.cmake to report a higher version** — Tampering with version files causes silent runtime errors due to API incompatibility; dangerous and unsupported. (95% fail)
