summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalUnixMakefileGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator.cxx')
-rw-r--r--Source/cmGlobalUnixMakefileGenerator.cxx167
1 files changed, 79 insertions, 88 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx
index ee1454b..aeb3e41 100644
--- a/Source/cmGlobalUnixMakefileGenerator.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator.cxx
@@ -23,47 +23,83 @@
void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
cmMakefile *mf)
{
- // only do for global runs
- if (!m_CMakeInstance->GetLocal())
+ // if no lang specified use CXX
+ if(!lang )
{
- std::string output;
- std::string root
- = cmSystemTools::ConvertToOutputPath(mf->GetDefinition("CMAKE_ROOT"));
- // if no lang specified use CXX
- if(!lang )
+ lang = "CXX";
+ }
+ std::string root
+ = cmSystemTools::ConvertToOutputPath(mf->GetDefinition("CMAKE_ROOT"));
+ std::string rootBin = mf->GetHomeOutputDirectory();
+ if(m_ConfiguredFilesPath.size())
+ {
+ rootBin = m_ConfiguredFilesPath;
+ }
+ bool needCBackwards = false;
+ bool needCXXBackwards = false;
+
+ // check for a C compiler and configure it
+ if(!m_CMakeInstance->GetLocal() &&
+ !this->GetLanguageEnabled("C") &&
+ lang[0] == 'C')
+ {
+ if (m_CMakeInstance->GetIsInTryCompile())
{
- lang = "CXX";
+ cmSystemTools::Error("This should not have happen. "
+ "If you see this message, you are probably using a "
+ "broken CMakeLists.txt file or a problematic release of "
+ "CMake");
}
- // if CXX or C, then enable C
- if((!this->GetLanguageEnabled("C") && lang[0] == 'C'))
+ needCBackwards = true;
+ // Read the DetermineSystem file
+ std::string systemFile = root;
+ systemFile += "/Modules/CMakeDetermineSystem.cmake";
+ mf->ReadListFile(0, systemFile.c_str());
+ // read determine C compiler
+ std::string determineCFile = root;
+ determineCFile += "/Modules/CMakeDetermineCCompiler.cmake";
+ mf->ReadListFile(0,determineCFile.c_str());
+ this->SetLanguageEnabled("C");
+ }
+
+ // check for a CXX compiler and configure it
+ if(!m_CMakeInstance->GetLocal() &&
+ !this->GetLanguageEnabled("CXX") &&
+ strcmp(lang, "CXX") == 0)
+ {
+ needCXXBackwards = true;
+ std::string determineCFile = root;
+ determineCFile += "/Modules/CMakeDetermineCXXCompiler.cmake";
+ mf->ReadListFile(0,determineCFile.c_str());
+ this->SetLanguageEnabled("CXX");
+ }
+
+
+ std::string fpath = rootBin;
+ fpath += "/CMakeSystem.cmake";
+ mf->ReadListFile(0,fpath.c_str());
+ // if C, then enable C
+ if(lang[0] == 'C')
+ {
+ fpath = rootBin;
+ fpath += "/CMakeCCompiler.cmake";
+ mf->ReadListFile(0,fpath.c_str());
+ }
+ if(strcmp(lang, "CXX") == 0)
+ {
+ fpath = rootBin;
+ fpath += "/CMakeCXXCompiler.cmake";
+ mf->ReadListFile(0,fpath.c_str());
+ }
+ fpath = root;
+ fpath += "/Modules/CMakeSystemSpecificInformation.cmake";
+ mf->ReadListFile(0,fpath.c_str());
+ if(!m_CMakeInstance->GetLocal())
+ {
+ // At this point we should have enough info for a try compile
+ // which is used in the backward stuff
+ if(needCBackwards)
{
- static char envCC[5000];
- if(mf->GetDefinition("CMAKE_C_COMPILER"))
- {
- std::string env = "CC=${CMAKE_C_COMPILER}";
- mf->ExpandVariablesInString(env);
- strncpy(envCC, env.c_str(), 4999);
- envCC[4999] = 0;
- putenv(envCC);
- }
- if (m_CMakeInstance->GetIsInTryCompile())
- {
- cmSystemTools::Error("This should not have happen. "
- "If you see this message, you are probably using a "
- "broken CMakeLists.txt file or a problematic release of "
- "CMake");
- }
-
- std::string cmd = root;
- cmd += "/Templates/cconfigure";
- cmSystemTools::RunCommand(cmd.c_str(), output,
- cmSystemTools::ConvertToOutputPath(
- mf->GetHomeOutputDirectory()).c_str());
-
- std::string fpath = mf->GetHomeOutputDirectory();
- fpath += "/CCMakeSystemConfig.cmake";
- mf->ReadListFile(0,fpath.c_str());
- this->SetLanguageEnabled("C");
if (!m_CMakeInstance->GetIsInTryCompile())
{
// for old versions of CMake ListFiles
@@ -72,41 +108,12 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
if (!versionValue || atof(versionValue) <= 1.4)
{
std::string ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake";
- mf->ReadListFile(0,ifpath.c_str());
+ mf->ReadListFile(0,ifpath.c_str());
}
}
}
- // if CXX
- if(!this->GetLanguageEnabled("CXX") && strcmp(lang, "CXX") == 0)
+ if(needCXXBackwards)
{
- // see man putenv for explaination of this stupid code....
- static char envCXX[5000];
- if(mf->GetDefinition("CMAKE_CXX_COMPILER"))
- {
- std::string env = "CXX=${CMAKE_CXX_COMPILER}";
- mf->ExpandVariablesInString(env);
- strncpy(envCXX, env.c_str(), 4999);
- envCXX[4999] = 0;
- putenv(envCXX);
- }
- std::string cmd = root;
- if (m_CMakeInstance->GetIsInTryCompile())
- {
- cmSystemTools::Error("This should not have happen. "
- "If you see this message, you are probably using a "
- "broken CMakeLists.txt file or a problematic release of "
- "CMake");
- }
- cmd += "/Templates/cxxconfigure";
- cmSystemTools::RunCommand(cmd.c_str(), output,
- cmSystemTools::ConvertToOutputPath(
- mf->GetHomeOutputDirectory()).c_str());
-
- std::string fpath = mf->GetHomeOutputDirectory();
- fpath += "/CXXCMakeSystemConfig.cmake";
- mf->ReadListFile(0,fpath.c_str());
- this->SetLanguageEnabled("CXX");
-
if (!m_CMakeInstance->GetIsInTryCompile())
{
// for old versions of CMake ListFiles
@@ -114,12 +121,11 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
if (!versionValue || atof(versionValue) <= 1.4)
{
- fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake";
- mf->ReadListFile(0,fpath.c_str());
+ std::string fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake";
+ mf->ReadListFile(0,fpath.c_str());
}
}
}
-
// if we are from the top, always define this
mf->AddDefinition("RUN_CONFIGURE", true);
}
@@ -133,33 +139,18 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
return lg;
}
-void cmGlobalUnixMakefileGenerator::EnableLanguagesFromGenerator(
- cmGlobalGenerator *gen, cmMakefile *mf)
+void cmGlobalUnixMakefileGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen)
{
- // for UNIX we just want to read in the configured files
- cmLocalGenerator *lg = this->CreateLocalGenerator();
-
- // set the Start directories
- lg->GetMakefile()->SetStartDirectory(m_CMakeInstance->GetStartDirectory());
- lg->GetMakefile()->SetStartOutputDirectory(m_CMakeInstance->GetStartOutputDirectory());
- lg->GetMakefile()->MakeStartDirectoriesCurrent();
-
+ this->SetConfiguredFilesPath(gen->GetCMakeInstance()->GetHomeOutputDirectory());
// if C, then enable C
if(gen->GetLanguageEnabled("C"))
{
- std::string fpath = mf->GetHomeOutputDirectory();
- fpath += "/CCMakeSystemConfig.cmake";
- lg->GetMakefile()->ReadListFile(0,fpath.c_str());
this->SetLanguageEnabled("C");
}
// if CXX
if(gen->GetLanguageEnabled("CXX"))
{
- std::string fpath = mf->GetHomeOutputDirectory();
- fpath += "/CXXCMakeSystemConfig.cmake";
- lg->GetMakefile()->ReadListFile(0,fpath.c_str());
this->SetLanguageEnabled("CXX");
}
- delete lg;
}