{
  "id": "cmake/find-package-version-inequality",
  "signature": "CMake Error: Found package version 1.2.3 but required version is 2.0.0 (found /usr/lib/cmake/MyPackage/MyPackageConfig.cmake).",
  "signature_zh": "CMake 错误：找到的包版本为 1.2.3，但所需版本为 2.0.0（位于 /usr/lib/cmake/MyPackage/MyPackageConfig.cmake）。",
  "regex": "Found package version [0-9.]+ but required version is [0-9.]+",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用 EXACT 或版本范围的 find_package() 找到了不满足所需版本约束的包配置文件，通常是由于安装了多个版本或版本指定不正确。",
  "versions": [
    {
      "version": "CMake 3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.24",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Omitting version argument in find_package()",
      "why_fails": "Removing the version requirement from find_package() may allow the build to proceed but could cause runtime incompatibilities with the older library.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Modifying the package's Version.cmake file to report a fake version",
      "why_fails": "Manually editing the package's version file to report a higher version may bypass the error but corrupts the package's metadata.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing CMAKE_FIND_PACKAGE_SORT_DIRECTION",
      "why_fails": "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.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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/`.",
      "success_rate": 0.9,
      "how": "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/`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set `set(MyPackage_DIR \"/path/to/correct/version\")` before find_package() to force CMake to search the specific directory containing the desired version.",
      "success_rate": 0.8,
      "how": "Set `set(MyPackage_DIR \"/path/to/correct/version\")` before find_package() to force CMake to search the specific directory containing the desired version.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "安装所需版本的包，例如 `apt-get install mypackage=2.0.0` 或从源码构建，然后使用 `rm -rf CMakeCache.txt CMakeFiles/` 清理 CMake 缓存。",
    "仅在需要精确版本时使用 `find_package(MyPackage 2.0.0 EXACT)`，或者如果 API 向后兼容，则移除 EXACT 以允许兼容版本。",
    "在 find_package() 之前设置 `set(MyPackage_DIR \"/path/to/correct/version\")`，强制 CMake 搜索包含所需版本的特定目录。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/find_package.html#version-selection",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2024-03-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}