# 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-version-inequality`
- **Domain:** cmake
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

find_package() with EXACT or version range finds a package configuration file whose version does not satisfy the required version constraint, often due to multiple installed versions or incorrect version specification.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.10 | active | — | — |
| CMake 3.16 | active | — | — |
| CMake 3.24 | active | — | — |

## Workarounds

1. **Install the required version of the package, e.g., `apt-get install mypackage=2.0.0` or build from source, then clean the CMake cache with `rm -rf CMakeCache.txt CMakeFiles/`.** (90% success)
   ```
   Install the required version of the package, e.g., `apt-get install mypackage=2.0.0` or build from source, then clean the CMake cache with `rm -rf CMakeCache.txt CMakeFiles/`.
   ```
2. **Use `find_package(MyPackage 2.0.0 EXACT)` only if the exact version is required, or remove EXACT and allow compatible versions if the API is backward-compatible.** (85% success)
   ```
   Use `find_package(MyPackage 2.0.0 EXACT)` only if the exact version is required, or remove EXACT and allow compatible versions if the API is backward-compatible.
   ```
3. **Set `set(MyPackage_DIR "/path/to/correct/version")` before find_package() to force CMake to search the specific directory containing the desired version.** (80% success)
   ```
   Set `set(MyPackage_DIR "/path/to/correct/version")` before find_package() to force CMake to search the specific directory containing the desired version.
   ```

## Dead Ends

- **Omitting version argument in find_package()** — Removing the version requirement from find_package() may allow the build to proceed but could cause runtime incompatibilities with the older library. (80% fail)
- **Modifying the package's Version.cmake file to report a fake version** — Manually editing the package's version file to report a higher version may bypass the error but corrupts the package's metadata. (95% fail)
- **Changing CMAKE_FIND_PACKAGE_SORT_DIRECTION** — Setting CMAKE_FIND_PACKAGE_SORT_DIRECTION to DEC may change the order of found packages but does not solve version mismatch if only one version is installed. (70% fail)
