From ee592e9b9854f06d492cd5865678e6b67ca56c94 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Fri, 13 Sep 2002 13:48:14 -0400 Subject: [PATCH] some fixes for try compile --- Source/cmGlobalGenerator.cxx | 9 ++++++++- Source/cmMakefile.cxx | 1 + Source/cmake.h | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 869f6cb0f..2ec4a2717 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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::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; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fc7622c38..e41551a32 100644 --- a/Source/cmMakefile.cxx +++ b/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()); diff --git a/Source/cmake.h b/Source/cmake.h index 60bde266d..3cf1a51e8 100644 --- a/Source/cmake.h +++ b/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 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();