Selaa lähdekoodia

Merge topic 'fix-find-make-program' into release-3.19

ef91fb02f3 cmGlobalGenerator: FindMakeProgram() at a generator-specific time

Acked-by: Kitware Robot <[email protected]>
Acked-by: Frank Dana <[email protected]>
Merge-request: !5529
Brad King 5 vuotta sitten
vanhempi
sitoutus
aeb0e40111

+ 8 - 1
Source/cmGlobalGenerator.cxx

@@ -584,7 +584,8 @@ void cmGlobalGenerator::EnableLanguage(
     // Find the native build tool for this generator.
     // Find the native build tool for this generator.
     // This has to be done early so that MSBuild can be used to examine the
     // This has to be done early so that MSBuild can be used to examine the
     // cross-compilation environment.
     // cross-compilation environment.
-    if (!this->FindMakeProgram(mf)) {
+    if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Early &&
+        !this->FindMakeProgram(mf)) {
       return;
       return;
     }
     }
   }
   }
@@ -660,6 +661,12 @@ void cmGlobalGenerator::EnableLanguage(
       cmSystemTools::SetFatalErrorOccured();
       cmSystemTools::SetFatalErrorOccured();
       return;
       return;
     }
     }
+
+    // Find the native build tool for this generator.
+    if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Late &&
+        !this->FindMakeProgram(mf)) {
+      return;
+    }
   }
   }
 
 
   // Check that the languages are supported by the generator and its
   // Check that the languages are supported by the generator and its

+ 11 - 0
Source/cmGlobalGenerator.h

@@ -597,6 +597,17 @@ protected:
 
 
   std::string GetPredefinedTargetsFolder();
   std::string GetPredefinedTargetsFolder();
 
 
+  enum class FindMakeProgramStage
+  {
+    Early,
+    Late,
+  };
+
+  virtual FindMakeProgramStage GetFindMakeProgramStage() const
+  {
+    return FindMakeProgramStage::Late;
+  }
+
 private:
 private:
   using TargetMap = std::unordered_map<std::string, cmTarget*>;
   using TargetMap = std::unordered_map<std::string, cmTarget*>;
   using GeneratorTargetMap =
   using GeneratorTargetMap =

+ 5 - 0
Source/cmGlobalVisualStudioGenerator.h

@@ -166,6 +166,11 @@ protected:
 
 
   void WriteSLNHeader(std::ostream& fout);
   void WriteSLNHeader(std::ostream& fout);
 
 
+  FindMakeProgramStage GetFindMakeProgramStage() const override
+  {
+    return FindMakeProgramStage::Early;
+  }
+
   bool ComputeTargetDepends() override;
   bool ComputeTargetDepends() override;
   class VSDependSet : public std::set<std::string>
   class VSDependSet : public std::set<std::string>
   {
   {

+ 5 - 0
Source/cmGlobalXCodeGenerator.h

@@ -124,6 +124,11 @@ protected:
   void AddExtraIDETargets() override;
   void AddExtraIDETargets() override;
   void Generate() override;
   void Generate() override;
 
 
+  FindMakeProgramStage GetFindMakeProgramStage() const override
+  {
+    return FindMakeProgramStage::Early;
+  }
+
 private:
 private:
   bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
   bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
   bool ProcessGeneratorToolsetField(std::string const& key,
   bool ProcessGeneratorToolsetField(std::string const& key,