diff options
Diffstat (limited to 'Source/cmake.cxx')
| -rw-r--r-- | Source/cmake.cxx | 57 | 
1 files changed, 49 insertions, 8 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b47155e..1c1cab3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -861,6 +861,11 @@ 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, @@ -1077,6 +1082,14 @@ void cmake::SetArgs(const std::vector<std::string>& args)                    << "uninitialized variables.\n";          state->SetCheckSystemVars(true);          return true; +      } }, +    CommandArgument{ +      "--compile-no-warning-as-error", CommandArgument::Values::Zero, +      [](std::string const&, cmake* state) -> bool { +        std::cout << "Ignoring COMPILE_WARNING_AS_ERROR target property and " +                  << "CMAKE_COMPILE_WARNING_AS_ERROR variable.\n"; +        state->SetIgnoreWarningAsError(true); +        return true;        } }    }; @@ -1148,6 +1161,12 @@ void cmake::SetArgs(const std::vector<std::string>& args)      // iterate each argument      std::string const& arg = args[i]; +    if (this->GetWorkingMode() == SCRIPT_MODE && 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)) { @@ -1445,7 +1464,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 @@ -1980,7 +1999,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)    }    cmSystemTools::Message(warning.str());    // avoid reconfigure if there were errors -  if (!cmSystemTools::GetErrorOccuredFlag()) { +  if (!cmSystemTools::GetErrorOccurredFlag()) {      // re-run configure      return this->Configure();    } @@ -2089,6 +2108,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"); @@ -2250,7 +2284,7 @@ int cmake::ActualConfigure()    this->State->SaveVerificationScript(this->GetHomeOutputDirectory(),                                        this->Messenger.get());    this->SaveCache(this->GetHomeOutputDirectory()); -  if (cmSystemTools::GetErrorOccuredFlag()) { +  if (cmSystemTools::GetErrorOccurredFlag()) {      return -1;    }    return 0; @@ -2364,7 +2398,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)  {    // Process the arguments    this->SetArgs(args); -  if (cmSystemTools::GetErrorOccuredFlag()) { +  if (cmSystemTools::GetErrorOccurredFlag()) {      return -1;    }    if (this->GetWorkingMode() == HELP_MODE) { @@ -2389,12 +2423,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();    } @@ -2414,7 +2455,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)    // In script mode we terminate after running the script.    if (this->GetWorkingMode() != NORMAL_MODE) { -    if (cmSystemTools::GetErrorOccuredFlag()) { +    if (cmSystemTools::GetErrorOccurredFlag()) {        return -1;      }      return 0; @@ -2488,7 +2529,7 @@ int cmake::Generate()    if (this->WarnUnusedCli) {      this->RunCheckForUnusedVariables();    } -  if (cmSystemTools::GetErrorOccuredFlag()) { +  if (cmSystemTools::GetErrorOccurredFlag()) {      return -1;    }    // Save the cache again after a successful Generate so that any internal @@ -2507,7 +2548,7 @@ void cmake::AddCacheEntry(const std::string& key, cmValue value,                            const char* helpString, int type)  {    this->State->AddCacheEntry(key, value, helpString, -                             cmStateEnums::CacheEntryType(type)); +                             static_cast<cmStateEnums::CacheEntryType>(type));    this->UnwatchUnusedCli(key);    if (key == "CMAKE_WARN_DEPRECATED"_s) { @@ -2848,7 +2889,7 @@ int cmake::CheckBuildSystem()    cmGlobalGenerator gg(&cm);    cmMakefile mf(&gg, cm.GetCurrentSnapshot());    if (!mf.ReadListFile(this->CheckBuildSystemArgument) || -      cmSystemTools::GetErrorOccuredFlag()) { +      cmSystemTools::GetErrorOccurredFlag()) {      if (verbose) {        std::ostringstream msg;        msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument  | 
