CMakeCache.txt directory is different C/C++ Origin: Application & API OSI layer 7 · Application Last updated 28 Nov 2026

CMake Error: The current CMakeCache.txt directory is different than the directory where CMakeCache.txt was created

The build folder was copied or moved.

Exact message you may see current CMakeCache.txt directory is differentCMakeCache.txt directory
Seen on: CMake

Meaning

CMake stores absolute paths in CMakeCache.txt. If you copy or rename a build folder, those paths are wrong and CMake refuses to continue instead of mixing two locations.

Common causes

  • build directory moved
  • Copied from another machine
  • Build folder committed or copied between machines

⚡ Quick fix

  1. rm -rf build then reconfigure
  2. Delete the whole build directory and configure again
  3. Keep build directories out of version control

Detailed fix by platform

Shell

  1. rm -rf build && cmake -S . -B build

How to diagnose

  1. Moved — Folder?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

CMake Error: CMAKE_C_COMPILER not set / No CMAKE_CXX_COMPILER could be found — CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles" (macOS)CMake Error: CMAKE_C_…Could not find a package configuration file — CMake Error: Could not find a package configuration file provided by "Foo" (requested version 1.2) (C/C++)Could not find a pack…does not appear to contain CMakeLists.txt — CMake Error: The source directory does not appear to contain CMakeLists.txt (C/C++)does not appear to co…Error: SHA256 mismatch (expected X, actual Y) — Error: SHA256 mismatch Expected: abc... Actual: def... File: /Users/me/Library/Caches/Homebrew/downloads/... (macOS)Error: SHA256 mismatc…No CMAKE_CXX_COMPILER could be found — CMake Error: No CMAKE_CXX_COMPILER could be found (C/C++)No CMAKE_CXX_COMPILER…target was not found — CMake Error: Target "app" links to target "Foo::Foo" but the target was not found (C/C++)target was not foundCMakeCach…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.