2002-08-31 00:00:35 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2002-08-31 00:00:35 +04:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
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:00:35 +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.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmMakefile.h"
|
2003-05-24 18:07:58 +04:00
|
|
|
#include <stdlib.h> // required for atof
|
2002-08-31 00:00:35 +04:00
|
|
|
|
2003-07-16 23:38:31 +04:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2002-09-04 23:24:49 +04:00
|
|
|
cmGlobalGenerator::cmGlobalGenerator()
|
|
|
|
{
|
2003-01-09 20:18:22 +03:00
|
|
|
// do nothing duh
|
2002-09-04 23:24:49 +04:00
|
|
|
}
|
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
cmGlobalGenerator::~cmGlobalGenerator()
|
2003-01-09 19:28:29 +03:00
|
|
|
{
|
2002-08-31 00:00:35 +04:00
|
|
|
// Delete any existing cmLocalGenerators
|
2002-09-08 05:26:08 +04:00
|
|
|
unsigned int i;
|
2002-08-31 00:00:35 +04:00
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
delete m_LocalGenerators[i];
|
|
|
|
}
|
|
|
|
m_LocalGenerators.clear();
|
|
|
|
}
|
|
|
|
|
2002-12-05 21:44:11 +03:00
|
|
|
|
|
|
|
void cmGlobalGenerator::EnableLanguage(const char* lang,
|
2003-07-16 23:38:31 +04:00
|
|
|
cmMakefile *mf)
|
2002-12-05 21:44:11 +03:00
|
|
|
{
|
|
|
|
if(m_FindMakeProgramFile.size() == 0)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"Generator implementation error, "
|
|
|
|
"all generators must specify m_FindMakeProgramFile");
|
|
|
|
}
|
|
|
|
std::string root = mf->GetDefinition("CMAKE_ROOT");
|
|
|
|
if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
|
|
|
|
|| cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
|
|
|
|
{
|
|
|
|
std::string setMakeProgram = root;
|
|
|
|
setMakeProgram += "/Modules/";
|
|
|
|
setMakeProgram += m_FindMakeProgramFile;
|
|
|
|
mf->ReadListFile(0, setMakeProgram.c_str());
|
|
|
|
}
|
|
|
|
if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
|
|
|
|
|| cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
|
|
|
|
{
|
2003-05-14 00:11:14 +04:00
|
|
|
cmOStringStream err;
|
|
|
|
err << "CMake was unable to find a build program corresponding to \""
|
|
|
|
<< this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
|
|
|
|
<< "probably need to select a different build tool.";
|
|
|
|
cmSystemTools::Error(err.str().c_str());
|
2003-05-13 22:26:16 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2002-12-05 21:44:11 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string makeProgram = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
if(makeProgram.find(' ') != makeProgram.npos)
|
|
|
|
{
|
|
|
|
cmSystemTools::GetShortPath(makeProgram.c_str(), makeProgram);
|
|
|
|
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
|
|
|
|
"make program",
|
|
|
|
cmCacheManager::FILEPATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLocal = m_CMakeInstance->GetLocal();
|
|
|
|
// if no lang specified use CXX
|
|
|
|
if(!lang )
|
|
|
|
{
|
|
|
|
lang = "CXX";
|
|
|
|
}
|
|
|
|
std::string rootBin = mf->GetHomeOutputDirectory();
|
|
|
|
if(m_ConfiguredFilesPath.size())
|
|
|
|
{
|
|
|
|
rootBin = m_ConfiguredFilesPath;
|
|
|
|
}
|
|
|
|
bool needCBackwards = false;
|
|
|
|
bool needCXXBackwards = false;
|
2002-12-11 18:34:35 +03:00
|
|
|
|
|
|
|
if (!isLocal &&
|
|
|
|
!this->GetLanguageEnabled("C") && !this->GetLanguageEnabled("CXX") &&
|
|
|
|
!this->GetLanguageEnabled("JAVA"))
|
|
|
|
{
|
2003-07-16 23:38:31 +04:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
/* Windows version number data. */
|
|
|
|
OSVERSIONINFO osvi;
|
|
|
|
ZeroMemory(&osvi, sizeof(osvi));
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
GetVersionEx (&osvi);
|
|
|
|
cmOStringStream windowsVersionString;
|
|
|
|
windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion;
|
|
|
|
windowsVersionString.str();
|
|
|
|
mf->AddDefinition("CMAKE_SYSTEM_VERSION", windowsVersionString.str().c_str());
|
|
|
|
#endif
|
2002-12-11 18:34:35 +03:00
|
|
|
// Read the DetermineSystem file
|
|
|
|
std::string systemFile = root;
|
|
|
|
systemFile += "/Modules/CMakeDetermineSystem.cmake";
|
|
|
|
mf->ReadListFile(0, systemFile.c_str());
|
|
|
|
}
|
2002-12-05 21:44:11 +03:00
|
|
|
|
|
|
|
// check for a C compiler and configure it
|
|
|
|
if(!isLocal &&
|
|
|
|
!this->GetLanguageEnabled("C") &&
|
|
|
|
lang[0] == 'C')
|
2002-12-06 19:43:23 +03:00
|
|
|
{
|
2002-12-05 21:44:11 +03:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
needCBackwards = true;
|
|
|
|
// read determine C compiler
|
|
|
|
std::string determineCFile = root;
|
|
|
|
determineCFile += "/Modules/CMakeDetermineCCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,determineCFile.c_str());
|
|
|
|
this->SetLanguageEnabled("C");
|
2002-12-06 19:43:23 +03:00
|
|
|
// put CC in the environment in case user scripts want
|
|
|
|
// to run configure
|
|
|
|
// see man putenv for explaination of this stupid code...
|
|
|
|
if(mf->GetDefinition("CMAKE_C_COMPILER"))
|
|
|
|
{
|
|
|
|
static char envCC[5000];
|
|
|
|
std::string env = "CC=${CMAKE_C_COMPILER}";
|
|
|
|
mf->ExpandVariablesInString(env);
|
2003-01-10 19:07:29 +03:00
|
|
|
unsigned int size = static_cast<unsigned int>(env.size());
|
2003-01-09 19:28:29 +03:00
|
|
|
if(size > 4999)
|
|
|
|
{
|
|
|
|
size = 4999;
|
|
|
|
}
|
|
|
|
strncpy(envCC, env.c_str(), size);
|
|
|
|
envCC[size] = 0;
|
2002-12-06 19:43:23 +03:00
|
|
|
putenv(envCC);
|
|
|
|
}
|
2002-12-05 21:44:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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");
|
2002-12-06 19:43:23 +03:00
|
|
|
// put CXX in the environment in case user scripts want
|
|
|
|
// to run configure
|
|
|
|
// 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}";
|
2003-01-09 19:28:29 +03:00
|
|
|
mf->ExpandVariablesInString(env);
|
2003-01-10 19:07:29 +03:00
|
|
|
unsigned int size = static_cast<unsigned int>(env.size());
|
2003-01-09 19:28:29 +03:00
|
|
|
if(size > 4999)
|
|
|
|
{
|
|
|
|
size = 4999;
|
|
|
|
}
|
|
|
|
strncpy(envCXX, env.c_str(), size);
|
2002-12-06 19:43:23 +03:00
|
|
|
envCXX[4999] = 0;
|
|
|
|
putenv(envCXX);
|
|
|
|
}
|
2002-12-05 21:44:11 +03:00
|
|
|
}
|
2002-12-19 23:34:11 +03:00
|
|
|
// check for a Java compiler and configure it
|
2002-12-11 18:34:35 +03:00
|
|
|
if(!isLocal &&
|
|
|
|
!this->GetLanguageEnabled("JAVA") &&
|
|
|
|
strcmp(lang, "JAVA") == 0)
|
|
|
|
{
|
|
|
|
std::string determineCFile = root;
|
|
|
|
determineCFile += "/Modules/CMakeDetermineJavaCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,determineCFile.c_str());
|
|
|
|
this->SetLanguageEnabled("JAVA");
|
|
|
|
}
|
|
|
|
|
2002-12-05 21:44:11 +03:00
|
|
|
std::string fpath = rootBin;
|
|
|
|
if(!mf->GetDefinition("CMAKE_SYSTEM_LOADED"))
|
|
|
|
{
|
|
|
|
fpath += "/CMakeSystem.cmake";
|
|
|
|
mf->ReadListFile(0,fpath.c_str());
|
|
|
|
}
|
|
|
|
// if C, then enable C
|
|
|
|
if(lang[0] == 'C' && !mf->GetDefinition("CMAKE_C_COMPILER_LOADED"))
|
|
|
|
{
|
|
|
|
fpath = rootBin;
|
|
|
|
fpath += "/CMakeCCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,fpath.c_str());
|
2002-12-19 23:34:11 +03:00
|
|
|
this->SetLanguageEnabled("C");
|
2002-12-05 21:44:11 +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-12-19 23:34:11 +03:00
|
|
|
this->SetLanguageEnabled("CXX");
|
|
|
|
|
2002-12-05 21:44:11 +03:00
|
|
|
}
|
2002-12-11 18:34:35 +03:00
|
|
|
if(strcmp(lang, "JAVA") == 0 && !mf->GetDefinition("CMAKE_JAVA_COMPILER_LOADED"))
|
|
|
|
{
|
|
|
|
fpath = rootBin;
|
|
|
|
fpath += "/CMakeJavaCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,fpath.c_str());
|
2002-12-19 23:34:11 +03:00
|
|
|
this->SetLanguageEnabled("JAVA");
|
2002-12-11 18:34:35 +03:00
|
|
|
}
|
|
|
|
if ( lang[0] == 'C' && !mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
|
2002-12-05 21:44:11 +03:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
|
|
|
{
|
2003-01-21 20:50:48 +03:00
|
|
|
std::string ifpath = root + "/Modules/CMakeTestCCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,ifpath.c_str());
|
2002-12-05 21:44:11 +03:00
|
|
|
// for old versions of CMake ListFiles
|
|
|
|
const char* versionValue
|
2003-01-09 16:47:54 +03:00
|
|
|
= mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
|
|
|
if (atof(versionValue) <= 1.4)
|
2002-12-05 21:44:11 +03:00
|
|
|
{
|
2003-01-21 20:50:48 +03:00
|
|
|
ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake";
|
2002-12-05 21:44:11 +03:00
|
|
|
mf->ReadListFile(0,ifpath.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(needCXXBackwards)
|
|
|
|
{
|
|
|
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
|
|
|
{
|
2003-01-21 20:50:48 +03:00
|
|
|
std::string ifpath = root + "/Modules/CMakeTestCXXCompiler.cmake";
|
|
|
|
mf->ReadListFile(0,ifpath.c_str());
|
2002-12-05 21:44:11 +03:00
|
|
|
// for old versions of CMake ListFiles
|
|
|
|
const char* versionValue
|
2003-01-09 16:47:54 +03:00
|
|
|
= mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
|
|
|
if (atof(versionValue) <= 1.4)
|
2002-12-05 21:44:11 +03:00
|
|
|
{
|
2002-12-09 06:34:17 +03:00
|
|
|
std::string nfpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake";
|
|
|
|
mf->ReadListFile(0,nfpath.c_str());
|
2002-12-05 21:44:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if we are from the top, always define this
|
|
|
|
mf->AddDefinition("RUN_CONFIGURE", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
void cmGlobalGenerator::SetLanguageEnabled(const char* l)
|
|
|
|
{
|
|
|
|
m_LanguageEnabled[l] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGlobalGenerator::GetLanguageEnabled(const char* l)
|
|
|
|
{
|
|
|
|
return (m_LanguageEnabled.count(l) > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalGenerator::ClearEnabledLanguages()
|
|
|
|
{
|
|
|
|
m_LanguageEnabled.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalGenerator::Configure()
|
|
|
|
{
|
|
|
|
// Delete any existing cmLocalGenerators
|
2002-09-08 05:26:08 +04:00
|
|
|
unsigned int i;
|
2002-08-31 00:00:35 +04:00
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
delete m_LocalGenerators[i];
|
|
|
|
}
|
|
|
|
m_LocalGenerators.clear();
|
|
|
|
|
|
|
|
// start with this directory
|
|
|
|
cmLocalGenerator *lg = this->CreateLocalGenerator();
|
|
|
|
m_LocalGenerators.push_back(lg);
|
|
|
|
|
|
|
|
// set the Start directories
|
2002-09-06 21:06:23 +04:00
|
|
|
lg->GetMakefile()->SetStartDirectory(m_CMakeInstance->GetStartDirectory());
|
|
|
|
lg->GetMakefile()->SetStartOutputDirectory(m_CMakeInstance->GetStartOutputDirectory());
|
2002-09-04 23:24:49 +04:00
|
|
|
lg->GetMakefile()->MakeStartDirectoriesCurrent();
|
2002-08-31 00:00:35 +04:00
|
|
|
|
|
|
|
// now do it
|
2002-09-26 23:14:20 +04:00
|
|
|
this->RecursiveConfigure(lg,0.0f,0.9f);
|
2002-09-15 16:54:16 +04:00
|
|
|
|
2003-01-31 21:50:42 +03:00
|
|
|
std::set<std::string> notFoundMap;
|
2002-09-15 16:54:16 +04:00
|
|
|
// after it is all done do a ConfigureFinalPass
|
2003-01-31 21:50:42 +03:00
|
|
|
cmCacheManager* manager = 0;
|
2002-09-15 16:54:16 +04:00
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
2003-01-31 21:50:42 +03:00
|
|
|
manager = m_LocalGenerators[i]->GetMakefile()->GetCacheManager();
|
2002-09-15 16:54:16 +04:00
|
|
|
m_LocalGenerators[i]->ConfigureFinalPass();
|
2003-01-31 21:50:42 +03:00
|
|
|
cmTargets const& targets = m_LocalGenerators[i]->GetMakefile()->GetTargets();
|
|
|
|
for (cmTargets::const_iterator l = targets.begin();
|
|
|
|
l != targets.end(); l++)
|
|
|
|
{
|
|
|
|
cmTarget::LinkLibraries libs = l->second.GetLinkLibraries();
|
|
|
|
for(cmTarget::LinkLibraries::iterator lib = libs.begin();
|
|
|
|
lib != libs.end(); ++lib)
|
|
|
|
{
|
2003-02-04 23:37:24 +03:00
|
|
|
if(lib->first.size() > 9 &&
|
|
|
|
cmSystemTools::IsNOTFOUND(lib->first.c_str()))
|
2003-01-31 21:50:42 +03:00
|
|
|
{
|
2003-01-31 22:39:49 +03:00
|
|
|
std::string varName = lib->first.substr(0, lib->first.size()-9);
|
|
|
|
notFoundMap.insert(varName);
|
2003-01-31 21:50:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
std::vector<std::string>& incs =
|
|
|
|
m_LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
|
|
|
|
|
|
|
|
for( std::vector<std::string>::iterator lib = incs.begin();
|
|
|
|
lib != incs.end(); ++lib)
|
|
|
|
{
|
2003-02-04 23:37:24 +03:00
|
|
|
if(lib->size() > 9 &&
|
|
|
|
cmSystemTools::IsNOTFOUND(lib->c_str()))
|
2003-01-31 21:50:42 +03:00
|
|
|
{
|
2003-01-31 22:39:49 +03:00
|
|
|
std::string varName = lib->substr(0, lib->size()-9);
|
|
|
|
notFoundMap.insert(varName);
|
2003-01-31 21:50:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
m_CMakeInstance->UpdateProgress("Configuring",
|
2002-09-26 23:14:20 +04:00
|
|
|
0.9f+0.1f*(i+1.0f)/m_LocalGenerators.size());
|
2003-01-31 21:50:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(notFoundMap.size())
|
|
|
|
{
|
|
|
|
std::string notFoundVars;
|
2003-02-02 19:45:44 +03:00
|
|
|
for(std::set<std::string>::iterator ii = notFoundMap.begin();
|
|
|
|
ii != notFoundMap.end(); ++ii)
|
2003-01-31 21:50:42 +03:00
|
|
|
{
|
2003-02-02 19:45:44 +03:00
|
|
|
notFoundVars += *ii;
|
2003-01-31 21:50:42 +03:00
|
|
|
if(manager)
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
2003-02-02 19:45:44 +03:00
|
|
|
manager->GetCacheIterator(ii->c_str());
|
2003-01-31 21:50:42 +03:00
|
|
|
if(it.GetPropertyAsBool("ADVANCED"))
|
|
|
|
{
|
|
|
|
notFoundVars += " (ADVANCED)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notFoundVars += "\n";
|
|
|
|
}
|
|
|
|
cmSystemTools::Error("This project requires some variables to be set,\n"
|
|
|
|
"and cmake can not find them.\n"
|
|
|
|
"Please set the following variables:\n",
|
|
|
|
notFoundVars.c_str());
|
2002-09-15 16:54:16 +04:00
|
|
|
}
|
2002-09-26 23:14:20 +04:00
|
|
|
m_CMakeInstance->UpdateProgress("Configuring done", -1);
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// loop through the directories creating cmLocalGenerators and Configure()
|
2002-09-26 23:14:20 +04:00
|
|
|
void cmGlobalGenerator::RecursiveConfigure(cmLocalGenerator *lg,
|
|
|
|
float startProgress,
|
|
|
|
float endProgress)
|
2002-08-31 00:00:35 +04:00
|
|
|
{
|
|
|
|
// configure the current directory
|
|
|
|
lg->Configure();
|
2002-09-26 23:14:20 +04:00
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
// get all the subdirectories
|
|
|
|
std::vector<std::string> subdirs = lg->GetMakefile()->GetSubDirectories();
|
2002-09-26 23:14:20 +04:00
|
|
|
float progressPiece = (endProgress - startProgress)/(1.0f+subdirs.size());
|
|
|
|
m_CMakeInstance->UpdateProgress("Configuring",
|
|
|
|
startProgress + progressPiece);
|
2002-08-31 00:00:35 +04:00
|
|
|
|
|
|
|
// for each subdir recurse
|
2002-09-08 05:26:08 +04:00
|
|
|
unsigned int i;
|
2002-08-31 00:00:35 +04:00
|
|
|
for (i = 0; i < subdirs.size(); ++i)
|
|
|
|
{
|
|
|
|
cmLocalGenerator *lg2 = this->CreateLocalGenerator();
|
|
|
|
m_LocalGenerators.push_back(lg2);
|
|
|
|
|
|
|
|
// add the subdir to the start output directory
|
|
|
|
std::string outdir = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
outdir += "/";
|
|
|
|
outdir += subdirs[i];
|
|
|
|
lg2->GetMakefile()->SetStartOutputDirectory(outdir.c_str());
|
|
|
|
|
|
|
|
// add the subdir to the start source directory
|
|
|
|
std::string currentDir = lg->GetMakefile()->GetStartDirectory();
|
|
|
|
currentDir += "/";
|
|
|
|
currentDir += subdirs[i];
|
|
|
|
lg2->GetMakefile()->SetStartDirectory(currentDir.c_str());
|
2002-09-04 23:24:49 +04:00
|
|
|
lg2->GetMakefile()->MakeStartDirectoriesCurrent();
|
2002-08-31 00:00:35 +04:00
|
|
|
|
2002-09-26 23:14:20 +04:00
|
|
|
this->RecursiveConfigure(lg2,
|
|
|
|
startProgress + (i+1.0f)*progressPiece,
|
|
|
|
startProgress + (i+2.0f)*progressPiece);
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalGenerator::Generate()
|
|
|
|
{
|
|
|
|
// For each existing cmLocalGenerator
|
2002-09-08 05:26:08 +04:00
|
|
|
unsigned int i;
|
2002-08-31 00:00:35 +04:00
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
m_LocalGenerators[i]->Generate(true);
|
2002-09-26 23:14:20 +04:00
|
|
|
m_CMakeInstance->UpdateProgress("Generating",
|
|
|
|
(i+1.0f)/m_LocalGenerators.size());
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
2002-10-09 23:24:20 +04:00
|
|
|
m_CMakeInstance->UpdateProgress("Generating done", -1);
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalGenerator::LocalGenerate()
|
|
|
|
{
|
|
|
|
// for this case we create one LocalGenerator
|
|
|
|
// configure it, and then Generate it
|
|
|
|
// start with this directory
|
|
|
|
cmLocalGenerator *lg = this->CreateLocalGenerator();
|
|
|
|
|
|
|
|
// set the Start directories
|
2002-09-06 21:06:23 +04:00
|
|
|
lg->GetMakefile()->SetStartDirectory(m_CMakeInstance->GetStartDirectory());
|
|
|
|
lg->GetMakefile()->SetStartOutputDirectory(m_CMakeInstance->GetStartOutputDirectory());
|
2002-09-04 23:24:49 +04:00
|
|
|
lg->GetMakefile()->MakeStartDirectoriesCurrent();
|
2002-08-31 00:00:35 +04:00
|
|
|
|
|
|
|
// now do trhe configure
|
|
|
|
lg->Configure();
|
2002-09-15 16:54:16 +04:00
|
|
|
lg->ConfigureFinalPass();
|
2002-08-31 00:00:35 +04:00
|
|
|
lg->Generate(false);
|
|
|
|
delete lg;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmGlobalGenerator::TryCompile(const char *, const char *bindir,
|
2002-09-20 21:15:56 +04:00
|
|
|
const char *, const char *target,
|
|
|
|
std::string *output)
|
2002-08-31 00:00:35 +04:00
|
|
|
{
|
|
|
|
// now build the test
|
|
|
|
std::string makeCommand =
|
|
|
|
m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
|
|
|
|
if(makeCommand.size() == 0)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"Generator cannot find the appropriate make command.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run an executable command and put the stdout in output.
|
|
|
|
*/
|
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
|
cmSystemTools::ChangeDirectory(bindir);
|
2002-09-25 15:46:45 +04:00
|
|
|
|
|
|
|
// Since we have full control over the invocation of nmake, let us
|
|
|
|
// make it quiet.
|
|
|
|
if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
|
|
|
|
{
|
|
|
|
makeCommand += " /NOLOGO ";
|
|
|
|
}
|
2002-08-31 00:00:35 +04:00
|
|
|
|
|
|
|
// now build
|
2002-09-11 00:49:40 +04:00
|
|
|
if (target)
|
|
|
|
{
|
|
|
|
makeCommand += " ";
|
|
|
|
makeCommand += target;
|
2002-09-24 17:24:39 +04:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2002-09-23 20:23:06 +04:00
|
|
|
makeCommand += ".exe";
|
|
|
|
#endif // WIN32
|
2002-09-11 00:49:40 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
makeCommand += " all";
|
|
|
|
}
|
|
|
|
int retVal;
|
2002-09-20 21:15:56 +04:00
|
|
|
if (!cmSystemTools::RunCommand(makeCommand.c_str(), *output, retVal, 0, false))
|
2002-08-31 00:00:35 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::Error("Generator: execution of make failed.");
|
|
|
|
// return to the original directory
|
|
|
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
|
|
|
return 1;
|
|
|
|
}
|
2003-05-14 20:06:40 +04:00
|
|
|
|
|
|
|
// The SGI MipsPro 7.3 compiler does not return an error code when
|
|
|
|
// the source has a #error in it! This is a work-around for such
|
|
|
|
// compilers.
|
|
|
|
if((retVal == 0) && (output->find("#error") != std::string::npos))
|
|
|
|
{
|
|
|
|
retVal = 1;
|
|
|
|
}
|
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
2002-09-11 00:49:40 +04:00
|
|
|
return retVal;
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
|
|
|
|
{
|
|
|
|
cmLocalGenerator *lg = new cmLocalGenerator;
|
|
|
|
lg->SetGlobalGenerator(this);
|
|
|
|
return lg;
|
|
|
|
}
|
2002-09-13 18:42:50 +04:00
|
|
|
|
2002-11-08 23:46:08 +03:00
|
|
|
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
|
2002-09-13 18:42:50 +04:00
|
|
|
{
|
2002-12-05 21:44:11 +03:00
|
|
|
this->SetConfiguredFilesPath(
|
|
|
|
gen->GetCMakeInstance()->GetHomeOutputDirectory());
|
|
|
|
const char* make =
|
|
|
|
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
|
|
|
|
"make program",
|
|
|
|
cmCacheManager::FILEPATH);
|
|
|
|
// if C, then enable C
|
|
|
|
if(gen->GetLanguageEnabled("C"))
|
2002-09-13 18:42:50 +04:00
|
|
|
{
|
2002-12-05 21:44:11 +03:00
|
|
|
this->SetLanguageEnabled("C");
|
|
|
|
}
|
|
|
|
|
|
|
|
// if CXX
|
|
|
|
if(gen->GetLanguageEnabled("CXX"))
|
|
|
|
{
|
|
|
|
this->SetLanguageEnabled("CXX");
|
2002-09-13 18:42:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const
|
|
|
|
{
|
|
|
|
entry.name = this->GetName();
|
|
|
|
entry.brief = "";
|
|
|
|
entry.full = "";
|
|
|
|
}
|