Bläddra i källkod

Ninja Multi-Config: Read configuration variables as normal variables

Early versions of the Ninja Multi-Config generator required
CMAKE_CONFIGURATION_TYPES and friends to be cache variables in order
to support selecting the default config in cmake(1) --build. The
behavior of cmake(1) --build has since been updated to no longer
require this, and requiring these variables to be cache variables is
inconsistent with the other generators.

Read the variables as normal CMake variables like the other generators.
This does not require a policy, since the only scenario where this would
cause a breakage is one where the cache variable and the CMake variable
are explicitly set to different values, which doesn't make sense to do
anyway.
Kyle Edwards 5 år sedan
förälder
incheckning
297ab15bf6
2 ändrade filer med 13 tillägg och 23 borttagningar
  1. 13 20
      Source/cmGlobalNinjaGenerator.cxx
  2. 0 3
      Source/cmGlobalNinjaGenerator.h

+ 13 - 20
Source/cmGlobalNinjaGenerator.cxx

@@ -2649,31 +2649,18 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
 }
 
 bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
-{
-  this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_DEFAULT_BUILD_TYPE");
-  this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_CROSS_CONFIGS");
-  this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_DEFAULT_CONFIGS");
-  return this->ReadCacheEntriesForBuild(*this->Makefiles.front()->GetState());
-}
-
-std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
-{
-  return "";
-}
-
-bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
-  const cmState& state)
 {
   std::vector<std::string> configsVec;
-  cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CONFIGURATION_TYPES"),
-               configsVec);
+  cmExpandList(
+    this->Makefiles.front()->GetSafeDefinition("CMAKE_CONFIGURATION_TYPES"),
+    configsVec);
   if (configsVec.empty()) {
     configsVec.emplace_back();
   }
   std::set<std::string> configs(configsVec.cbegin(), configsVec.cend());
 
   this->DefaultFileConfig =
-    state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE");
+    this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_BUILD_TYPE");
   if (this->DefaultFileConfig.empty()) {
     this->DefaultFileConfig = configsVec.front();
   }
@@ -2688,8 +2675,9 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
   }
 
   std::vector<std::string> crossConfigsVec;
-  cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CROSS_CONFIGS"),
-               crossConfigsVec);
+  cmExpandList(
+    this->Makefiles.front()->GetSafeDefinition("CMAKE_CROSS_CONFIGS"),
+    crossConfigsVec);
   auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec);
   if (!crossConfigs) {
     std::ostringstream msg;
@@ -2702,7 +2690,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
   this->CrossConfigs = *crossConfigs;
 
   auto defaultConfigsString =
-    state.GetSafeCacheEntryValue("CMAKE_DEFAULT_CONFIGS");
+    this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_CONFIGS");
   if (defaultConfigsString.empty()) {
     defaultConfigsString = this->DefaultFileConfig;
   }
@@ -2736,6 +2724,11 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
   return true;
 }
 
+std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
+{
+  return "";
+}
+
 std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTarget(
   cmGeneratorTarget const* target, const std::string& config) const
 {

+ 0 - 3
Source/cmGlobalNinjaGenerator.h

@@ -31,7 +31,6 @@ class cmLinkLineComputer;
 class cmLocalGenerator;
 class cmMakefile;
 class cmOutputConverter;
-class cmState;
 class cmStateDirectory;
 class cmake;
 struct cmDocumentationEntry;
@@ -647,8 +646,6 @@ public:
 
   std::string GetDefaultBuildConfig() const override;
 
-  bool ReadCacheEntriesForBuild(const cmState& state) override;
-
   bool SupportsDefaultBuildType() const override { return true; }
   bool SupportsCrossConfigs() const override { return true; }
   bool SupportsDefaultConfigs() const override { return true; }