Browse Source

Tell generators about CMAKE_SYSTEM_NAME as soon as it is known

Add a cmGlobalGenerator::SetSystemName virtual method.  Call it from
cmGlobalGenerator::EnableLanguage as soon as CMAKE_SYSTEM_NAME is known.
This will give generators a chance to adapt themselves to the target
system.  Pass the cmMakefile instance to the method so that the
generator can update it accordingly.  Return early from EnableLanguage
if SetSystemName returns false.
Brad King 11 years ago
parent
commit
ecb34faaab
2 changed files with 12 additions and 0 deletions
  1. 8 0
      Source/cmGlobalGenerator.cxx
  2. 4 0
      Source/cmGlobalGenerator.h

+ 8 - 0
Source/cmGlobalGenerator.cxx

@@ -448,6 +448,14 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
     mf->ReadListFile(0,fpath.c_str());
     mf->ReadListFile(0,fpath.c_str());
     }
     }
 
 
+  // Tell the generator about the target system.
+  std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
+  if(!this->SetSystemName(system, mf))
+    {
+    cmSystemTools::SetFatalErrorOccured();
+    return;
+    }
+
   // Tell the generator about the toolset, if any.
   // Tell the generator about the toolset, if any.
   std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
   std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
   if(!toolset.empty() &&
   if(!toolset.empty() &&

+ 4 - 0
Source/cmGlobalGenerator.h

@@ -61,6 +61,10 @@ public:
   virtual bool MatchesGeneratorName(const std::string& name) const
   virtual bool MatchesGeneratorName(const std::string& name) const
   { return this->GetName() == name; }
   { return this->GetName() == name; }
 
 
+  /** Tell the generator about the target system.  */
+  virtual bool SetSystemName(std::string const&, cmMakefile*)
+    { return true; }
+
   /** Set the generator-specific toolset name.  Returns true if toolset
   /** Set the generator-specific toolset name.  Returns true if toolset
       is supported and false otherwise.  */
       is supported and false otherwise.  */
   virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
   virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);