summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx45
1 files changed, 36 insertions, 9 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7de488b..a8dc963 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -565,10 +565,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
"No install directory specified for --install-prefix",
CommandArgument::Values::One, PrefixLambda },
CommandArgument{ "--find-package", CommandArgument::Values::Zero,
- [&](std::string const&, cmake*) -> bool {
- findPackageMode = true;
- return true;
- } },
+ CommandArgument::setToTrue(findPackageMode) },
};
for (decltype(args.size()) i = 1; i < args.size(); ++i) {
std::string const& arg = args[i];
@@ -868,13 +865,15 @@ void cmake::SetArgs(const std::vector<std::string>& args)
CommandArgument{ "-B", "No build directory specified for -B",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No, BuildArgLambda },
+ CommandArgument{ "--fresh", CommandArgument::Values::Zero,
+ [](std::string const&, cmake* cm) -> bool {
+ cm->FreshCache = true;
+ return true;
+ } },
CommandArgument{ "-P", "-P must be followed by a file name.",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No,
- [&](std::string const&, cmake*) -> bool {
- scriptMode = true;
- return true;
- } },
+ CommandArgument::setToTrue(scriptMode) },
CommandArgument{ "-D", "-D must be followed with VAR=VALUE.",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No,
@@ -1158,6 +1157,12 @@ void cmake::SetArgs(const std::vector<std::string>& args)
// iterate each argument
std::string const& arg = args[i];
+ if (scriptMode && arg == "--") {
+ // Stop processing CMake args and avoid possible errors
+ // when arbitrary args are given to CMake script.
+ break;
+ }
+
// Generator flag has special handling for when to print help
// so it becomes the exception
if (generatorCommand.matches(arg)) {
@@ -1455,7 +1460,7 @@ void cmake::PrintTraceFormatVersion()
Json::StreamWriterBuilder builder;
builder["indentation"] = "";
version["major"] = 1;
- version["minor"] = 1;
+ version["minor"] = 2;
val["version"] = version;
msg = Json::writeString(builder, val);
#endif
@@ -2098,6 +2103,21 @@ int cmake::ActualConfigure()
cmStateEnums::INTERNAL);
}
+ // We want to create the package redirects directory as early as possible,
+ // but not before pre-configure checks have passed. This ensures we get
+ // errors about inappropriate source/binary directories first.
+ const auto redirectsDir =
+ cmStrCat(this->GetHomeOutputDirectory(), "/CMakeFiles/pkgRedirects");
+ cmSystemTools::RemoveADirectory(redirectsDir);
+ if (!cmSystemTools::MakeDirectory(redirectsDir)) {
+ cmSystemTools::Error(
+ "Unable to (re)create the private pkgRedirects directory:\n" +
+ redirectsDir);
+ return -1;
+ }
+ this->AddCacheEntry("CMAKE_FIND_PACKAGE_REDIRECTS_DIR", redirectsDir,
+ "Value Computed by CMake.", cmStateEnums::STATIC);
+
// no generator specified on the command line
if (!this->GlobalGenerator) {
cmValue genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
@@ -2398,12 +2418,19 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
}
if (this->GetWorkingMode() == NORMAL_MODE) {
+ if (this->FreshCache) {
+ this->DeleteCache(this->GetHomeOutputDirectory());
+ }
// load the cache
if (this->LoadCache() < 0) {
cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
return -1;
}
} else {
+ if (this->FreshCache) {
+ cmSystemTools::Error("--fresh allowed only when configuring a project");
+ return -1;
+ }
this->AddCMakePaths();
}