cmake: Friendlier message when trying to --build the wrong dir

Also for --open.

Fixes: #11166
This commit is contained in:
Nikita Nemkin
2025-02-07 15:00:52 +05:00
committed by Brad King
parent d567d38ba0
commit ddf7ebe06e
3 changed files with 6 additions and 4 deletions

View File

@@ -3850,7 +3850,8 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
std::string cachePath = FindCacheFile(dir);
if (!this->LoadCache(cachePath)) {
std::cerr << "Error: could not load cache\n";
std::cerr
<< "Error: not a CMake build directory (missing CMakeCache.txt)\n";
return 1;
}
cmValue cachedGenerator = this->State->GetCacheEntryValue("CMAKE_GENERATOR");
@@ -3979,7 +3980,8 @@ bool cmake::Open(std::string const& dir, bool dryRun)
std::string cachePath = FindCacheFile(dir);
if (!this->LoadCache(cachePath)) {
std::cerr << "Error: could not load cache\n";
std::cerr
<< "Error: not a CMake build directory (missing CMakeCache.txt)\n";
return false;
}
cmValue genName = this->State->GetCacheEntryValue("CMAKE_GENERATOR");

View File

@@ -1 +1 @@
^Error: could not load cache
^Error: not a CMake build directory \(missing CMakeCache\.txt\)$

View File

@@ -1 +1 @@
^Error: could not load cache$
^Error: not a CMake build directory \(missing CMakeCache\.txt\)$