diff --git a/implementations/Crafter.Build-External.cpp b/implementations/Crafter.Build-External.cpp index 4a9fbe2..d209a00 100644 --- a/implementations/Crafter.Build-External.cpp +++ b/implementations/Crafter.Build-External.cpp @@ -179,6 +179,19 @@ std::string ConfigureCMake(const fs::path& cloneDir, const fs::path& cmakeBuildD if (!needsConfigure) return ""; + // A build directory configured with other inputs starts over instead of + // being reconfigured. CMake reconfigures in place without recompiling + // what an old compiler or --sysroot compiled (the Makefiles generator + // writes --sysroot into build.make, which make does not compare) and + // keeps the check results the old configure cached. A mingw external + // built against the host's /usr as the sysroot (issue #43) kept its + // objects reading __libc_single_threaded after the fix that way. The + // directory keeps its name, which projects point generated headers at. + if (fs::exists(cmakeBuildDir / "CMakeCache.txt")) { + std::error_code ec; + fs::remove_all(cmakeBuildDir, ec); + if (ec) return std::format("cannot clear {} for a fresh configure: {}", cmakeBuildDir.string(), ec.message()); + } if (!fs::exists(cmakeBuildDir)) fs::create_directories(cmakeBuildDir); std::string cmd = std::format("cmake -S {} -B {}{}", ShellQuote(fs::absolute(cloneDir).string()), ShellQuote(fs::absolute(cmakeBuildDir).string()), injected);