some fixes for try compile

This commit is contained in:
Ken Martin 2002-09-13 13:48:14 -04:00
parent 9d59d651a1
commit ee592e9b98
3 changed files with 14 additions and 6 deletions

View File

@ -186,12 +186,19 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
cmMakefile *mf) 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 // for each existing language call enable Language
std::map<cmStdString, bool>::const_iterator i = std::map<cmStdString, bool>::const_iterator i =
gen->m_LanguageEnabled.begin(); gen->m_LanguageEnabled.begin();
for (;i != gen->m_LanguageEnabled.end(); ++i) for (;i != gen->m_LanguageEnabled.end(); ++i)
{ {
this->EnableLanguage(i->first.c_str(),mf); this->EnableLanguage(i->first.c_str(),lg->GetMakefile());
} }
delete lg;
} }

View File

@ -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 // be run that way but the cmake object requires a vailid path
std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND"); std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND");
cmake cm; cmake cm;
cm.AddCMakePaths(cmakeCommand.c_str());
cm.SetIsInTryCompile(true); cm.SetIsInTryCompile(true);
cmGlobalGenerator *gg = cmGlobalGenerator *gg =
cm.CreateGlobalGenerator(m_LocalGenerator->GetGlobalGenerator()->GetName()); cm.CreateGlobalGenerator(m_LocalGenerator->GetGlobalGenerator()->GetName());

View File

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