Browse Source

some fixes for try compile

Ken Martin 23 years ago
parent
commit
ee592e9b98
3 changed files with 14 additions and 6 deletions
  1. 8 1
      Source/cmGlobalGenerator.cxx
  2. 1 0
      Source/cmMakefile.cxx
  3. 5 5
      Source/cmake.h

+ 8 - 1
Source/cmGlobalGenerator.cxx

@@ -186,12 +186,19 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
 void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, 
                                                      cmMakefile *mf)
 {
+  // create a temp generator
+  cmLocalGenerator *lg = this->CreateLocalGenerator();
+  lg->GetMakefile()->SetStartDirectory(m_CMakeInstance->GetStartDirectory());
+  lg->GetMakefile()->SetStartOutputDirectory(m_CMakeInstance->GetStartOutputDirectory());
+  lg->GetMakefile()->MakeStartDirectoriesCurrent();
+
   // for each existing language call enable Language
   std::map<cmStdString, bool>::const_iterator i = 
     gen->m_LanguageEnabled.begin();
   for (;i != gen->m_LanguageEnabled.end(); ++i)
     {
-    this->EnableLanguage(i->first.c_str(),mf);
+    this->EnableLanguage(i->first.c_str(),lg->GetMakefile());
     }
+  delete lg;
 }
 

+ 1 - 0
Source/cmMakefile.cxx

@@ -1352,6 +1352,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
   // be run that way but the cmake object requires a vailid path
   std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND");
   cmake cm;
+  cm.AddCMakePaths(cmakeCommand.c_str());
   cm.SetIsInTryCompile(true);
   cmGlobalGenerator *gg = 
     cm.CreateGlobalGenerator(m_LocalGenerator->GetGlobalGenerator()->GetName());

+ 5 - 5
Source/cmake.h

@@ -181,6 +181,11 @@ class cmake
   ///! Is this cmake running as a result of a TRY_COMPILE command
   void SetIsInTryCompile(bool i) { m_InTryCompile = i; }
   
+  /**
+   * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
+   */
+  int AddCMakePaths(const char *arg0);
+
 protected:
   typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
   RegisteredCommandsMap m_Commands;
@@ -199,11 +204,6 @@ protected:
   ///! read in a cmake list file to initialize the cache
   void ReadListFile(const char *path);
   
-  /**
-   * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
-   */
-  int AddCMakePaths(const char *arg0);
-
   ///! used by Run
   int LocalGenerate();