CMake/Source/cmGlobalUnixMakefileGenerat...

165 lines
5.1 KiB
C++
Raw Normal View History

2002-08-31 00:01:48 +04:00
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
2002-08-31 00:01:48 +04:00
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
2002-08-31 00:01:48 +04:00
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
2002-08-31 00:01:48 +04:00
#include "cmGlobalUnixMakefileGenerator.h"
#include "cmLocalUnixMakefileGenerator.h"
#include "cmMakefile.h"
2002-09-06 21:06:23 +04:00
#include "cmake.h"
2002-08-31 00:01:48 +04:00
void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
cmMakefile *mf)
{
bool isLocal = m_CMakeInstance->GetLocal();
// if no lang specified use CXX
if(!lang )
2002-08-31 00:01:48 +04:00
{
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(!isLocal &&
!this->GetLanguageEnabled("C") &&
lang[0] == 'C')
{
if (m_CMakeInstance->GetIsInTryCompile())
2002-09-13 18:42:50 +04:00
{
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");
2002-09-13 18:42:50 +04:00
}
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(!isLocal &&
!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;
2002-11-11 20:31:46 +03:00
if(!mf->GetDefinition("CMAKE_SYSTEM_LOADED"))
{
fpath += "/CMakeSystem.cmake";
mf->ReadListFile(0,fpath.c_str());
}
// if C, then enable C
2002-11-11 20:31:46 +03:00
if(lang[0] == 'C' && !mf->GetDefinition("CMAKE_C_COMPILER_LOADED"))
{
fpath = rootBin;
fpath += "/CMakeCCompiler.cmake";
mf->ReadListFile(0,fpath.c_str());
}
2002-11-11 20:31:46 +03:00
if(strcmp(lang, "CXX") == 0 && !mf->GetDefinition("CMAKE_CXX_COMPILER_LOADED"))
{
fpath = rootBin;
fpath += "/CMakeCXXCompiler.cmake";
mf->ReadListFile(0,fpath.c_str());
}
2002-11-11 20:31:46 +03:00
if(!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
{
fpath = root;
fpath += "/Modules/CMakeSystemSpecificInformation.cmake";
mf->ReadListFile(0,fpath.c_str());
}
if(!isLocal)
{
// At this point we should have enough info for a try compile
// which is used in the backward stuff
if(needCBackwards)
2002-08-31 00:01:48 +04:00
{
if (!m_CMakeInstance->GetIsInTryCompile())
{
// for old versions of CMake ListFiles
const char* versionValue
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
if (!versionValue || atof(versionValue) <= 1.4)
{
2002-10-17 18:51:23 +04:00
std::string ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake";
mf->ReadListFile(0,ifpath.c_str());
}
}
2002-09-13 18:42:50 +04:00
}
if(needCXXBackwards)
2002-09-13 18:42:50 +04:00
{
if (!m_CMakeInstance->GetIsInTryCompile())
2002-09-06 21:06:23 +04:00
{
// for old versions of CMake ListFiles
2002-09-13 18:42:50 +04:00
const char* versionValue
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
if (!versionValue || atof(versionValue) <= 1.4)
{
std::string fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake";
mf->ReadListFile(0,fpath.c_str());
2002-09-13 18:42:50 +04:00
}
2002-09-06 21:06:23 +04:00
}
2002-08-31 00:01:48 +04:00
}
2002-09-06 21:06:23 +04:00
// if we are from the top, always define this
mf->AddDefinition("RUN_CONFIGURE", true);
}
2002-08-31 00:01:48 +04:00
}
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
{
cmLocalGenerator *lg = new cmLocalUnixMakefileGenerator;
lg->SetGlobalGenerator(this);
return lg;
}
void cmGlobalUnixMakefileGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen)
2002-09-13 18:42:50 +04:00
{
this->SetConfiguredFilesPath(gen->GetCMakeInstance()->GetHomeOutputDirectory());
2002-09-13 18:42:50 +04:00
// if C, then enable C
if(gen->GetLanguageEnabled("C"))
{
this->SetLanguageEnabled("C");
}
// if CXX
if(gen->GetLanguageEnabled("CXX"))
{
this->SetLanguageEnabled("CXX");
}
}