summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx367
1 files changed, 170 insertions, 197 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6d0fedc..14eaeac 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -20,6 +20,7 @@
#include "cmLocalGenerator.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmake.h"
+#include "cmState.h"
#include "cmMakefile.h"
#include "cmQtAutoGenerators.h"
#include "cmSourceFile.h"
@@ -32,6 +33,7 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmExportBuildFileGenerator.h"
#include "cmCPackPropertiesGenerator.h"
+#include "cmAlgorithms.h"
#include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
@@ -46,7 +48,8 @@
#include <assert.h>
-cmGlobalGenerator::cmGlobalGenerator()
+cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
+ : CMakeInstance(cm)
{
// By default the .SYMBOLIC dependency is not needed on symbolic rules.
this->NeedSymbolicMark = false;
@@ -67,18 +70,14 @@ cmGlobalGenerator::cmGlobalGenerator()
this->TryCompileTimeout = 0;
this->ExtraGenerator = 0;
- this->CurrentLocalGenerator = 0;
+ this->CurrentMakefile = 0;
this->TryCompileOuterMakefile = 0;
}
cmGlobalGenerator::~cmGlobalGenerator()
{
this->ClearGeneratorMembers();
-
- if (this->ExtraGenerator)
- {
- delete this->ExtraGenerator;
- }
+ delete this->ExtraGenerator;
}
bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
@@ -88,18 +87,16 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
{
return true;
}
- else
- {
- std::ostringstream e;
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "does not support platform specification, but platform\n"
- " " << p << "\n"
- "was specified.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
- return false;
- }
+
+ std::ostringstream e;
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "does not support platform specification, but platform\n"
+ " " << p << "\n"
+ "was specified.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
}
bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
@@ -109,18 +106,15 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
{
return true;
}
- else
- {
- std::ostringstream e;
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "does not support toolset specification, but toolset\n"
- " " << ts << "\n"
- "was specified.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
- return false;
- }
+ std::ostringstream e;
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "does not support toolset specification, but toolset\n"
+ " " << ts << "\n"
+ "was specified.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
}
std::string cmGlobalGenerator::SelectMakeProgram(
@@ -182,7 +176,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
return;
}
const char* cname = this->GetCMakeInstance()->
- GetCacheManager()->GetCacheValue(langComp);
+ GetState()->GetInitializedCacheValue(langComp);
std::string changeVars;
if(cname && !optional)
{
@@ -202,7 +196,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
if (cnameString != pathString)
{
const char* cvars =
- this->GetCMakeInstance()->GetProperty(
+ this->GetCMakeInstance()->GetState()->GetGlobalProperty(
"__CMAKE_DELETE_CACHE_CHANGE_VARS_");
if(cvars)
{
@@ -212,7 +206,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
changeVars += langComp;
changeVars += ";";
changeVars += cname;
- this->GetCMakeInstance()->SetProperty(
+ this->GetCMakeInstance()->GetState()->SetGlobalProperty(
"__CMAKE_DELETE_CACHE_CHANGE_VARS_",
changeVars.c_str());
}
@@ -280,7 +274,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
mf->GetModulesFile(this->FindMakeProgramFile.c_str());
if(!setMakeProgram.empty())
{
- mf->ReadListFile(0, setMakeProgram.c_str());
+ mf->ReadListFile(setMakeProgram.c_str());
}
}
if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
@@ -313,7 +307,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
makeProgram += saveFile;
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
"make program",
- cmCacheManager::FILEPATH);
+ cmState::FILEPATH);
}
}
@@ -430,7 +424,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
fpath += "/CMakeSystem.cmake";
if(cmSystemTools::FileExists(fpath.c_str()))
{
- mf->ReadListFile(0,fpath.c_str());
+ mf->ReadListFile(fpath.c_str());
}
}
// Load the CMakeDetermineSystem.cmake file and find out
@@ -458,12 +452,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
#endif
// Read the DetermineSystem file
std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake");
- mf->ReadListFile(0, systemFile.c_str());
+ mf->ReadListFile(systemFile.c_str());
// load the CMakeSystem.cmake from the binary directory
// this file is configured by the CMakeDetermineSystem.cmake file
fpath = rootBin;
fpath += "/CMakeSystem.cmake";
- mf->ReadListFile(0,fpath.c_str());
+ mf->ReadListFile(fpath.c_str());
}
if(readCMakeSystem)
@@ -497,7 +491,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))
{
fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake");
- if(!mf->ReadListFile(0,fpath.c_str()))
+ if(!mf->ReadListFile(fpath.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: "
"CMakeSystemSpecificInitialize.cmake");
@@ -535,7 +529,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// to avoid duplicate compiler tests.
if(cmSystemTools::FileExists(fpath.c_str()))
{
- if(!mf->ReadListFile(0,fpath.c_str()))
+ if(!mf->ReadListFile(fpath.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: ",
fpath.c_str());
@@ -565,7 +559,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
determineCompiler += "Compiler.cmake";
std::string determineFile =
mf->GetModulesFile(determineCompiler.c_str());
- if(!mf->ReadListFile(0,determineFile.c_str()))
+ if(!mf->ReadListFile(determineFile.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: ",
determineCompiler.c_str());
@@ -599,7 +593,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
fpath += "/CMake";
fpath += lang;
fpath += "Compiler.cmake";
- if(!mf->ReadListFile(0,fpath.c_str()))
+ if(!mf->ReadListFile(fpath.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: ",
fpath.c_str());
@@ -618,7 +612,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
{
fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if(!mf->ReadListFile(0,fpath.c_str()))
+ if(!mf->ReadListFile(fpath.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: "
"CMakeSystemSpecificInformation.cmake");
@@ -709,7 +703,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
cmSystemTools::Error("Could not find cmake module file: ",
fpath.c_str());
}
- else if(!mf->ReadListFile(0, informationFile.c_str()))
+ else if(!mf->ReadListFile(informationFile.c_str()))
{
cmSystemTools::Error("Could not process cmake module file: ",
informationFile.c_str());
@@ -734,7 +728,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
testLang += lang;
testLang += "Compiler.cmake";
std::string ifpath = mf->GetModulesFile(testLang.c_str());
- if(!mf->ReadListFile(0,ifpath.c_str()))
+ if(!mf->ReadListFile(ifpath.c_str()))
{
cmSystemTools::Error("Could not find cmake module file: ",
testLang.c_str());
@@ -779,7 +773,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
projectCompatibility += "Compatibility.cmake";
if(cmSystemTools::FileExists(projectCompatibility.c_str()))
{
- mf->ReadListFile(0,projectCompatibility.c_str());
+ mf->ReadListFile(projectCompatibility.c_str());
}
// Inform any extra generator of the new language.
if (this->ExtraGenerator)
@@ -828,7 +822,6 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(strcmp(compilerId, "AppleClang") == 0)
{
- cmPolicies* policies = this->CMakeInstance->GetPolicies();
switch(mf->GetPolicyStatus(cmPolicies::CMP0025))
{
case cmPolicies::WARN:
@@ -836,7 +829,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025"))
{
std::ostringstream w;
- w << policies->GetPolicyWarning(cmPolicies::CMP0025) << "\n"
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0025) << "\n"
"Converting " << lang <<
" compiler id \"AppleClang\" to \"Clang\" for compatibility."
;
@@ -850,7 +843,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage(
cmake::FATAL_ERROR,
- policies->GetRequiredPolicyError(cmPolicies::CMP0025)
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025)
);
case cmPolicies::NEW:
// NEW behavior is to keep AppleClang.
@@ -860,7 +853,6 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(strcmp(compilerId, "QCC") == 0)
{
- cmPolicies* policies = this->CMakeInstance->GetPolicies();
switch(mf->GetPolicyStatus(cmPolicies::CMP0047))
{
case cmPolicies::WARN:
@@ -868,7 +860,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047"))
{
std::ostringstream w;
- w << policies->GetPolicyWarning(cmPolicies::CMP0047) << "\n"
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0047) << "\n"
"Converting " << lang <<
" compiler id \"QCC\" to \"GNU\" for compatibility."
;
@@ -890,7 +882,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage(
cmake::FATAL_ERROR,
- policies->GetRequiredPolicyError(cmPolicies::CMP0047)
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047)
);
case cmPolicies::NEW:
// NEW behavior is to keep QCC.
@@ -971,7 +963,7 @@ void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
cmMakefile* mf)
{
- this->LanguageEnabled[l] = true;
+ this->CMakeInstance->GetState()->SetLanguageEnabled(l);
// Fill the language-to-extension map with the current variable
// settings to make sure it is available for the try_compile()
@@ -1082,12 +1074,12 @@ bool cmGlobalGenerator::IgnoreFile(const char* ext) const
bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
{
- return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end());
+ return this->CMakeInstance->GetState()->GetLanguageEnabled(l);
}
void cmGlobalGenerator::ClearEnabledLanguages()
{
- this->LanguageEnabled.clear();
+ return this->CMakeInstance->GetState()->ClearEnabledLanguages();
}
void cmGlobalGenerator::Configure()
@@ -1096,21 +1088,20 @@ void cmGlobalGenerator::Configure()
this->ClearGeneratorMembers();
// start with this directory
- cmLocalGenerator *lg = this->CreateLocalGenerator();
+ cmLocalGenerator *lg = this->MakeLocalGenerator();
this->LocalGenerators.push_back(lg);
// set the Start directories
- cmMakefile* mf = lg->GetMakefile();
- lg->GetMakefile()->SetStartDirectory
- (this->CMakeInstance->GetStartDirectory());
- lg->GetMakefile()->SetStartOutputDirectory
- (this->CMakeInstance->GetStartOutputDirectory());
- lg->GetMakefile()->MakeStartDirectoriesCurrent();
+ lg->GetMakefile()->SetCurrentSourceDirectory
+ (this->CMakeInstance->GetHomeDirectory());
+ lg->GetMakefile()->SetCurrentBinaryDirectory
+ (this->CMakeInstance->GetHomeOutputDirectory());
- this->BinaryDirectories.insert(mf->GetStartOutputDirectory());
+ this->BinaryDirectories.insert(
+ this->CMakeInstance->GetHomeOutputDirectory());
// now do it
- lg->Configure();
+ lg->GetMakefile()->Configure();
// update the cache entry for the number of local generators, this is used
// for progress
@@ -1118,7 +1109,7 @@ void cmGlobalGenerator::Configure()
sprintf(num,"%d",static_cast<int>(this->LocalGenerators.size()));
this->GetCMakeInstance()->AddCacheEntry
("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num,
- "number of local generators", cmCacheManager::INTERNAL);
+ "number of local generators", cmState::INTERNAL);
// check for link libraries and include directories containing "NOTFOUND"
// and for infinite loops
@@ -1172,8 +1163,8 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
{
// If the property is not enabled then okay.
- if(!this->CMakeInstance
- ->GetPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
+ if(!this->CMakeInstance->GetState()
+ ->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
{
return true;
}
@@ -1227,6 +1218,7 @@ void cmGlobalGenerator::Generate()
this->CreateDefaultGlobalTargets(&globalTargets);
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
+ this->LocalGenerators[i]->ComputeObjectMaxPath();
cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
cmTargets* targets = &(mf->GetTargets());
cmTargets::iterator tit;
@@ -1281,11 +1273,15 @@ void cmGlobalGenerator::Generate()
// it builds by default.
this->FillLocalGeneratorToTargetMap();
+ for (i = 0; i < this->LocalGenerators.size(); ++i)
+ {
+ this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
+ }
+
// Generate project files
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
- this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem();
- this->SetCurrentLocalGenerator(this->LocalGenerators[i]);
+ this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile());
this->LocalGenerators[i]->Generate();
if(!this->LocalGenerators[i]->GetMakefile()->IsOn(
"CMAKE_SKIP_INSTALL_RULES"))
@@ -1297,7 +1293,7 @@ void cmGlobalGenerator::Generate()
(static_cast<float>(i)+1.0f)/
static_cast<float>(this->LocalGenerators.size()));
}
- this->SetCurrentLocalGenerator(0);
+ this->SetCurrentMakefile(0);
if(!this->GenerateCPackPropertiesFile())
{
@@ -1330,9 +1326,7 @@ void cmGlobalGenerator::Generate()
if(!this->CMP0042WarnTargets.empty())
{
std::ostringstream w;
- w <<
- (this->GetCMakeInstance()->GetPolicies()->
- GetPolicyWarning(cmPolicies::CMP0042)) << "\n";
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
w << "MACOSX_RPATH is not specified for"
" the following targets:\n";
for(std::set<std::string>::iterator
@@ -1373,10 +1367,18 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
cmTargets& targets =
this->LocalGenerators[i]->GetMakefile()->GetTargets();
+ std::vector<std::string> targetNames;
+ targetNames.reserve(targets.size());
for(cmTargets::iterator ti = targets.begin();
ti != targets.end(); ++ti)
{
- cmTarget& target = ti->second;
+ targetNames.push_back(ti->second.GetName());
+ }
+ for(std::vector<std::string>::iterator ti = targetNames.begin();
+ ti != targetNames.end(); ++ti)
+ {
+ cmTarget& target = *this->LocalGenerators[i]
+ ->GetMakefile()->FindTarget(*ti, true);
if(target.GetType() == cmTarget::EXECUTABLE ||
target.GetType() == cmTarget::STATIC_LIBRARY ||
target.GetType() == cmTarget::SHARED_LIBRARY ||
@@ -1391,7 +1393,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
cmQtAutoGenerators autogen;
if(autogen.InitializeAutogenTarget(&target))
{
- autogens.push_back(AutogensType::value_type(autogen, &target));
+ autogens.push_back(std::make_pair(autogen, &target));
}
}
}
@@ -1454,15 +1456,16 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf)
+void cmGlobalGenerator::CreateGeneratorTargets(cmLocalGenerator *lg)
{
cmGeneratorTargetsType generatorTargets;
+ cmMakefile* mf = lg->GetMakefile();
cmTargets& targets = mf->GetTargets();
for(cmTargets::iterator ti = targets.begin();
ti != targets.end(); ++ti)
{
cmTarget* t = &ti->second;
- cmGeneratorTarget* gt = new cmGeneratorTarget(t);
+ cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->ComputeTargetObjectDirectory(gt);
this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt;
@@ -1472,7 +1475,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf)
j = mf->GetOwnedImportedTargets().begin();
j != mf->GetOwnedImportedTargets().end(); ++j)
{
- cmGeneratorTarget* gt = new cmGeneratorTarget(*j);
+ cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
this->GeneratorTargets[*j] = gt;
generatorTargets[*j] = gt;
}
@@ -1485,7 +1488,7 @@ void cmGlobalGenerator::CreateGeneratorTargets()
// Construct per-target generator information.
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{
- this->CreateGeneratorTargets(this->LocalGenerators[i]->GetMakefile());
+ this->CreateGeneratorTargets(this->LocalGenerators[i]);
}
}
@@ -1540,11 +1543,10 @@ void cmGlobalGenerator::CheckLocalGenerators()
std::map<std::string, std::string> notFoundMap;
// std::set<std::string> notFoundMap;
// after it is all done do a ConfigureFinalPass
- cmCacheManager* manager = 0;
+ cmState* state = this->GetCMakeInstance()->GetState();
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
- manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
- this->LocalGenerators[i]->ConfigureFinalPass();
+ this->LocalGenerators[i]->GetMakefile()->ConfigureFinalPass();
cmTargets &targets =
this->LocalGenerators[i]->GetMakefile()->GetTargets();
for (cmTargets::iterator l = targets.begin();
@@ -1563,9 +1565,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
cmSystemTools::IsNOTFOUND(lib->first.c_str()))
{
std::string varName = lib->first.substr(0, lib->first.size()-9);
- cmCacheManager::CacheIterator it =
- manager->GetCacheIterator(varName.c_str());
- if(it.GetPropertyAsBool("ADVANCED"))
+ if(state->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
{
varName += " (ADVANCED)";
}
@@ -1573,7 +1573,8 @@ void cmGlobalGenerator::CheckLocalGenerators()
text += "\n linked by target \"";
text += l->second.GetName();
text += "\" in directory ";
- text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
+ text+=this->LocalGenerators[i]->GetMakefile()
+ ->GetCurrentSourceDirectory();
notFoundMap[varName] = text;
}
}
@@ -1596,16 +1597,14 @@ void cmGlobalGenerator::CheckLocalGenerators()
cmSystemTools::IsNOTFOUND(incDir->c_str()))
{
std::string varName = incDir->substr(0, incDir->size()-9);
- cmCacheManager::CacheIterator it =
- manager->GetCacheIterator(varName.c_str());
- if(it.GetPropertyAsBool("ADVANCED"))
+ if(state->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
{
varName += " (ADVANCED)";
}
std::string text = notFoundMap[varName];
text += "\n used as include directory in directory ";
text += this->LocalGenerators[i]
- ->GetMakefile()->GetCurrentDirectory();
+ ->GetMakefile()->GetCurrentSourceDirectory();
notFoundMap[varName] = text;
}
}
@@ -1645,7 +1644,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
// and there is a good chance that the try compile stuff will
// take the bulk of the time, so try and guess some progress
// by getting closer and closer to 100 without actually getting there.
- if (!this->CMakeInstance->GetCacheManager()->GetCacheValue
+ if (!this->CMakeInstance->GetState()->GetInitializedCacheValue
("CMAKE_NUMBER_OF_LOCAL_GENERATORS"))
{
// If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set
@@ -1681,14 +1680,14 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
return this->Build(srcdir,bindir,projectName,
newTarget,
- output,"",config,false,fast,
+ output,"",config,false,fast,false,
this->TryCompileTimeout);
}
void cmGlobalGenerator::GenerateBuildCommand(
std::vector<std::string>& makeCommand, const std::string&,
const std::string&, const std::string&, const std::string&,
- const std::string&, bool,
+ const std::string&, bool, bool,
std::vector<std::string> const&)
{
makeCommand.push_back(
@@ -1701,7 +1700,7 @@ int cmGlobalGenerator::Build(
std::string& output,
const std::string& makeCommandCSTR,
const std::string& config,
- bool clean, bool fast,
+ bool clean, bool fast, bool verbose,
double timeout,
cmSystemTools::OutputOption outputflag,
std::vector<std::string> const& nativeOptions)
@@ -1721,17 +1720,30 @@ int cmGlobalGenerator::Build(
std::string outputBuffer;
std::string* outputPtr = &outputBuffer;
+ std::vector<std::string> makeCommand;
+ this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
+ bindir, target, config, fast, verbose,
+ nativeOptions);
+
+ // Workaround to convince VCExpress.exe to produce output.
+ if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH &&
+ !makeCommand.empty() && cmSystemTools::LowerCase(
+ cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe")
+ {
+ outputflag = cmSystemTools::OUTPUT_NORMAL;
+ }
+
// should we do a clean first?
if (clean)
{
std::vector<std::string> cleanCommand;
this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
- bindir, "clean", config, fast);
+ bindir, "clean", config, fast, verbose);
output += "\nRun Clean Command:";
output += cmSystemTools::PrintSingleCommand(cleanCommand);
output += "\n";
- if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
+ if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr,
&retVal, 0, outputflag, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
@@ -1747,15 +1759,12 @@ int cmGlobalGenerator::Build(
}
// now build
- std::vector<std::string> makeCommand;
- this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
- bindir, target, config, fast, nativeOptions);
std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
output += "\nRun Build Command:";
output += makeCommandStr;
output += "\n";
- if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
+ if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr,
&retVal, 0, outputflag, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
@@ -1833,7 +1842,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
// update progress
// estimate how many lg there will be
const char *numGenC =
- this->CMakeInstance->GetCacheManager()->GetCacheValue
+ this->CMakeInstance->GetState()->GetInitializedCacheValue
("CMAKE_NUMBER_OF_LOCAL_GENERATORS");
if (!numGenC)
@@ -1875,11 +1884,23 @@ void cmGlobalGenerator::EnableInstallTarget()
this->InstallTargetEnabled = true;
}
-cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
+cmLocalGenerator *
+cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot,
+ cmLocalGenerator *parent)
{
- cmLocalGenerator *lg = new cmLocalGenerator;
- lg->SetGlobalGenerator(this);
- return lg;
+ if (!snapshot.IsValid())
+ {
+ snapshot = this->CMakeInstance->GetCurrentSnapshot();
+ }
+
+ return this->CreateLocalGenerator(parent, snapshot);
+}
+
+cmLocalGenerator*
+cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+{
+ return new cmLocalGenerator(this, parent, snapshot);
}
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
@@ -1891,9 +1912,11 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
"make program",
- cmCacheManager::FILEPATH);
+ cmState::FILEPATH);
// copy the enabled languages
- this->LanguageEnabled = gen->LanguageEnabled;
+ this->GetCMakeInstance()->GetState()->SetEnabledLanguages(
+ gen->GetCMakeInstance()->GetState()->GetEnabledLanguages()
+ );
this->LanguagesReady = gen->LanguagesReady;
this->ExtensionToLanguage = gen->ExtensionToLanguage;
this->IgnoreExtensions = gen->IgnoreExtensions;
@@ -1956,11 +1979,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
void
cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
{
- for(std::map<std::string, bool>::const_iterator i =
- this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i)
- {
- lang.push_back(i->first);
- }
+ lang = this->CMakeInstance->GetState()->GetEnabledLanguages();
}
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
@@ -2047,7 +2066,7 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
for(std::vector<cmLocalGenerator*>::const_iterator it =
this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
{
- std::string sd = (*it)->GetMakefile()->GetStartDirectory();
+ std::string sd = (*it)->GetMakefile()->GetCurrentSourceDirectory();
if (sd == start_dir)
{
return *it;
@@ -2124,20 +2143,13 @@ inline std::string removeQuotes(const std::string& s)
return s;
}
-void cmGlobalGenerator::SetCMakeInstance(cmake* cm)
-{
- // Store a pointer to the cmake object instance.
- this->CMakeInstance = cm;
-}
-
void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
{
cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
- const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
// CPack
- std::string workingDir = mf->GetStartOutputDirectory();
+ std::string workingDir = mf->GetCurrentBinaryDirectory();
cmCustomCommandLines cpackCommandLines;
std::vector<std::string> depends;
cmCustomCommandLine singleLine;
@@ -2148,7 +2160,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
singleLine.push_back(cmakeCfgIntDir);
}
singleLine.push_back("--config");
- std::string configFile = mf->GetStartOutputDirectory();;
+ std::string configFile = mf->GetCurrentBinaryDirectory();;
configFile += "/CPackConfig.cmake";
std::string relConfigFile = "./CPackConfig.cmake";
singleLine.push_back(relConfigFile);
@@ -2184,7 +2196,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
depends.erase(depends.begin(), depends.end());
singleLine.push_back(cmSystemTools::GetCPackCommand());
singleLine.push_back("--config");
- configFile = mf->GetStartOutputDirectory();;
+ configFile = mf->GetCurrentBinaryDirectory();;
configFile += "/CPackSourceConfig.cmake";
relConfigFile = "./CPackSourceConfig.cmake";
singleLine.push_back(relConfigFile);
@@ -2249,7 +2261,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
}
else
{
- singleLine.push_back(cmakeCommand);
+ singleLine.push_back(cmSystemTools::GetCMakeCommand());
singleLine.push_back("-E");
singleLine.push_back("echo");
singleLine.push_back("No interactive CMake dialog available.");
@@ -2270,7 +2282,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
- singleLine.push_back(cmakeCommand);
+ singleLine.push_back(cmSystemTools::GetCMakeCommand());
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
@@ -2299,15 +2311,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
std::ostringstream ostr;
if (!componentsSet->empty())
{
- ostr << "Available install components are:";
- std::set<std::string>::iterator it;
- for (
- it = componentsSet->begin();
- it != componentsSet->end();
- ++ it )
- {
- ostr << " \"" << *it << "\"";
- }
+ ostr << "Available install components are: ";
+ ostr << cmWrap('"', *componentsSet, '"', " ");
}
else
{
@@ -2319,7 +2324,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
ostr.str().c_str(),
&cpackCommandLines, depends, 0, /*uses_terminal*/false);
}
- std::string cmd = cmakeCommand;
+ std::string cmd = cmSystemTools::GetCMakeCommand();
cpackCommandLines.erase(cpackCommandLines.begin(),
cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
@@ -2399,8 +2404,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
//----------------------------------------------------------------------------
const char* cmGlobalGenerator::GetPredefinedTargetsFolder()
{
- const char* prop =
- this->GetCMakeInstance()->GetProperty("PREDEFINED_TARGETS_FOLDER");
+ const char* prop = this->GetCMakeInstance()->GetState()
+ ->GetGlobalProperty("PREDEFINED_TARGETS_FOLDER");
if (prop)
{
@@ -2413,7 +2418,8 @@ const char* cmGlobalGenerator::GetPredefinedTargetsFolder()
//----------------------------------------------------------------------------
bool cmGlobalGenerator::UseFolderProperty()
{
- const char* prop = this->GetCMakeInstance()->GetProperty("USE_FOLDERS");
+ const char* prop = this->GetCMakeInstance()->GetState()
+ ->GetGlobalProperty("USE_FOLDERS");
// If this property is defined, let the setter turn this on or off...
//
@@ -2429,38 +2435,6 @@ bool cmGlobalGenerator::UseFolderProperty()
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
-{
- this->FindMakeProgram(mf);
- std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- std::vector<std::string> locations;
- locations.push_back(cmSystemTools::GetProgramPath(makeProgram));
- locations.push_back("/mingw/bin");
- locations.push_back("c:/mingw/bin");
- std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
- std::string gcc = "gcc.exe";
- if(!tgcc.empty())
- {
- gcc = tgcc;
- }
- std::string tgxx = cmSystemTools::FindProgram("g++", locations);
- std::string gxx = "g++.exe";
- if(!tgxx.empty())
- {
- gxx = tgxx;
- }
- std::string trc = cmSystemTools::FindProgram("windres", locations);
- std::string rc = "windres.exe";
- if(!trc.empty())
- {
- rc = trc;
- }
- mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
-}
-
-//----------------------------------------------------------------------------
cmTarget cmGlobalGenerator::CreateGlobalTarget(
const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
@@ -2470,7 +2444,6 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
{
// Package
cmTarget target;
- target.GetProperties().SetCMakeInstance(this->CMakeInstance);
target.SetType(cmTarget::GLOBAL_TARGET, name);
target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
@@ -2575,17 +2548,12 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
"test", "RUN_TESTS",
"package", "PACKAGE",
"package_source",
- "ZERO_CHECK",
- 0
+ "ZERO_CHECK"
};
- for(const char** reservedTarget = reservedTargets;
- *reservedTarget; ++reservedTarget)
- {
- if(name == *reservedTarget) return true;
- }
-
- return false;
+ return std::find(cmArrayBegin(reservedTargets),
+ cmArrayEnd(reservedTargets), name)
+ != cmArrayEnd(reservedTargets);
}
void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
@@ -2941,14 +2909,11 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
{
target->GetSourceFiles(sources, *ci);
}
- std::set<cmSourceFile*> emitted;
+ std::vector<cmSourceFile*>::const_iterator sourcesEnd
+ = cmRemoveDuplicates(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
+ si != sourcesEnd; ++si)
{
- if (!emitted.insert(*si).second)
- {
- continue;
- }
Json::Value& lj_source = lj_sources.append(Json::objectValue);
cmSourceFile* sf = *si;
std::string const& sfp = sf->GetFullPath();
@@ -3034,7 +2999,7 @@ void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile,
//----------------------------------------------------------------------------
void cmGlobalGenerator::ProcessEvaluationFiles()
{
- std::set<std::string> generatedFiles;
+ std::vector<std::string> generatedFiles;
for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
li = this->EvaluationFiles.begin();
li != this->EvaluationFiles.end();
@@ -3046,16 +3011,24 @@ void cmGlobalGenerator::ProcessEvaluationFiles()
return;
}
std::vector<std::string> files = (*li)->GetFiles();
- for(std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi)
+ std::sort(files.begin(), files.end());
+
+ std::vector<std::string> intersection;
+ std::set_intersection(files.begin(), files.end(),
+ generatedFiles.begin(), generatedFiles.end(),
+ std::back_inserter(intersection));
+ if (!intersection.empty())
{
- if (!generatedFiles.insert(*fi).second)
- {
- cmSystemTools::Error("File to be generated by multiple different "
- "commands: ", fi->c_str());
- return;
- }
+ cmSystemTools::Error("Files to be generated by multiple different "
+ "commands: ", cmWrap('"', intersection, '"', " ").c_str());
+ return;
}
+
+ generatedFiles.insert(generatedFiles.end(),
+ files.begin(), files.end());
+ std::vector<std::string>::iterator newIt =
+ generatedFiles.end() - files.size();
+ std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end());
}
}
@@ -3077,7 +3050,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
std::vector<std::string> configs;
std::string config = mf->GetConfigurations(configs, false);
- std::string path = this->CMakeInstance->GetStartOutputDirectory();
+ std::string path = this->CMakeInstance->GetHomeOutputDirectory();
path += "/CPackProperties.cmake";
if(!cmSystemTools::FileExists(path.c_str()) && installedFiles.empty())