summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt4
-rw-r--r--Source/CMakeVersion.cmake6
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx10
-rw-r--r--Source/CPack/cmCPackGenerator.cxx7
-rw-r--r--Source/CPack/cpack.cxx7
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx2
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx103
-rw-r--r--Source/CTest/cmCTestBuildHandler.h10
-rw-r--r--Source/CTest/cmCTestCVS.cxx12
-rw-r--r--Source/CTest/cmCTestCVS.h4
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx43
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx305
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h6
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx18
-rw-r--r--Source/CTest/cmCTestGlobalVC.h6
-rw-r--r--Source/CTest/cmCTestLaunch.cxx130
-rw-r--r--Source/CTest/cmCTestLaunch.h12
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx90
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h3
-rw-r--r--Source/CTest/cmCTestRunTest.cxx4
-rw-r--r--Source/CTest/cmCTestSVN.cxx6
-rw-r--r--Source/CTest/cmCTestSVN.h2
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx11
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx333
-rw-r--r--Source/CTest/cmCTestTestHandler.h13
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx63
-rw-r--r--Source/CTest/cmCTestUploadHandler.cxx46
-rw-r--r--Source/CTest/cmCTestVC.cxx38
-rw-r--r--Source/CTest/cmCTestVC.h7
-rw-r--r--Source/Checks/cm_cxx11_unordered_map.cmake25
-rw-r--r--Source/Checks/cm_cxx11_unordered_map.cpp6
-rw-r--r--Source/CursesDialog/ccmake.cxx2
-rw-r--r--Source/QtDialog/CMakeSetup.cxx2
-rw-r--r--Source/cmCTest.cxx154
-rw-r--r--Source/cmCTest.h9
-rw-r--r--Source/cmCacheManager.cxx11
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx9
-rw-r--r--Source/cmConditionEvaluator.cxx10
-rw-r--r--Source/cmConfigure.cmake.h.in1
-rw-r--r--Source/cmDefinitions.cxx104
-rw-r--r--Source/cmDefinitions.h53
-rw-r--r--Source/cmExecutionStatus.h29
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx6
-rw-r--r--Source/cmExtraKateGenerator.cxx2
-rw-r--r--Source/cmExtraQbsGenerator.cxx260
-rw-r--r--Source/cmExtraQbsGenerator.h48
-rw-r--r--Source/cmFileCommand.cxx51
-rw-r--r--Source/cmFileTimeComparison.cxx12
-rw-r--r--Source/cmForEachCommand.cxx24
-rw-r--r--Source/cmForEachCommand.h5
-rw-r--r--Source/cmFunctionCommand.cxx2
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx17
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h5
-rw-r--r--Source/cmGlobalGenerator.cxx52
-rw-r--r--Source/cmGlobalGenerator.h39
-rw-r--r--Source/cmGlobalGeneratorFactory.h9
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx11
-rw-r--r--Source/cmGlobalGhsMultiGenerator.h5
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.cxx25
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.h5
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.cxx17
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.h5
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.cxx19
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.h5
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx25
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h5
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx55
-rw-r--r--Source/cmGlobalNinjaGenerator.h10
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx15
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h10
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx24
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx28
-rw-r--r--Source/cmGlobalVisualStudio11Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx26
-rw-r--r--Source/cmGlobalVisualStudio12Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx26
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx9
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx36
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h10
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx157
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h22
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx48
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h9
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx33
-rw-r--r--Source/cmGlobalVisualStudio9Generator.h5
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx20
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h23
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx26
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h5
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx25
-rw-r--r--Source/cmGlobalXCodeGenerator.h5
-rw-r--r--Source/cmGraphVizWriter.cxx7
-rw-r--r--Source/cmListFileCache.cxx49
-rw-r--r--Source/cmListFileCache.h10
-rw-r--r--Source/cmLocalGenerator.cxx298
-rw-r--r--Source/cmLocalGenerator.h30
-rw-r--r--Source/cmLocalGhsMultiGenerator.cxx36
-rw-r--r--Source/cmLocalGhsMultiGenerator.h21
-rw-r--r--Source/cmLocalNinjaGenerator.cxx9
-rw-r--r--Source/cmLocalNinjaGenerator.h12
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx43
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h49
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx7
-rw-r--r--Source/cmLocalVisualStudio10Generator.h5
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx11
-rw-r--r--Source/cmLocalVisualStudio6Generator.h3
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx113
-rw-r--r--Source/cmLocalVisualStudio7Generator.h12
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx19
-rw-r--r--Source/cmLocalVisualStudioGenerator.h26
-rw-r--r--Source/cmLocalXCodeGenerator.cxx5
-rw-r--r--Source/cmLocalXCodeGenerator.h3
-rw-r--r--Source/cmMakefile.cxx341
-rw-r--r--Source/cmMakefile.h93
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx20
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx22
-rw-r--r--Source/cmNinjaTargetGenerator.cxx24
-rw-r--r--Source/cmNinjaTargetGenerator.h3
-rw-r--r--Source/cmPolicies.h3
-rw-r--r--Source/cmQtAutoGenerators.cxx46
-rw-r--r--Source/cmState.cxx257
-rw-r--r--Source/cmState.h49
-rw-r--r--Source/cmTarget.cxx45
-rw-r--r--Source/cmTarget.h17
-rw-r--r--Source/cmTest.h5
-rw-r--r--Source/cmTryRunCommand.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx142
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h1
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx26
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h2
-rw-r--r--Source/cmWhileCommand.cxx17
-rw-r--r--Source/cmWhileCommand.h5
-rw-r--r--Source/cmXMLWriter.cxx134
-rw-r--r--Source/cmXMLWriter.h120
-rw-r--r--Source/cmake.cxx144
-rw-r--r--Source/cmake.h13
-rw-r--r--Source/cmakemain.cxx8
-rw-r--r--Source/cmcmd.cxx84
-rw-r--r--Source/ctest.cxx2
-rw-r--r--Source/kwsys/CMakeLists.txt3
-rw-r--r--Source/kwsys/SystemTools.cxx44
-rw-r--r--Source/kwsys/testSystemTools.cxx18
147 files changed, 2720 insertions, 2764 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 6f12785..a7adb51 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -233,8 +233,6 @@ set(SRCS
cmExtraKateGenerator.h
cmExtraSublimeTextGenerator.cxx
cmExtraSublimeTextGenerator.h
- cmExtraQbsGenerator.cxx
- cmExtraQbsGenerator.h
cmFileLock.cxx
cmFileLock.h
cmFileLockPool.cxx
@@ -349,6 +347,8 @@ set(SRCS
cmXMLParser.h
cmXMLSafe.cxx
cmXMLSafe.h
+ cmXMLWriter.cxx
+ cmXMLWriter.h
cmake.cxx
cmake.h
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 060aedd..26a3b8a 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 2)
-set(CMake_VERSION_PATCH 20150519)
-#set(CMake_VERSION_RC 1)
+set(CMake_VERSION_MINOR 3)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 2)
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 0137374..5049a3f 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -283,8 +283,6 @@ int cmCPackDebGenerator::PackageFiles()
int cmCPackDebGenerator::createDeb()
{
- const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
-
// debian-binary file
std::string dbfilename;
dbfilename += this->GetOption("GEN_WDIR");
@@ -420,15 +418,15 @@ int cmCPackDebGenerator::createDeb()
} else if(!strcmp(debian_compression_type, "bzip2")) {
compression_suffix = ".bz2";
compression_modifier = "j";
- cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else if(!strcmp(debian_compression_type, "gzip")) {
compression_suffix = ".gz";
compression_modifier = "z";
- cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else if(!strcmp(debian_compression_type, "none")) {
compression_suffix = "";
compression_modifier = "";
- cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error unrecognized compression type: "
@@ -501,7 +499,7 @@ int cmCPackDebGenerator::createDeb()
fileIt != packageFiles.end(); ++ fileIt )
{
cmd = "\"";
- cmd += cmakeExecutable;
+ cmd += cmSystemTools::GetCMakeCommand();
cmd += "\" -E md5sum \"";
cmd += *fileIt;
cmd += "\"";
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index e254e9a..bf4df60 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -711,11 +711,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
- cmGlobalGenerator gg;
- gg.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cmGlobalGenerator gg(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile();
std::string realInstallDirectory = tempInstallDirectory;
if ( !installSubDirectory.empty() && installSubDirectory != "/" )
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 2207873..c2fe763 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -198,10 +198,11 @@ int main (int argc, char const* const* argv)
"Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst;
+ cminst.SetHomeDirectory("");
+ cminst.SetHomeOutputDirectory("");
cminst.GetState()->RemoveUnscriptableCommands();
- cmGlobalGenerator cmgg;
- cmgg.SetCMakeInstance(&cminst);
- cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());
+ cmGlobalGenerator cmgg(&cminst);
+ cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator());
cmMakefile* globalMF = cmlg->GetMakefile();
#if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 586070b..20d303d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -204,6 +204,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
std::string cmakeOutString;
cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
static_cast<void>(captureRAII);
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 29e07ef..e141b60 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -18,7 +18,7 @@
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmGeneratedFileStream.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include "cmFileTimeComparison.h"
#include "cmAlgorithms.h"
@@ -68,13 +68,13 @@ static const char* cmCTestErrorMatches[] = {
"^CMake Error.*:",
":[ \\t]cannot find",
":[ \\t]can't find",
- ": \\*\\*\\* No rule to make target \\[`'].*\\'. Stop",
+ ": \\*\\*\\* No rule to make target [`'].*\\'. Stop",
": \\*\\*\\* No targets specified and no makefile found",
": Invalid loader fixup for symbol",
": Invalid fixups exist",
": Can't find library for",
": internal link edit command failed",
- ": Unrecognized option \\[`'].*\\'",
+ ": Unrecognized option [`'].*\\'",
"\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([^WI]\\)",
"ld: 0706-006 Cannot find or open library file: -l ",
"ild: \\(argument error\\) can't find library argument ::",
@@ -523,16 +523,17 @@ int cmCTestBuildHandler::ProcessHandler()
<< std::endl);
return -1;
}
- this->GenerateXMLHeader(xofs);
+ cmXMLWriter xml(xofs);
+ this->GenerateXMLHeader(xml);
if(this->UseCTestLaunch)
{
- this->GenerateXMLLaunched(xofs);
+ this->GenerateXMLLaunched(xml);
}
else
{
- this->GenerateXMLLogScraped(xofs);
+ this->GenerateXMLLogScraped(xml);
}
- this->GenerateXMLFooter(xofs, elapsed_build_time);
+ this->GenerateXMLFooter(xml, elapsed_build_time);
if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0)
{
@@ -552,17 +553,14 @@ int cmCTestBuildHandler::ProcessHandler()
}
//----------------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateXMLHeader(std::ostream& os)
+void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
{
- this->CTest->StartXML(os, this->AppendXML);
- os << "<Build>\n"
- << "\t<StartDateTime>" << this->StartBuild << "</StartDateTime>\n"
- << "\t<StartBuildTime>" <<
- static_cast<unsigned int>(this->StartBuildTime)
- << "</StartBuildTime>\n"
- << "<BuildCommand>"
- << cmXMLSafe(this->GetMakeCommand())
- << "</BuildCommand>" << std::endl;
+ this->CTest->StartXML(xml, this->AppendXML);
+ xml.StartElement("Build");
+ xml.Element("StartDateTime", this->StartBuild);
+ xml.Element("StartBuildTime",
+ static_cast<unsigned int>(this->StartBuildTime));
+ xml.Element("BuildCommand", this->GetMakeCommand());
}
//----------------------------------------------------------------------------
@@ -591,7 +589,7 @@ private:
};
//----------------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os)
+void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
{
if(this->CTestLaunchDir.empty())
{
@@ -632,12 +630,12 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os)
for(Fragments::const_iterator fi = fragments.begin();
fi != fragments.end(); ++fi)
{
- this->GenerateXMLLaunchedFragment(os, fi->c_str());
+ xml.FragmentFile(fi->c_str());
}
}
//----------------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
+void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
{
std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
std::vector<cmCTestBuildErrorWarning>::iterator it;
@@ -665,10 +663,9 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
{
numWarningsAllowed--;
}
- os << "\t<" << (cm->Error ? "Error" : "Warning") << ">\n"
- << "\t\t<BuildLogLine>" << cm->LogLine << "</BuildLogLine>\n"
- << "\t\t<Text>" << cmXMLSafe(cm->Text).Quotes(false)
- << "\n</Text>" << std::endl;
+ xml.StartElement(cm->Error ? "Error" : "Warning");
+ xml.Element("BuildLogLine", cm->LogLine);
+ xml.Element("Text", cm->Text);
std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
for ( rit = this->ErrorWarningFileLineRegex.begin();
rit != this->ErrorWarningFileLineRegex.end(); ++ rit )
@@ -706,62 +703,48 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
{
if (!cm->SourceFile.empty())
{
- os << "\t\t<SourceFile>" << cm->SourceFile << "</SourceFile>"
- << std::endl;
+ xml.Element("SourceFile", cm->SourceFile);
}
if (!cm->SourceFileTail.empty())
{
- os << "\t\t<SourceFileTail>" << cm->SourceFileTail
- << "</SourceFileTail>" << std::endl;
+ xml.Element("SourceFileTail", cm->SourceFileTail);
}
if ( cm->LineNumber >= 0 )
{
- os << "\t\t<SourceLineNumber>" << cm->LineNumber
- << "</SourceLineNumber>" << std::endl;
+ xml.Element("SourceLineNumber", cm->LineNumber);
}
}
- os << "\t\t<PreContext>" << cmXMLSafe(cm->PreContext).Quotes(false)
- << "</PreContext>\n"
- << "\t\t<PostContext>" << cmXMLSafe(cm->PostContext).Quotes(false);
+ xml.Element("PreContext", cm->PreContext);
+ xml.StartElement("PostContext");
+ xml.Content(cm->PostContext);
// is this the last warning or error, if so notify
if ((cm->Error && !numErrorsAllowed) ||
(!cm->Error && !numWarningsAllowed))
{
- os << "\nThe maximum number of reported warnings or errors has been "
- "reached!!!\n";
+ xml.Content("\nThe maximum number of reported warnings or errors "
+ "has been reached!!!\n");
}
- os << "</PostContext>\n"
- << "\t\t<RepeatCount>0</RepeatCount>\n"
- << "</" << (cm->Error ? "Error" : "Warning") << ">\n\n"
- << std::endl;
+ xml.EndElement(); // PostContext
+ xml.Element("RepeatCount", "0");
+ xml.EndElement(); // "Error" / "Warning"
}
}
}
//----------------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateXMLFooter(std::ostream& os,
+void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
double elapsed_build_time)
{
- os << "\t<Log Encoding=\"base64\" Compression=\"/bin/gzip\">\n\t</Log>\n"
- << "\t<EndDateTime>" << this->EndBuild << "</EndDateTime>\n"
- << "\t<EndBuildTime>" << static_cast<unsigned int>(this->EndBuildTime)
- << "</EndBuildTime>\n"
- << "<ElapsedMinutes>" << static_cast<int>(elapsed_build_time/6)/10.0
- << "</ElapsedMinutes>"
- << "</Build>" << std::endl;
- this->CTest->EndXML(os);
-}
-
-//----------------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os,
- const char* fname)
-{
- cmsys::ifstream fin(fname, std::ios::in | std::ios::binary);
- std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- os << line << "\n";
- }
+ xml.StartElement("Log");
+ xml.Attribute("Encoding", "base64");
+ xml.Attribute("Compression", "bin/gzip");
+ xml.EndElement(); // Log
+
+ xml.Element("EndDateTime", this->EndBuild);
+ xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
+ xml.Element("ElapsedMinutes", static_cast<int>(elapsed_build_time/6)/10.0);
+ xml.EndElement(); // Build
+ this->CTest->EndXML(xml);
}
//----------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index d13d5cf..2e9b92a 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -22,6 +22,7 @@
#include <deque>
class cmMakefile;
+class cmXMLWriter;
/** \class cmCTestBuildHandler
* \brief A class that handles ctest -S invocations
@@ -86,11 +87,10 @@ private:
};
// generate the XML output
- void GenerateXMLHeader(std::ostream& os);
- void GenerateXMLLaunched(std::ostream& os);
- void GenerateXMLLogScraped(std::ostream& os);
- void GenerateXMLFooter(std::ostream& os, double elapsed_build_time);
- void GenerateXMLLaunchedFragment(std::ostream& os, const char* fname);
+ void GenerateXMLHeader(cmXMLWriter& xml);
+ void GenerateXMLLaunched(cmXMLWriter& xml);
+ void GenerateXMLLogScraped(cmXMLWriter& xml);
+ void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
bool IsLaunchedErrorFile(const char* fname);
bool IsLaunchedWarningFile(const char* fname);
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index ab363d0..0fb3fec 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
@@ -266,13 +266,13 @@ void cmCTestCVS::LoadRevisions(std::string const& file,
}
//----------------------------------------------------------------------------
-void cmCTestCVS::WriteXMLDirectory(std::ostream& xml,
+void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
std::string const& path,
Directory const& dir)
{
const char* slash = path.empty()? "":"/";
- xml << "\t<Directory>\n"
- << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
+ xml.StartElement("Directory");
+ xml.Element("Name", path);
// Lookup the branch checked out in the working tree.
std::string branchFlag = this->ComputeBranchFlag(path);
@@ -298,11 +298,11 @@ void cmCTestCVS::WriteXMLDirectory(std::ostream& xml,
File f(fi->second, &revisions[0], &revisions[1]);
this->WriteXMLEntry(xml, path, fi->first, full, f);
}
- xml << "\t</Directory>\n";
+ xml.EndElement(); // Directory
}
//----------------------------------------------------------------------------
-bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml)
+bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per updated file):\n"
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index 64e1747..f2c0a73 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -29,7 +29,7 @@ public:
private:
// Implement cmCTestVC internal API.
virtual bool UpdateImpl();
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
// Update status for files in each directory.
class Directory: public std::map<std::string, PathStatus> {};
@@ -38,7 +38,7 @@ private:
std::string ComputeBranchFlag(std::string const& dir);
void LoadRevisions(std::string const& file, const char* branchFlag,
std::vector<Revision>& revisions);
- void WriteXMLDirectory(std::ostream& xml, std::string const& path,
+ void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
Directory const& dir);
// Parsing helper classes.
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index 3b444f2..2e8aeb9 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -15,7 +15,7 @@
#include "cmCTest.h"
#include "cmGeneratedFileStream.h"
#include "cmake.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/Process.h>
@@ -89,33 +89,22 @@ int cmCTestConfigureHandler::ProcessHandler()
if ( os )
{
- this->CTest->StartXML(os, this->AppendXML);
- os << "<Configure>\n"
- << "\t<StartDateTime>" << start_time << "</StartDateTime>"
- << std::endl
- << "\t<StartConfigureTime>" << start_time_time
- << "</StartConfigureTime>\n";
-
- if ( res == cmsysProcess_State_Exited && retVal )
- {
- os << retVal;
- }
- os << "<ConfigureCommand>" << cCommand << "</ConfigureCommand>"
- << std::endl;
+ cmXMLWriter xml(os);
+ this->CTest->StartXML(xml, this->AppendXML);
+ xml.StartElement("Configure");
+ xml.Element("StartDateTime", start_time);
+ xml.Element("StartConfigureTime", start_time_time);
+ xml.Element("ConfigureCommand", cCommand);
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
- os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl;
- std::string end_time = this->CTest->CurrentTime();
- os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
- << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
- << "\t<EndConfigureTime>" <<
- static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndConfigureTime>\n"
- << "<ElapsedMinutes>"
- << static_cast<int>(
- (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
- << "</ElapsedMinutes>"
- << "</Configure>" << std::endl;
- this->CTest->EndXML(os);
+ xml.Element("Log", output);
+ xml.Element("ConfigureStatus", retVal);
+ xml.Element("EndDateTime", this->CTest->CurrentTime());
+ xml.Element("EndConfigureTime",
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("ElapsedMinutes", static_cast<int>(
+ (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ xml.EndElement(); // Configure
+ this->CTest->EndXML(xml);
}
}
else
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 790e488..f92f19a 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -22,7 +22,7 @@
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmGeneratedFileStream.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/Process.h>
#include <cmsys/RegularExpression.hxx>
@@ -185,14 +185,6 @@ bool cmCTestCoverageHandler::StartCoverageLogFile(
<< covLogFilename << std::endl);
return false;
}
- std::string local_start_time = this->CTest->CurrentTime();
- this->CTest->StartXML(covLogFile, this->AppendXML);
- covLogFile << "<CoverageLog>" << std::endl
- << "\t<StartDateTime>" << local_start_time << "</StartDateTime>"
- << "\t<StartTime>"
- << static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</StartTime>"
- << std::endl;
return true;
}
@@ -200,13 +192,6 @@ bool cmCTestCoverageHandler::StartCoverageLogFile(
void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr,
int logFileCount)
{
- std::string local_end_time = this->CTest->CurrentTime();
- ostr << "\t<EndDateTime>" << local_end_time << "</EndDateTime>" << std::endl
- << "\t<EndTime>" <<
- static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndTime>" << std::endl
- << "</CoverageLog>" << std::endl;
- this->CTest->EndXML(ostr);
char covLogFilename[1024];
sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Close file: "
@@ -215,6 +200,25 @@ void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr,
}
//----------------------------------------------------------------------
+void cmCTestCoverageHandler::StartCoverageLogXML(cmXMLWriter& xml)
+{
+ this->CTest->StartXML(xml, this->AppendXML);
+ xml.StartElement("CoverageLog");
+ xml.Element("StartDateTime", this->CTest->CurrentTime());
+ xml.Element("StartTime",
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
+}
+
+//----------------------------------------------------------------------
+void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
+{
+ xml.Element("EndDateTime", this->CTest->CurrentTime());
+ xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.EndElement(); // CoverageLog
+ this->CTest->EndXML(xml);
+}
+
+//----------------------------------------------------------------------
bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
const char* srcDir,
const char* binDir)
@@ -451,6 +455,8 @@ int cmCTestCoverageHandler::ProcessHandler()
}
cmGeneratedFileStream covSumFile;
cmGeneratedFileStream covLogFile;
+ cmXMLWriter covSumXML(covSumFile);
+ cmXMLWriter covLogXML(covLogFile);
if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
{
@@ -458,20 +464,21 @@ int cmCTestCoverageHandler::ProcessHandler()
"Cannot open coverage summary file." << std::endl);
return -1;
}
+ covSumFile.setf(std::ios::fixed, std::ios::floatfield);
+ covSumFile.precision(2);
- this->CTest->StartXML(covSumFile, this->AppendXML);
+ this->CTest->StartXML(covSumXML, this->AppendXML);
// Produce output xml files
- covSumFile << "<Coverage>" << std::endl
- << "\t<StartDateTime>" << coverage_start_time << "</StartDateTime>"
- << std::endl
- << "\t<StartTime>" << coverage_start_time_time << "</StartTime>"
- << std::endl;
+ covSumXML.StartElement("Coverage");
+ covSumXML.Element("StartDateTime", coverage_start_time);
+ covSumXML.Element("StartTime", coverage_start_time_time);
int logFileCount = 0;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
{
return -1;
}
+ this->StartCoverageLogXML(covLogXML);
cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator fileIterator;
int cnt = 0;
long total_tested = 0;
@@ -528,12 +535,14 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( ++cnt % 100 == 0 )
{
+ this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
logFileCount ++;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
{
return -1;
}
+ this->StartCoverageLogXML(covLogXML);
}
const std::string fileName
@@ -542,9 +551,10 @@ int cmCTestCoverageHandler::ProcessHandler()
this->CTest->GetShortPathToFile(fullFileName.c_str());
const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
= fileIterator->second;
- covLogFile << "\t<File Name=\"" << cmXMLSafe(fileName)
- << "\" FullPath=\"" << cmXMLSafe(shortFileName) << "\">\n"
- << "\t\t<Report>" << std::endl;
+ covLogXML.StartElement("File");
+ covLogXML.Attribute("Name", fileName);
+ covLogXML.Attribute("FullPath", shortFileName);
+ covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullFileName.c_str());
if ( !ifs)
@@ -576,9 +586,11 @@ int cmCTestCoverageHandler::ProcessHandler()
error ++;
break;
}
- covLogFile << "\t\t<Line Number=\"" << cc << "\" Count=\"" << fcov[cc]
- << "\">"
- << cmXMLSafe(line) << "</Line>" << std::endl;
+ covLogXML.StartElement("Line");
+ covLogXML.Attribute("Number", cc);
+ covLogXML.Attribute("Count", fcov[cc]);
+ covLogXML.Content(line);
+ covLogXML.EndElement(); // Line
if ( fcov[cc] == 0 )
{
untested ++;
@@ -605,24 +617,19 @@ int cmCTestCoverageHandler::ProcessHandler()
}
total_tested += tested;
total_untested += untested;
- covLogFile << "\t\t</Report>" << std::endl
- << "\t</File>" << std::endl;
- covSumFile << "\t<File Name=\"" << cmXMLSafe(fileName)
- << "\" FullPath=\"" << cmXMLSafe(
- this->CTest->GetShortPathToFile(fullFileName.c_str()))
- << "\" Covered=\"" << (tested+untested > 0 ? "true":"false") << "\">\n"
- << "\t\t<LOCTested>" << tested << "</LOCTested>\n"
- << "\t\t<LOCUnTested>" << untested << "</LOCUnTested>\n"
- << "\t\t<PercentCoverage>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile << (cper) << "</PercentCoverage>\n"
- << "\t\t<CoverageMetric>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile << (cmet) << "</CoverageMetric>\n";
- this->WriteXMLLabels(covSumFile, shortFileName);
- covSumFile << "\t</File>" << std::endl;
+ covLogXML.EndElement(); // Report
+ covLogXML.EndElement(); // File
+ covSumXML.StartElement("File");
+ covSumXML.Attribute("Name", fileName);
+ covSumXML.Attribute("FullPath",
+ this->CTest->GetShortPathToFile(fullFileName.c_str()));
+ covSumXML.Attribute("Covered", tested + untested > 0 ? "true" : "false");
+ covSumXML.Element("LOCTested", tested);
+ covSumXML.Element("LOCUnTested", untested);
+ covSumXML.Element("PercentCoverage", cper);
+ covSumXML.Element("CoverageMetric", cmet);
+ this->WriteXMLLabels(covSumXML, shortFileName);
+ covSumXML.EndElement(); // File
}
//Handle all the files in the extra coverage globs that have no cov data
@@ -632,9 +639,10 @@ int cmCTestCoverageHandler::ProcessHandler()
std::string fileName = cmSystemTools::GetFilenameName(*i);
std::string fullPath = cont.SourceDir + "/" + *i;
- covLogFile << "\t<File Name=\"" << cmXMLSafe(fileName)
- << "\" FullPath=\"" << cmXMLSafe(*i) << "\">\n"
- << "\t\t<Report>" << std::endl;
+ covLogXML.StartElement("File");
+ covLogXML.Attribute("Name", fileName);
+ covLogXML.Attribute("FullPath", *i);
+ covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullPath.c_str());
if (!ifs)
@@ -651,24 +659,30 @@ int cmCTestCoverageHandler::ProcessHandler()
"Actually performing coverage for: " << *i << std::endl, this->Quiet);
while (cmSystemTools::GetLineFromStream(ifs, line))
{
- covLogFile << "\t\t<Line Number=\"" << untested << "\" Count=\"0\">"
- << cmXMLSafe(line) << "</Line>" << std::endl;
+ covLogXML.StartElement("Line");
+ covLogXML.Attribute("Number", untested);
+ covLogXML.Attribute("Count", 0);
+ covLogXML.Content(line);
+ covLogXML.EndElement(); // Line
untested ++;
}
- covLogFile << "\t\t</Report>\n\t</File>" << std::endl;
+ covLogXML.EndElement(); // Report
+ covLogXML.EndElement(); // File
total_untested += untested;
- covSumFile << "\t<File Name=\"" << cmXMLSafe(fileName)
- << "\" FullPath=\"" << cmXMLSafe(i->c_str())
- << "\" Covered=\"true\">\n"
- << "\t\t<LOCTested>0</LOCTested>\n"
- << "\t\t<LOCUnTested>" << untested << "</LOCUnTested>\n"
- << "\t\t<PercentCoverage>0</PercentCoverage>\n"
- << "\t\t<CoverageMetric>0</CoverageMetric>\n";
- this->WriteXMLLabels(covSumFile, *i);
- covSumFile << "\t</File>" << std::endl;
- }
-
+ covSumXML.StartElement("File");
+ covSumXML.Attribute("Name", fileName);
+ covSumXML.Attribute("FullPath", *i);
+ covSumXML.Attribute("Covered", "true");
+ covSumXML.Element("LOCTested", 0);
+ covSumXML.Element("LOCUnTested", untested);
+ covSumXML.Element("PercentCoverage", 0);
+ covSumXML.Element("CoverageMetric", 0);
+ this->WriteXMLLabels(covSumXML, *i);
+ covSumXML.EndElement(); // File
+ }
+
+ this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
if (!errorsWhileAccumulating.empty())
@@ -696,22 +710,17 @@ int cmCTestCoverageHandler::ProcessHandler()
std::string end_time = this->CTest->CurrentTime();
- covSumFile << "\t<LOCTested>" << total_tested << "</LOCTested>\n"
- << "\t<LOCUntested>" << total_untested << "</LOCUntested>\n"
- << "\t<LOC>" << total_lines << "</LOC>\n"
- << "\t<PercentCoverage>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile << (percent_coverage)<< "</PercentCoverage>\n"
- << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
- << "\t<EndTime>" <<
- static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndTime>\n";
- covSumFile << "<ElapsedMinutes>" <<
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
- << "</ElapsedMinutes>"
- << "</Coverage>" << std::endl;
- this->CTest->EndXML(covSumFile);
+ covSumXML.Element("LOCTested", total_tested);
+ covSumXML.Element("LOCUntested", total_untested);
+ covSumXML.Element("LOC", total_lines);
+ covSumXML.Element("PercentCoverage", percent_coverage);
+ covSumXML.Element("EndDateTime", end_time);
+ covSumXML.Element("EndTime",
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
+ covSumXML.Element("ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ covSumXML.EndElement(); // Coverage
+ this->CTest->EndXML(covSumXML);
cmCTestLog(this->CTest, HANDLER_OUTPUT, "" << std::endl
<< "\tCovered LOC: "
@@ -1952,11 +1961,13 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
}
// create the output stream for the CoverageLog-N.xml file
cmGeneratedFileStream covLogFile;
+ cmXMLWriter covLogXML(covLogFile);
int logFileCount = 0;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
{
return -1;
}
+ this->StartCoverageLogXML(covLogXML);
// for each file run covbr on that file to get the coverage
// information for that file
std::string outputFile;
@@ -2009,20 +2020,22 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
// if we are in a valid file close it because a new one started
if(valid)
{
- covLogFile << "\t\t</Report>" << std::endl
- << "\t</File>" << std::endl;
+ covLogXML.EndElement(); // Report
+ covLogXML.EndElement(); // File
}
// only allow 100 files in each log file
if ( count != 0 && count % 100 == 0 )
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"start a new log file: " << count << std::endl, this->Quiet);
+ this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
logFileCount ++;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
{
return -1;
}
+ this->StartCoverageLogXML(covLogXML);
count++; // move on one
}
std::map<std::string, std::string>::iterator
@@ -2036,19 +2049,20 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
"Produce coverage for file: " << file << " " << count
<< std::endl, this->Quiet);
// start the file output
- covLogFile << "\t<File Name=\""
- << cmXMLSafe(i->first)
- << "\" FullPath=\"" << cmXMLSafe(
- this->CTest->GetShortPathToFile(
- i->second.c_str())) << "\">" << std::endl
- << "\t\t<Report>" << std::endl;
+ covLogXML.StartElement("File");
+ covLogXML.Attribute("Name", i->first);
+ covLogXML.Attribute("FullPath",
+ this->CTest->GetShortPathToFile(i->second.c_str()));
+ covLogXML.StartElement("Report");
// write the bullseye header
line =0;
for(int k =0; bullseyeHelp[k] != 0; ++k)
{
- covLogFile << "\t\t<Line Number=\"" << line << "\" Count=\"-1\">"
- << cmXMLSafe(bullseyeHelp[k])
- << "</Line>" << std::endl;
+ covLogXML.StartElement("Line");
+ covLogXML.Attribute("Number", line);
+ covLogXML.Attribute("Count", -1);
+ covLogXML.Content(bullseyeHelp[k]);
+ covLogXML.EndElement(); // Line
line++;
}
valid = true; // we are in a valid file section
@@ -2062,18 +2076,21 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
// we are not at a start file, and we are in a valid file output the line
else if(valid)
{
- covLogFile << "\t\t<Line Number=\"" << line << "\" Count=\"-1\">"
- << cmXMLSafe(lineIn)
- << "</Line>" << std::endl;
+ covLogXML.StartElement("Line");
+ covLogXML.Attribute("Number", line);
+ covLogXML.Attribute("Count", -1);
+ covLogXML.Content(lineIn);
+ covLogXML.EndElement(); // Line
line++;
}
}
// if we ran out of lines a valid file then close that file
if(valid)
{
- covLogFile << "\t\t</Report>" << std::endl
- << "\t</File>" << std::endl;
+ covLogXML.EndElement(); // Report
+ covLogXML.EndElement(); // File
}
+ this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
return 1;
}
@@ -2143,23 +2160,20 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
std::ostream& tmpLog = *cont->OFS;
// copen the Coverage.xml file in the Testing directory
cmGeneratedFileStream covSumFile;
+ cmXMLWriter xml(covSumFile);
if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot open coverage summary file." << std::endl);
return 0;
}
- this->CTest->StartXML(covSumFile, this->AppendXML);
+ this->CTest->StartXML(xml, this->AppendXML);
double elapsed_time_start = cmSystemTools::GetTime();
std::string coverage_start_time = this->CTest->CurrentTime();
- covSumFile << "<Coverage>" << std::endl
- << "\t<StartDateTime>"
- << coverage_start_time << "</StartDateTime>"
- << std::endl
- << "\t<StartTime>"
- << static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</StartTime>"
- << std::endl;
+ xml.StartElement("Coverage");
+ xml.Element("StartDateTime", coverage_start_time);
+ xml.Element("StartTime",
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
std::string stdline;
std::string errline;
// expected output:
@@ -2271,58 +2285,35 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
tmpLog << "percentBranch: " << percentBranch << "\n";
tmpLog << "percentCoverage: " << percent_coverage << "\n";
tmpLog << "coverage metric: " << cmet << "\n";
- covSumFile << "\t<File Name=\"" << cmXMLSafe(sourceFile)
- << "\" FullPath=\"" << cmXMLSafe(shortFileName)
- << "\" Covered=\"" << (cmet>0?"true":"false") << "\">\n"
- << "\t\t<BranchesTested>"
- << branchCovered
- << "</BranchesTested>\n"
- << "\t\t<BranchesUnTested>"
- << totalBranches - branchCovered
- << "</BranchesUnTested>\n"
- << "\t\t<FunctionsTested>"
- << functionsCalled
- << "</FunctionsTested>\n"
- << "\t\t<FunctionsUnTested>"
- << totalFunctions - functionsCalled
- << "</FunctionsUnTested>\n"
- // Hack for conversion of function to loc assume a function
- // has 100 lines of code
- << "\t\t<LOCTested>" << functionsCalled *100
- << "</LOCTested>\n"
- << "\t\t<LOCUnTested>"
- << (totalFunctions - functionsCalled)*100
- << "</LOCUnTested>\n"
- << "\t\t<PercentCoverage>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile << (cper) << "</PercentCoverage>\n"
- << "\t\t<CoverageMetric>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile << (cmet) << "</CoverageMetric>\n";
- this->WriteXMLLabels(covSumFile, shortFileName);
- covSumFile << "\t</File>" << std::endl;
+ xml.StartElement("File");
+ xml.Attribute("Name", sourceFile);
+ xml.Attribute("FullPath", shortFileName);
+ xml.Attribute("Covered", cmet > 0 ? "true" : "false");
+ xml.Element("BranchesTested", branchCovered);
+ xml.Element("BranchesUnTested", totalBranches - branchCovered);
+ xml.Element("FunctionsTested", functionsCalled);
+ xml.Element("FunctionsUnTested", totalFunctions - functionsCalled);
+ // Hack for conversion of function to loc assume a function
+ // has 100 lines of code
+ xml.Element("LOCTested", functionsCalled * 100);
+ xml.Element("LOCUnTested", (totalFunctions - functionsCalled) * 100);
+ xml.Element("PercentCoverage", cper);
+ xml.Element("CoverageMetric", cmet);
+ this->WriteXMLLabels(xml, shortFileName);
+ xml.EndElement(); // File
}
}
std::string end_time = this->CTest->CurrentTime();
- covSumFile << "\t<LOCTested>" << total_tested << "</LOCTested>\n"
- << "\t<LOCUntested>" << total_untested << "</LOCUntested>\n"
- << "\t<LOC>" << total_functions << "</LOC>\n"
- << "\t<PercentCoverage>";
- covSumFile.setf(std::ios::fixed, std::ios::floatfield);
- covSumFile.precision(2);
- covSumFile
- << SAFEDIV(percent_coverage,number_files)<< "</PercentCoverage>\n"
- << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
- << "\t<EndTime>" << static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndTime>\n";
- covSumFile
- << "<ElapsedMinutes>" <<
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
- << "</ElapsedMinutes>"
- << "</Coverage>" << std::endl;
- this->CTest->EndXML(covSumFile);
+ xml.Element("LOCTested", total_tested);
+ xml.Element("LOCUntested", total_untested);
+ xml.Element("LOC", total_functions);
+ xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
+ xml.Element("EndDateTime", end_time);
+ xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ xml.EndElement(); // Coverage
+ this->CTest->EndXML(xml);
// Now create the coverage information for each file
return this->RunBullseyeCoverageBranch(cont,
@@ -2514,19 +2505,19 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
}
//----------------------------------------------------------------------
-void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os,
+void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
std::string const& source)
{
LabelMapType::const_iterator li = this->SourceLabels.find(source);
if(li != this->SourceLabels.end() && !li->second.empty())
{
- os << "\t\t<Labels>\n";
+ xml.StartElement("Labels");
for(LabelSet::const_iterator lsi = li->second.begin();
lsi != li->second.end(); ++lsi)
{
- os << "\t\t\t<Label>" << cmXMLSafe(this->Labels[*lsi]) << "</Label>\n";
+ xml.Element("Label", this->Labels[*lsi]);
}
- os << "\t\t</Labels>\n";
+ xml.EndElement(); // Labels
}
}
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 3258ddb..2ca123a 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -20,6 +20,7 @@
#include <cmsys/RegularExpression.hxx>
class cmGeneratedFileStream;
+class cmXMLWriter;
class cmCTestCoverageHandlerContainer
{
public:
@@ -65,6 +66,9 @@ private:
bool StartCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
void EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
+ void StartCoverageLogXML(cmXMLWriter& xml);
+ void EndCoverageLogXML(cmXMLWriter& xml);
+
//! Handle coverage using GCC's GCov
int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont);
void FindGCovFiles(std::vector<std::string>& files);
@@ -146,7 +150,7 @@ private:
// Label reading and writing methods.
void LoadLabels();
void LoadLabels(const char* dir);
- void WriteXMLLabels(std::ostream& os, std::string const& source);
+ void WriteXMLLabels(cmXMLWriter& xml, std::string const& source);
// Label-based filtering.
std::set<int> LabelFilter;
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 5f570b5..c091ec4 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
@@ -91,36 +91,36 @@ void cmCTestGlobalVC::DoModification(PathStatus status,
}
//----------------------------------------------------------------------------
-void cmCTestGlobalVC::WriteXMLDirectory(std::ostream& xml,
+void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
std::string const& path,
Directory const& dir)
{
const char* slash = path.empty()? "":"/";
- xml << "\t<Directory>\n"
- << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
+ xml.StartElement("Directory");
+ xml.Element("Name", path);
for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
{
std::string full = path + slash + fi->first;
this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
}
- xml << "\t</Directory>\n";
+ xml.EndElement(); // Directory
}
//----------------------------------------------------------------------------
-void cmCTestGlobalVC::WriteXMLGlobal(std::ostream& xml)
+void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
{
if(!this->NewRevision.empty())
{
- xml << "\t<Revision>" << this->NewRevision << "</Revision>\n";
+ xml.Element("Revision", this->NewRevision);
}
if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision)
{
- xml << "\t<PriorRevision>" << this->OldRevision << "</PriorRevision>\n";
+ xml.Element("PriorRevision", this->OldRevision);
}
}
//----------------------------------------------------------------------------
-bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml)
+bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index 29e0a61..d0e9410 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -30,7 +30,7 @@ public:
protected:
// Implement cmCTestVC internal API.
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
/** Represent a vcs-reported action for one path in a revision. */
struct Change
@@ -62,8 +62,8 @@ protected:
virtual void LoadModifications() = 0;
virtual void LoadRevisions() = 0;
- virtual void WriteXMLGlobal(std::ostream& xml);
- void WriteXMLDirectory(std::ostream& xml, std::string const& path,
+ virtual void WriteXMLGlobal(cmXMLWriter& xml);
+ void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
Directory const& dir);
};
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index de6ecde..0f588c5 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -13,7 +13,7 @@
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include "cmake.h"
#include <cmsys/MD5.h>
@@ -407,35 +407,32 @@ void cmCTestLaunch::WriteXML()
// Use cmGeneratedFileStream to atomically create the report file.
cmGeneratedFileStream fxml(logXML.c_str());
- fxml << "\t<Failure type=\""
- << (this->IsError()? "Error" : "Warning") << "\">\n";
- this->WriteXMLAction(fxml);
- this->WriteXMLCommand(fxml);
- this->WriteXMLResult(fxml);
- this->WriteXMLLabels(fxml);
- fxml << "\t</Failure>\n";
+ cmXMLWriter xml(fxml, 2);
+ xml.StartElement("Failure");
+ xml.Attribute("type", this->IsError() ? "Error" : "Warning");
+ this->WriteXMLAction(xml);
+ this->WriteXMLCommand(xml);
+ this->WriteXMLResult(xml);
+ this->WriteXMLLabels(xml);
+ xml.EndElement(); // Failure
}
//----------------------------------------------------------------------------
-void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
+void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
{
- fxml << "\t\t<!-- Meta-information about the build action -->\n";
- fxml << "\t\t<Action>\n";
+ xml.Comment("Meta-information about the build action");
+ xml.StartElement("Action");
// TargetName
if(!this->OptionTargetName.empty())
{
- fxml << "\t\t\t<TargetName>"
- << cmXMLSafe(this->OptionTargetName)
- << "</TargetName>\n";
+ xml.Element("TargetName", this->OptionTargetName);
}
// Language
if(!this->OptionLanguage.empty())
{
- fxml << "\t\t\t<Language>"
- << cmXMLSafe(this->OptionLanguage)
- << "</Language>\n";
+ xml.Element("Language", this->OptionLanguage);
}
// SourceFile
@@ -454,17 +451,13 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
source.c_str());
}
- fxml << "\t\t\t<SourceFile>"
- << cmXMLSafe(source)
- << "</SourceFile>\n";
+ xml.Element("SourceFile", source);
}
// OutputFile
if(!this->OptionOutput.empty())
{
- fxml << "\t\t\t<OutputFile>"
- << cmXMLSafe(this->OptionOutput)
- << "</OutputFile>\n";
+ xml.Element("OutputFile", this->OptionOutput);
}
// OutputType
@@ -494,103 +487,94 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
}
if(outputType)
{
- fxml << "\t\t\t<OutputType>"
- << cmXMLSafe(outputType)
- << "</OutputType>\n";
+ xml.Element("OutputType", outputType);
}
- fxml << "\t\t</Action>\n";
+ xml.EndElement(); // Action
}
//----------------------------------------------------------------------------
-void cmCTestLaunch::WriteXMLCommand(std::ostream& fxml)
+void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml)
{
- fxml << "\n";
- fxml << "\t\t<!-- Details of command -->\n";
- fxml << "\t\t<Command>\n";
+ xml.Comment("Details of command");
+ xml.StartElement("Command");
if(!this->CWD.empty())
{
- fxml << "\t\t\t<WorkingDirectory>"
- << cmXMLSafe(this->CWD)
- << "</WorkingDirectory>\n";
+ xml.Element("WorkingDirectory", this->CWD);
}
for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
ai != this->RealArgs.end(); ++ai)
{
- fxml << "\t\t\t<Argument>"
- << cmXMLSafe(ai->c_str())
- << "</Argument>\n";
+ xml.Element("Argument", *ai);
}
- fxml << "\t\t</Command>\n";
+ xml.EndElement(); // Command
}
//----------------------------------------------------------------------------
-void cmCTestLaunch::WriteXMLResult(std::ostream& fxml)
+void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
{
- fxml << "\n";
- fxml << "\t\t<!-- Result of command -->\n";
- fxml << "\t\t<Result>\n";
+ xml.Comment("Result of command");
+ xml.StartElement("Result");
// StdOut
- fxml << "\t\t\t<StdOut>";
- this->DumpFileToXML(fxml, this->LogOut);
- fxml << "</StdOut>\n";
+ xml.StartElement("StdOut");
+ this->DumpFileToXML(xml, this->LogOut);
+ xml.EndElement(); // StdOut
// StdErr
- fxml << "\t\t\t<StdErr>";
- this->DumpFileToXML(fxml, this->LogErr);
- fxml << "</StdErr>\n";
+ xml.StartElement("StdErr");
+ this->DumpFileToXML(xml, this->LogErr);
+ xml.EndElement(); // StdErr
// ExitCondition
- fxml << "\t\t\t<ExitCondition>";
+ xml.StartElement("ExitCondition");
cmsysProcess* cp = this->Process;
switch (cmsysProcess_GetState(cp))
{
case cmsysProcess_State_Starting:
- fxml << "No process has been executed"; break;
+ xml.Content("No process has been executed"); break;
case cmsysProcess_State_Executing:
- fxml << "The process is still executing"; break;
+ xml.Content("The process is still executing"); break;
case cmsysProcess_State_Disowned:
- fxml << "Disowned"; break;
+ xml.Content("Disowned"); break;
case cmsysProcess_State_Killed:
- fxml << "Killed by parent"; break;
+ xml.Content("Killed by parent"); break;
case cmsysProcess_State_Expired:
- fxml << "Killed when timeout expired"; break;
+ xml.Content("Killed when timeout expired"); break;
case cmsysProcess_State_Exited:
- fxml << this->ExitCode; break;
+ xml.Content(this->ExitCode); break;
case cmsysProcess_State_Exception:
- fxml << "Terminated abnormally: "
- << cmXMLSafe(cmsysProcess_GetExceptionString(cp)); break;
+ xml.Content("Terminated abnormally: ");
+ xml.Content(cmsysProcess_GetExceptionString(cp)); break;
case cmsysProcess_State_Error:
- fxml << "Error administrating child process: "
- << cmXMLSafe(cmsysProcess_GetErrorString(cp)); break;
+ xml.Content("Error administrating child process: ");
+ xml.Content(cmsysProcess_GetErrorString(cp)); break;
};
- fxml << "</ExitCondition>\n";
+ xml.EndElement(); // ExitCondition
- fxml << "\t\t</Result>\n";
+ xml.EndElement(); // Result
}
//----------------------------------------------------------------------------
-void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml)
+void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml)
{
this->LoadLabels();
if(!this->Labels.empty())
{
- fxml << "\n";
- fxml << "\t\t<!-- Interested parties -->\n";
- fxml << "\t\t<Labels>\n";
+ xml.Comment("Interested parties");
+ xml.StartElement("Labels");
for(std::set<std::string>::const_iterator li = this->Labels.begin();
li != this->Labels.end(); ++li)
{
- fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
+ xml.Element("Label", *li);
}
- fxml << "\t\t</Labels>\n";
+ xml.EndElement(); // Labels
}
}
//----------------------------------------------------------------------------
-void cmCTestLaunch::DumpFileToXML(std::ostream& fxml,
+void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml,
std::string const& fname)
{
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
@@ -605,7 +589,8 @@ void cmCTestLaunch::DumpFileToXML(std::ostream& fxml,
continue;
}
- fxml << sep << cmXMLSafe(line).Quotes(false);
+ xml.Content(sep);
+ xml.Content(line);
sep = "\n";
}
}
@@ -750,9 +735,10 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
void cmCTestLaunch::LoadConfig()
{
cmake cm;
- cmGlobalGenerator gg;
- gg.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cmGlobalGenerator gg(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile();
std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake";
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index bc90d28..b13e484 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -15,6 +15,8 @@
#include "cmStandardIncludes.h"
#include <cmsys/RegularExpression.hxx>
+class cmXMLWriter;
+
/** \class cmCTestLaunch
* \brief Launcher for make rules to report results for ctest
*
@@ -92,11 +94,11 @@ private:
// Methods to generate the xml fragment.
void WriteXML();
- void WriteXMLAction(std::ostream& fxml);
- void WriteXMLCommand(std::ostream& fxml);
- void WriteXMLResult(std::ostream& fxml);
- void WriteXMLLabels(std::ostream& fxml);
- void DumpFileToXML(std::ostream& fxml, std::string const& fname);
+ void WriteXMLAction(cmXMLWriter& xml);
+ void WriteXMLCommand(cmXMLWriter& xml);
+ void WriteXMLResult(cmXMLWriter& xml);
+ void WriteXMLLabels(cmXMLWriter& xml);
+ void DumpFileToXML(cmXMLWriter& xml, std::string const& fname);
// Configuration
void LoadConfig();
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 061f3fd..8f26716 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -21,7 +21,7 @@
#include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
#include "cmMakefile.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <stdlib.h>
#include <math.h>
@@ -352,55 +352,52 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
}
//----------------------------------------------------------------------
-void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
+void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
{
if ( !this->CTest->GetProduceXML() )
{
return;
}
- this->CTest->StartXML(os, this->AppendXML);
- os << "<DynamicAnalysis Checker=\"";
+ this->CTest->StartXML(xml, this->AppendXML);
+ xml.StartElement("DynamicAnalysis");
switch ( this->MemoryTesterStyle )
{
case cmCTestMemCheckHandler::VALGRIND:
- os << "Valgrind";
+ xml.Attribute("Checker", "Valgrind");
break;
case cmCTestMemCheckHandler::PURIFY:
- os << "Purify";
+ xml.Attribute("Checker", "Purify");
break;
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
- os << "BoundsChecker";
+ xml.Attribute("Checker", "BoundsChecker");
break;
case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
- os << "AddressSanitizer";
+ xml.Attribute("Checker", "AddressSanitizer");
break;
case cmCTestMemCheckHandler::THREAD_SANITIZER:
- os << "ThreadSanitizer";
+ xml.Attribute("Checker", "ThreadSanitizer");
break;
case cmCTestMemCheckHandler::MEMORY_SANITIZER:
- os << "MemorySanitizer";
+ xml.Attribute("Checker", "MemorySanitizer");
break;
case cmCTestMemCheckHandler::UB_SANITIZER:
- os << "UndefinedBehaviorSanitizer";
+ xml.Attribute("Checker", "UndefinedBehaviorSanitizer");
break;
default:
- os << "Unknown";
+ xml.Attribute("Checker", "Unknown");
}
- os << "\">" << std::endl;
- os << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
- << "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
- << "\t<TestList>\n";
+ xml.Element("StartDateTime", this->StartTest);
+ xml.Element("StartTestTime", this->StartTestTime);
+ xml.StartElement("TestList");
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
{
cmCTestTestResult *result = &this->TestResults[cc];
std::string testPath = result->Path + "/" + result->Name;
- os << "\t\t<Test>" << cmXMLSafe(
- this->CTest->GetShortPathToFile(testPath.c_str()))
- << "</Test>" << std::endl;
+ xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
- os << "\t</TestList>\n";
+ xml.EndElement(); // TestList
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"-- Processing memory checking output: ", this->Quiet);
size_t total = this->TestResults.size();
@@ -419,37 +416,33 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
}
this->CleanTestOutput(memcheckstr,
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
- this->WriteTestResultHeader(os, result);
- os << "\t\t<Results>" << std::endl;
+ this->WriteTestResultHeader(xml, result);
+ xml.StartElement("Results");
for(std::vector<int>::size_type kk = 0;
kk < memcheckresults.size(); ++kk)
{
if ( memcheckresults[kk] )
{
- os << "\t\t\t<Defect type=\"" << this->ResultStringsLong[kk]
- << "\">"
- << memcheckresults[kk]
- << "</Defect>" << std::endl;
+ xml.StartElement("Defect");
+ xml.Attribute("type", this->ResultStringsLong[kk]);
+ xml.Content(memcheckresults[kk]);
+ xml.EndElement(); // Defect
}
this->GlobalResults[kk] += memcheckresults[kk];
}
+ xml.EndElement(); // Results
- std::string logTag;
+ xml.StartElement("Log");
if(this->CTest->ShouldCompressMemCheckOutput())
{
this->CTest->CompressString(memcheckstr);
- logTag = "\t<Log compression=\"gzip\" encoding=\"base64\">\n";
- }
- else
- {
- logTag = "\t<Log>\n";
+ xml.Attribute("compression", "gzip");
+ xml.Attribute("encoding", "base64");
}
+ xml.Content(memcheckstr);
+ xml.EndElement(); // Log
- os
- << "\t\t</Results>\n"
- << logTag << cmXMLSafe(memcheckstr) << std::endl
- << "\t</Log>\n";
- this->WriteTestResultFooter(os, result);
+ this->WriteTestResultFooter(xml, result);
if ( current < cc )
{
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
@@ -460,7 +453,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
<< std::endl, this->Quiet);
- os << "\t<DefectList>" << std::endl;
+ xml.StartElement("DefectList");
for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
{
if ( this->GlobalResults[cc] )
@@ -473,21 +466,20 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
this->ResultStringsLong[cc] << " - "
<< this->GlobalResults[cc] << std::endl, this->Quiet);
- os << "\t\t<Defect Type=\"" << this->ResultStringsLong[cc]
- << "\"/>" << std::endl;
+ xml.StartElement("Defect");
+ xml.Attribute("Type", this->ResultStringsLong[cc]);
+ xml.EndElement();
}
}
- os << "\t</DefectList>" << std::endl;
+ xml.EndElement(); // DefectList
- os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>" << std::endl;
- os << "\t<EndTestTime>" << this->EndTestTime
- << "</EndTestTime>" << std::endl;
- os << "<ElapsedMinutes>"
- << static_cast<int>(this->ElapsedTestingTime/6)/10.0
- << "</ElapsedMinutes>\n";
+ xml.Element("EndDateTime", this->EndTest);
+ xml.Element("EndTestTime", this->EndTestTime);
+ xml.Element("ElapsedMinutes",
+ static_cast<int>(this->ElapsedTestingTime/6)/10.0);
- os << "</DynamicAnalysis>" << std::endl;
- this->CTest->EndXML(os);
+ xml.EndElement(); // DynamicAnalysis
+ this->CTest->EndXML(xml);
}
//----------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 69fdd9f..f1ac794 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -21,6 +21,7 @@
#include <string>
class cmMakefile;
+class cmXMLWriter;
/** \class cmCTestMemCheckHandler
* \brief A class that handles ctest -S invocations
@@ -119,7 +120,7 @@ private:
/**
* Generate the Dart compatible output
*/
- void GenerateDartOutput(std::ostream& os);
+ void GenerateDartOutput(cmXMLWriter& xml);
std::vector<std::string> CustomPreMemCheck;
std::vector<std::string> CustomPostMemCheck;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index d7da2b4..d9e4bd4 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -607,7 +607,7 @@ void cmCTestRunTest::DartProcessing()
{
if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str()))
{
- std::string dartString = this->TestHandler->DartStuff.match(1);
+ this->TestResult.DartString = this->TestHandler->DartStuff.match(1);
// keep searching and replacing until none are left
while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str()))
{
@@ -615,8 +615,6 @@ void cmCTestRunTest::DartProcessing()
cmSystemTools::ReplaceString(this->ProcessOutput,
this->TestHandler->DartStuff1.match(1).c_str(), "");
}
- this->TestResult.RegressionImages
- = this->TestHandler->GenerateRegressionImages(dartString);
}
}
}
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 86dc2f2..f7bd1f9 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -14,7 +14,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
@@ -535,11 +535,11 @@ void cmCTestSVN::LoadModifications()
}
//----------------------------------------------------------------------------
-void cmCTestSVN::WriteXMLGlobal(std::ostream& xml)
+void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
{
this->cmCTestGlobalVC::WriteXMLGlobal(xml);
- xml << "\t<SVNPath>" << this->RootInfo->Base << "</SVNPath>\n";
+ xml.Element("SVNPath", this->RootInfo->Base);
}
//----------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index 17bf7cb..f9febc5 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -84,7 +84,7 @@ private:
void DoRevisionSVN(Revision const& revision,
std::vector<Change> const& changes);
- void WriteXMLGlobal(std::ostream& xml);
+ void WriteXMLGlobal(cmXMLWriter& xml);
// Parsing helper classes.
class InfoParser;
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 0a34be8..047bd98 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -336,11 +336,12 @@ void cmCTestScriptHandler::CreateCMake()
delete this->LocalGenerator;
}
this->CMake = new cmake;
+ this->CMake->SetHomeDirectory("");
+ this->CMake->SetHomeOutputDirectory("");
this->CMake->AddCMakePaths();
- this->GlobalGenerator = new cmGlobalGenerator;
- this->GlobalGenerator->SetCMakeInstance(this->CMake);
+ this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
- this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator();
+ this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator();
this->Makefile = this->LocalGenerator->GetMakefile();
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
@@ -420,6 +421,10 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
}
+#if defined(__CYGWIN__)
+ this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
+#endif
+
// always add a function blocker to update the elapsed time
cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker();
f->CTestScriptHandler = this;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 95cdf3b..70b7f5c 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -27,7 +27,7 @@
#include "cmLocalGenerator.h"
#include "cmCommand.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include "cm_utf8.h"
#include <stdlib.h>
@@ -633,7 +633,8 @@ int cmCTestTestHandler::ProcessHandler()
this->LogFile = 0;
return 1;
}
- this->GenerateDartOutput(xmlfile);
+ cmXMLWriter xml(xmlfile);
+ this->GenerateDartOutput(xml);
}
if ( ! this->PostProcessHandler() )
@@ -1142,54 +1143,53 @@ void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int)
}
//----------------------------------------------------------------------
-void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
+void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
{
if ( !this->CTest->GetProduceXML() )
{
return;
}
- this->CTest->StartXML(os, this->AppendXML);
- os << "<Testing>\n"
- << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
- << "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
- << "\t<TestList>\n";
+ this->CTest->StartXML(xml, this->AppendXML);
+ xml.StartElement("Testing");
+ xml.Element("StartDateTime", this->StartTest);
+ xml.Element("StartTestTime", this->StartTestTime);
+ xml.StartElement("TestList");
cmCTestTestHandler::TestResultsVector::size_type cc;
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
{
cmCTestTestResult *result = &this->TestResults[cc];
std::string testPath = result->Path + "/" + result->Name;
- os << "\t\t<Test>" << cmXMLSafe(
- this->CTest->GetShortPathToFile(testPath.c_str()))
- << "</Test>" << std::endl;
+ xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
- os << "\t</TestList>\n";
+ xml.EndElement(); // TestList
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
{
cmCTestTestResult *result = &this->TestResults[cc];
- this->WriteTestResultHeader(os, result);
- os << "\t\t<Results>" << std::endl;
+ this->WriteTestResultHeader(xml, result);
+ xml.StartElement("Results");
if ( result->Status != cmCTestTestHandler::NOT_RUN )
{
if ( result->Status != cmCTestTestHandler::COMPLETED ||
result->ReturnValue )
{
- os << "\t\t\t<NamedMeasurement type=\"text/string\" "
- "name=\"Exit Code\"><Value>"
- << cmXMLSafe(this->GetTestStatus(result->Status))
- << "</Value>"
- "</NamedMeasurement>\n"
- << "\t\t\t<NamedMeasurement type=\"text/string\" "
- "name=\"Exit Value\"><Value>"
- << result->ReturnValue
- << "</Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", "Exit Code");
+ xml.Element("Value", this->GetTestStatus(result->Status));
+ xml.EndElement(); // NamedMeasurement
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", "Exit Value");
+ xml.Element("Value", result->ReturnValue);
+ xml.EndElement(); // NamedMeasurement
}
- os << result->RegressionImages;
- os << "\t\t\t<NamedMeasurement type=\"numeric/double\" "
- << "name=\"Execution Time\"><Value>"
- << result->ExecutionTime
- << "</Value></NamedMeasurement>\n";
+ this->GenerateRegressionImages(xml, result->DartString);
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "numeric/double");
+ xml.Attribute("name", "Execution Time");
+ xml.Element("Value", result->ExecutionTime);
+ xml.EndElement(); // NamedMeasurement
if(!result->Reason.empty())
{
const char* reasonType = "Pass Reason";
@@ -1198,109 +1198,103 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
{
reasonType = "Fail Reason";
}
- os << "\t\t\t<NamedMeasurement type=\"text/string\" "
- << "name=\"" << reasonType << "\"><Value>"
- << cmXMLSafe(result->Reason)
- << "</Value></NamedMeasurement>\n";
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", reasonType);
+ xml.Element("Value", result->Reason);
+ xml.EndElement(); // NamedMeasurement
}
- os
- << "\t\t\t<NamedMeasurement type=\"text/string\" "
- << "name=\"Completion Status\"><Value>"
- << cmXMLSafe(result->CompletionStatus)
- << "</Value></NamedMeasurement>\n";
- }
- os
- << "\t\t\t<NamedMeasurement type=\"text/string\" "
- << "name=\"Command Line\"><Value>"
- << cmXMLSafe(result->FullCommandLine)
- << "</Value></NamedMeasurement>\n";
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", "Completion Status");
+ xml.Element("Value", result->CompletionStatus);
+ xml.EndElement(); // NamedMeasurement
+ }
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", "Command Line");
+ xml.Element("Value", result->FullCommandLine);
+ xml.EndElement(); // NamedMeasurement
std::map<std::string,std::string>::iterator measureIt;
for ( measureIt = result->Properties->Measurements.begin();
measureIt != result->Properties->Measurements.end();
++ measureIt )
{
- os
- << "\t\t\t<NamedMeasurement type=\"text/string\" "
- << "name=\"" << measureIt->first << "\"><Value>"
- << cmXMLSafe(measureIt->second)
- << "</Value></NamedMeasurement>\n";
- }
- os
- << "\t\t\t<Measurement>\n"
- << "\t\t\t\t<Value"
- << (result->CompressOutput ?
- " encoding=\"base64\" compression=\"gzip\">"
- : ">");
- os << cmXMLSafe(result->Output);
- os
- << "</Value>\n"
- << "\t\t\t</Measurement>\n"
- << "\t\t</Results>\n";
-
- this->AttachFiles(os, result);
- this->WriteTestResultFooter(os, result);
- }
-
- os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>\n"
- << "\t<EndTestTime>" << this->EndTestTime << "</EndTestTime>\n"
- << "<ElapsedMinutes>"
- << static_cast<int>(this->ElapsedTestingTime/6)/10.0
- << "</ElapsedMinutes>"
- << "</Testing>" << std::endl;
- this->CTest->EndXML(os);
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "text/string");
+ xml.Attribute("name", measureIt->first);
+ xml.Element("Value", measureIt->second);
+ xml.EndElement(); // NamedMeasurement
+ }
+ xml.StartElement("Measurement");
+ xml.StartElement("Value");
+ if (result->CompressOutput)
+ {
+ xml.Attribute("encoding", "base64");
+ xml.Attribute("compression", "gzip");
+ }
+ xml.Content(result->Output);
+ xml.EndElement(); // Value
+ xml.EndElement(); // Measurement
+ xml.EndElement(); // Results
+
+ this->AttachFiles(xml, result);
+ this->WriteTestResultFooter(xml, result);
+ }
+
+ xml.Element("EndDateTime", this->EndTest);
+ xml.Element("EndTestTime", this->EndTestTime);
+ xml.Element("ElapsedMinutes",
+ static_cast<int>(this->ElapsedTestingTime/6)/10.0);
+ xml.EndElement(); // Testing
+ this->CTest->EndXML(xml);
}
//----------------------------------------------------------------------------
-void cmCTestTestHandler::WriteTestResultHeader(std::ostream& os,
+void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
cmCTestTestResult* result)
{
- os << "\t<Test Status=\"";
+ xml.StartElement("Test");
if ( result->Status == cmCTestTestHandler::COMPLETED )
{
- os << "passed";
+ xml.Attribute("Status", "passed");
}
else if ( result->Status == cmCTestTestHandler::NOT_RUN )
{
- os << "notrun";
+ xml.Attribute("Status", "notrun");
}
else
{
- os << "failed";
+ xml.Attribute("Status", "failed");
}
std::string testPath = result->Path + "/" + result->Name;
- os << "\">\n"
- << "\t\t<Name>" << cmXMLSafe(result->Name) << "</Name>\n"
- << "\t\t<Path>" << cmXMLSafe(
- this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n"
- << "\t\t<FullName>" << cmXMLSafe(
- this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n"
- << "\t\t<FullCommandLine>"
- << cmXMLSafe(result->FullCommandLine)
- << "</FullCommandLine>\n";
+ xml.Element("Name", result->Name);
+ xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
+ xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str()));
+ xml.Element("FullCommandLine", result->FullCommandLine);
}
//----------------------------------------------------------------------------
-void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os,
+void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
cmCTestTestResult* result)
{
if(!result->Properties->Labels.empty())
{
- os << "\t\t<Labels>\n";
+ xml.StartElement("Labels");
std::vector<std::string> const& labels = result->Properties->Labels;
for(std::vector<std::string>::const_iterator li = labels.begin();
li != labels.end(); ++li)
{
- os << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
+ xml.Element("Label", *li);
}
- os << "\t\t</Labels>\n";
+ xml.EndElement(); // Labels
}
- os
- << "\t</Test>" << std::endl;
+ xml.EndElement(); // Test
}
//----------------------------------------------------------------------
-void cmCTestTestHandler::AttachFiles(std::ostream& os,
+void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
cmCTestTestResult* result)
{
if(result->Status != cmCTestTestHandler::COMPLETED
@@ -1317,11 +1311,14 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os,
{
const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
std::string fname = cmSystemTools::GetFilenameName(*file);
- os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" "
- "compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">"
- "\n\t\t\t<Value>\n\t\t\t"
- << base64
- << "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n";
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("name", "Attached File");
+ xml.Attribute("encoding", "base64");
+ xml.Attribute("compression", "tar/gzip");
+ xml.Attribute("filename", fname);
+ xml.Attribute("type", "file");
+ xml.Element("Value", base64);
+ xml.EndElement(); // NamedMeasurement
}
}
@@ -1571,9 +1568,10 @@ void cmCTestTestHandler::GetListOfTests()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Constructing a list of tests" << std::endl, this->Quiet);
cmake cm;
- cmGlobalGenerator gg;
- gg.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cmGlobalGenerator gg(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile();
mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str());
@@ -1826,8 +1824,8 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
// Just for convenience
#define SPACE_REGEX "[ \t\r\n]"
//----------------------------------------------------------------------
-std::string cmCTestTestHandler::GenerateRegressionImages(
- const std::string& xml)
+void cmCTestTestHandler::GenerateRegressionImages(
+ cmXMLWriter& xml, const std::string& dart)
{
cmsys::RegularExpression twoattributes(
"<DartMeasurement"
@@ -1862,71 +1860,62 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
- std::ostringstream ostr;
bool done = false;
- std::string cxml = xml;
+ std::string cxml = dart;
while ( ! done )
{
if ( twoattributes.find(cxml) )
{
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << twoattributes.match(1) << "=\""
- << twoattributes.match(2) << "\""
- << " " << twoattributes.match(3) << "=\""
- << twoattributes.match(4) << "\""
- << "><Value>" << twoattributes.match(5)
- << "</Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(twoattributes.match(1).c_str(),
+ twoattributes.match(2));
+ xml.Attribute(twoattributes.match(3).c_str(),
+ twoattributes.match(4));
+ xml.Element("Value", twoattributes.match(5));
+ xml.EndElement();
cxml.erase(twoattributes.start(),
twoattributes.end() - twoattributes.start());
}
else if ( threeattributes.find(cxml) )
{
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << threeattributes.match(1) << "=\""
- << threeattributes.match(2) << "\""
- << " " << threeattributes.match(3) << "=\""
- << threeattributes.match(4) << "\""
- << " " << threeattributes.match(5) << "=\""
- << threeattributes.match(6) << "\""
- << "><Value>" << threeattributes.match(7)
- << "</Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(threeattributes.match(1).c_str(),
+ threeattributes.match(2));
+ xml.Attribute(threeattributes.match(3).c_str(),
+ threeattributes.match(4));
+ xml.Attribute(threeattributes.match(5).c_str(),
+ threeattributes.match(6));
+ xml.Element("Value", twoattributes.match(7));
+ xml.EndElement();
cxml.erase(threeattributes.start(),
threeattributes.end() - threeattributes.start());
}
else if ( fourattributes.find(cxml) )
{
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << fourattributes.match(1) << "=\""
- << fourattributes.match(2) << "\""
- << " " << fourattributes.match(3) << "=\""
- << fourattributes.match(4) << "\""
- << " " << fourattributes.match(5) << "=\""
- << fourattributes.match(6) << "\""
- << " " << fourattributes.match(7) << "=\""
- << fourattributes.match(8) << "\""
- << "><Value>" << fourattributes.match(9)
- << "</Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(fourattributes.match(1).c_str(),
+ fourattributes.match(2));
+ xml.Attribute(fourattributes.match(3).c_str(),
+ fourattributes.match(4));
+ xml.Attribute(fourattributes.match(5).c_str(),
+ fourattributes.match(6));
+ xml.Attribute(fourattributes.match(7).c_str(),
+ fourattributes.match(8));
+ xml.Element("Value", twoattributes.match(9));
+ xml.EndElement();
cxml.erase(fourattributes.start(),
fourattributes.end() - fourattributes.start());
}
else if ( cdatastart.find(cxml) && cdataend.find(cxml) )
{
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << cdatastart.match(1) << "=\""
- << cdatastart.match(2) << "\""
- << " " << cdatastart.match(3) << "=\""
- << cdatastart.match(4) << "\""
- << "><Value><![CDATA["
- << cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end())
- << "]]></Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(cdatastart.match(1).c_str(), cdatastart.match(2));
+ xml.Attribute(cdatastart.match(3).c_str(), cdatastart.match(4));
+ xml.StartElement("Value");
+ xml.CData(
+ cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
+ xml.EndElement(); // Value
+ xml.EndElement(); // NamedMeasurement
cxml.erase(cdatastart.start(),
cdataend.end() - cdatastart.start());
}
@@ -1952,13 +1941,12 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
v2 = "text/string";
}
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << k1 << "=\"" << v1 << "\""
- << " " << k2 << "=\"" << v2 << "\""
- << " encoding=\"none\""
- << "><Value>Image " << filename
- << " is empty</Value></NamedMeasurement>";
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(k1.c_str(), v1);
+ xml.Attribute(k2.c_str(), v2);
+ xml.Attribute("encoding", "none");
+ xml.Element("Value", "Image " + filename + " is empty");
+ xml.EndElement();
}
else
{
@@ -1976,14 +1964,13 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
size_t rlen
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
- ostr
- << "\t\t\t<NamedMeasurement"
- << " " << measurementfile.match(1) << "=\""
- << measurementfile.match(2) << "\""
- << " " << measurementfile.match(3) << "=\""
- << measurementfile.match(4) << "\""
- << " encoding=\"base64\""
- << ">" << std::endl << "\t\t\t\t<Value>";
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute(measurementfile.match(1).c_str(),
+ measurementfile.match(2));
+ xml.Attribute(measurementfile.match(3).c_str(),
+ measurementfile.match(4));
+ xml.Attribute("encoding", "base64");
+ std::stringstream ostr;
for (size_t cc = 0; cc < rlen; cc ++ )
{
ostr << encoded_buffer[cc];
@@ -1992,9 +1979,8 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
ostr << std::endl;
}
}
- ostr
- << "</Value>" << std::endl << "\t\t\t</NamedMeasurement>"
- << std::endl;
+ xml.Element("Value", ostr.str());
+ xml.EndElement(); // NamedMeasurement
delete [] file_buffer;
delete [] encoded_buffer;
}
@@ -2006,13 +1992,11 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
{
idx = 2;
}
- ostr
- << "\t\t\t<NamedMeasurement"
- << " name=\"" << measurementfile.match(idx) << "\""
- << " text=\"text/string\""
- << "><Value>File " << filename
- << " not found</Value></NamedMeasurement>"
- << std::endl;
+ xml.StartElement("NamedMeasurement");
+ xml.Attribute("name", measurementfile.match(idx));
+ xml.Attribute("text", "text/string");
+ xml.Element("Value", "File " + filename + " not found");
+ xml.EndElement();
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
<< "\" not found." << std::endl, this->Quiet);
}
@@ -2024,7 +2008,6 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
done = true;
}
}
- return ostr.str();
}
//----------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index fe43bb8..14067d5 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -18,6 +18,7 @@
#include <cmsys/RegularExpression.hxx>
class cmMakefile;
+class cmXMLWriter;
/** \class cmCTestTestHandler
* \brief A class that handles ctest -S invocations
@@ -128,7 +129,7 @@ public:
bool CompressOutput;
std::string CompletionStatus;
std::string Output;
- std::string RegressionImages;
+ std::string DartString;
int TestCount;
cmCTestTestProperties* Properties;
};
@@ -164,10 +165,10 @@ protected:
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
int ExecuteCommands(std::vector<std::string>& vec);
- void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result);
- void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result);
+ void WriteTestResultHeader(cmXMLWriter& xml, cmCTestTestResult* result);
+ void WriteTestResultFooter(cmXMLWriter& xml, cmCTestTestResult* result);
// Write attached test files into the xml
- void AttachFiles(std::ostream& os, cmCTestTestResult* result);
+ void AttachFiles(cmXMLWriter& xml, cmCTestTestResult* result);
//! Clean test output to specified length
bool CleanTestOutput(std::string& output, size_t length);
@@ -204,7 +205,7 @@ private:
/**
* Generate the Dart compatible output
*/
- virtual void GenerateDartOutput(std::ostream& os);
+ virtual void GenerateDartOutput(cmXMLWriter& xml);
void PrintLabelSummary();
/**
@@ -270,7 +271,7 @@ private:
cmsys::RegularExpression IncludeTestsRegularExpression;
cmsys::RegularExpression ExcludeTestsRegularExpression;
- std::string GenerateRegressionImages(const std::string& xml);
+ void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
cmsys::RegularExpression DartStuff1;
void CheckLabelFilter(cmCTestTestProperties& it);
void CheckLabelFilterExclude(cmCTestTestProperties& it);
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 10927e7..8494d28 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -20,7 +20,7 @@
#include "cmVersion.h"
#include "cmGeneratedFileStream.h"
#include "cmXMLParser.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include "cmCLocaleEnvironmentScope.h"
#include "cmCTestVC.h"
@@ -224,24 +224,24 @@ int cmCTestUpdateHandler::ProcessHandler()
bool updated = vc->Update();
std::string buildname = cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName"));
- os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<Update mode=\"Client\" Generator=\"ctest-"
- << cmVersion::GetCMakeVersion() << "\">\n"
- << "\t<Site>" << this->CTest->GetCTestConfiguration("Site") << "</Site>\n"
- << "\t<BuildName>" << buildname
- << "</BuildName>\n"
- << "\t<BuildStamp>" << this->CTest->GetCurrentTag() << "-"
- << this->CTest->GetTestModelString() << "</BuildStamp>" << std::endl;
- os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n"
- << "\t<StartTime>" << start_time_time << "</StartTime>\n"
- << "\t<UpdateCommand>"
- << cmXMLSafe(vc->GetUpdateCommandLine()).Quotes(false)
- << "</UpdateCommand>\n"
- << "\t<UpdateType>" << cmXMLSafe(
- cmCTestUpdateHandlerUpdateToString(this->UpdateType))
- << "</UpdateType>\n";
-
- vc->WriteXML(os);
+
+ cmXMLWriter xml(os);
+ xml.StartDocument();
+ xml.StartElement("Update");
+ xml.Attribute("mode", "Client");
+ xml.Attribute("Generator",
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
+ xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
+ xml.Element("BuildName", buildname);
+ xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+ this->CTest->GetTestModelString());
+ xml.Element("StartDateTime", start_time);
+ xml.Element("StartTime", start_time_time);
+ xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
+ xml.Element("UpdateType",
+ cmCTestUpdateHandlerUpdateToString(this->UpdateType));
+
+ vc->WriteXML(xml);
int localModifications = 0;
int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
@@ -265,29 +265,30 @@ int cmCTestUpdateHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
std::string end_time = this->CTest->CurrentTime();
- os << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
- << "\t<EndTime>" << static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndTime>\n"
- << "<ElapsedMinutes>" <<
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
- << "</ElapsedMinutes>\n"
- << "\t<UpdateReturnStatus>";
+ xml.Element("EndDateTime", end_time);
+ xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+
+ xml.StartElement("UpdateReturnStatus");
if(localModifications)
{
- os << "Update error: There are modified or conflicting files in the "
- "repository";
+ xml.Content("Update error: "
+ "There are modified or conflicting files in the repository");
cmCTestLog(this->CTest, ERROR_MESSAGE,
" There are modified or conflicting files in the repository"
<< std::endl);
}
if(!updated)
{
- os << "Update command failed:\n" << vc->GetUpdateCommandLine();
+ xml.Content("Update command failed:\n");
+ xml.Content(vc->GetUpdateCommandLine());
cmCTestLog(this->CTest, ERROR_MESSAGE, " Update command failed: "
<< vc->GetUpdateCommandLine() << "\n");
}
- os << "</UpdateReturnStatus>" << std::endl;
- os << "</Update>" << std::endl;
+ xml.EndElement(); // UpdateReturnStatus
+ xml.EndElement(); // Update
+ xml.EndDocument();
return numUpdated;
}
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index 579190a..5c6b229 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -13,7 +13,7 @@
#include "cmGeneratedFileStream.h"
#include "cmVersion.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
//----------------------------------------------------------------------------
cmCTestUploadHandler::cmCTestUploadHandler()
@@ -47,32 +47,36 @@ int cmCTestUploadHandler::ProcessHandler()
std::string buildname = cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName"));
cmCTest::SetOfStrings::const_iterator it;
- ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<?xml-stylesheet type=\"text/xsl\" "
+
+ cmXMLWriter xml(ofs);
+ xml.StartDocument();
+ xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
"href=\"Dart/Source/Server/XSL/Build.xsl "
- "<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
- << "<Site BuildName=\""
- << buildname
- << "\" BuildStamp=\""
- << this->CTest->GetCurrentTag() << "-"
- << this->CTest->GetTestModelString() << "\" Name=\""
- << this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest"
- << cmVersion::GetCMakeVersion()
- << "\">\n";
- this->CTest->AddSiteProperties(ofs);
- ofs << "<Upload>\n";
+ "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+ xml.StartElement("Site");
+ xml.Attribute("BuildName", buildname);
+ xml.Attribute("BuildStamp",
+ this->CTest->GetCurrentTag() + "-" + this->CTest->GetTestModelString());
+ xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
+ xml.Attribute("Generator",
+ std::string("ctest") + cmVersion::GetCMakeVersion());
+ this->CTest->AddSiteProperties(xml);
+ xml.StartElement("Upload");
for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
{
cmCTestOptionalLog(this->CTest, OUTPUT,
"\tUpload file: " << *it << std::endl, this->Quiet);
- ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
- << "<Content encoding=\"base64\">\n";
- ofs << this->CTest->Base64EncodeFile(*it);
- ofs << "\n</Content>\n"
- << "</File>\n";
+ xml.StartElement("File");
+ xml.Attribute("filename", *it);
+ xml.StartElement("Content");
+ xml.Attribute("encoding", "base64");
+ xml.Content(this->CTest->Base64EncodeFile(*it));
+ xml.EndElement(); // Content
+ xml.EndElement(); // File
}
- ofs << "</Upload>\n"
- << "</Site>\n";
+ xml.EndElement(); // Upload
+ xml.EndElement(); // Site
+ xml.EndDocument();
return 0;
}
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 6e93e95..8eff4d6 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/Process.h>
@@ -202,7 +202,7 @@ bool cmCTestVC::UpdateImpl()
}
//----------------------------------------------------------------------------
-bool cmCTestVC::WriteXML(std::ostream& xml)
+bool cmCTestVC::WriteXML(cmXMLWriter& xml)
{
this->Log << "--- Begin Revisions ---\n";
bool result = this->WriteXMLUpdates(xml);
@@ -211,7 +211,7 @@ bool cmCTestVC::WriteXML(std::ostream& xml)
}
//----------------------------------------------------------------------------
-bool cmCTestVC::WriteXMLUpdates(std::ostream&)
+bool cmCTestVC::WriteXMLUpdates(cmXMLWriter&)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"* CTest cannot extract updates for this VCS tool.\n");
@@ -219,7 +219,7 @@ bool cmCTestVC::WriteXMLUpdates(std::ostream&)
}
//----------------------------------------------------------------------------
-void cmCTestVC::WriteXMLEntry(std::ostream& xml,
+void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml,
std::string const& path,
std::string const& name,
std::string const& full,
@@ -228,21 +228,19 @@ void cmCTestVC::WriteXMLEntry(std::ostream& xml,
static const char* desc[3] = { "Updated", "Modified", "Conflicting"};
Revision const& rev = f.Rev? *f.Rev : this->Unknown;
std::string prior = f.PriorRev? f.PriorRev->Rev : std::string("Unknown");
- xml << "\t\t<" << desc[f.Status] << ">\n"
- << "\t\t\t<File>" << cmXMLSafe(name) << "</File>\n"
- << "\t\t\t<Directory>" << cmXMLSafe(path) << "</Directory>\n"
- << "\t\t\t<FullName>" << cmXMLSafe(full) << "</FullName>\n"
- << "\t\t\t<CheckinDate>" << cmXMLSafe(rev.Date) << "</CheckinDate>\n"
- << "\t\t\t<Author>" << cmXMLSafe(rev.Author) << "</Author>\n"
- << "\t\t\t<Email>" << cmXMLSafe(rev.EMail) << "</Email>\n"
- << "\t\t\t<Committer>" << cmXMLSafe(rev.Committer) << "</Committer>\n"
- << "\t\t\t<CommitterEmail>" << cmXMLSafe(rev.CommitterEMail)
- << "</CommitterEmail>\n"
- << "\t\t\t<CommitDate>" << cmXMLSafe(rev.CommitDate)
- << "</CommitDate>\n"
- << "\t\t\t<Log>" << cmXMLSafe(rev.Log) << "</Log>\n"
- << "\t\t\t<Revision>" << cmXMLSafe(rev.Rev) << "</Revision>\n"
- << "\t\t\t<PriorRevision>" << cmXMLSafe(prior) << "</PriorRevision>\n"
- << "\t\t</" << desc[f.Status] << ">\n";
+ xml.StartElement(desc[f.Status]);
+ xml.Element("File", name);
+ xml.Element("Directory", path);
+ xml.Element("FullName", full);
+ xml.Element("CheckinDate", rev.Date);
+ xml.Element("Author", rev.Author);
+ xml.Element("Email", rev.EMail);
+ xml.Element("Committer", rev.Committer);
+ xml.Element("CommitterEmail", rev.CommitterEMail);
+ xml.Element("CommitDate", rev.CommitDate);
+ xml.Element("Log", rev.Log);
+ xml.Element("Revision", rev.Rev);
+ xml.Element("PriorRevision", prior);
+ xml.EndElement();
++this->PathCount[f.Status];
}
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index 9dd0651..bc89302 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -15,6 +15,7 @@
#include "cmProcessTools.h"
class cmCTest;
+class cmXMLWriter;
/** \class cmCTestVC
* \brief Base class for version control system handlers
@@ -51,7 +52,7 @@ public:
{ return this->UpdateCommandLine; }
/** Write Update.xml entries for the updates found. */
- bool WriteXML(std::ostream& xml);
+ bool WriteXML(cmXMLWriter& xml);
/** Enumerate non-trivial working tree states during update. */
enum PathStatus { PathUpdated, PathModified, PathConflicting };
@@ -65,7 +66,7 @@ protected:
virtual void NoteOldRevision();
virtual bool UpdateImpl();
virtual void NoteNewRevision();
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510
public: // Sun CC 5.1 needs help to allow cmCTestSVN::Revision to see this
@@ -110,7 +111,7 @@ protected:
OutputParser* out, OutputParser* err = 0);
/** Write xml element for one file. */
- void WriteXMLEntry(std::ostream& xml, std::string const& path,
+ void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
std::string const& name, std::string const& full,
File const& f);
diff --git a/Source/Checks/cm_cxx11_unordered_map.cmake b/Source/Checks/cm_cxx11_unordered_map.cmake
new file mode 100644
index 0000000..80fe391
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cmake
@@ -0,0 +1,25 @@
+
+if(CMAKE_CXX_STANDARD AND NOT DEFINED CMake_HAVE_CXX11_UNORDERED_MAP)
+ message(STATUS "Checking if compiler supports C++11 unordered_map")
+ try_compile(CMake_HAVE_CXX11_UNORDERED_MAP
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx11_unordered_map.cpp
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(CMake_HAVE_CXX11_UNORDERED_MAP)
+ message(STATUS "Checking if compiler supports C++11 unordered_map - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports C++11 unordered_map passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports C++11 unordered_map - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports C++11 unordered_map failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+endif()
diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp
new file mode 100644
index 0000000..beeb31b
--- /dev/null
+++ b/Source/Checks/cm_cxx11_unordered_map.cpp
@@ -0,0 +1,6 @@
+#include <unordered_map>
+int main() {
+ std::unordered_map<int, int> map;
+ map[0] = 0;
+ return 0;
+}
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index e013f81..5236e57 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -104,6 +104,8 @@ int main(int argc, char const* const* argv)
if(doc.CheckOptions(argc, argv))
{
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
std::vector<cmDocumentationEntry> generators;
hcm.GetGeneratorDocumentation(generators);
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 8094124..4f93a77 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -68,6 +68,8 @@ int main(int argc, char** argv)
{
// Construct and print requested documentation.
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
std::vector<cmDocumentationEntry> generators;
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 403a459..e3b7a2b 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -28,6 +28,7 @@
#include "cmCTestStartCommand.h"
#include "cmAlgorithms.h"
#include "cmState.h"
+#include "cmXMLWriter.h"
#include "cmCTestBuildHandler.h"
#include "cmCTestBuildAndTestHandler.h"
@@ -510,9 +511,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
}
cmake cm;
- cmGlobalGenerator gg;
- gg.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cmGlobalGenerator gg(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile();
if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) )
{
@@ -1488,7 +1490,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
}
//----------------------------------------------------------------------
-void cmCTest::StartXML(std::ostream& ostr, bool append)
+void cmCTest::StartXML(cmXMLWriter& xml, bool append)
{
if(this->CurrentTag.empty())
{
@@ -1511,42 +1513,45 @@ void cmCTest::StartXML(std::ostream& ostr, bool append)
std::string site = cmCTest::SafeBuildIdField(
this->GetCTestConfiguration("Site"));
- ostr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<Site BuildName=\"" << buildname << "\"\n"
- << "\tBuildStamp=\"" << stamp << "\"\n"
- << "\tName=\"" << site << "\"\n"
- << "\tGenerator=\"ctest-" << cmVersion::GetCMakeVersion() << "\"\n"
- << (append? "\tAppend=\"true\"\n":"")
- << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler")
- << "\"\n"
+ xml.StartDocument();
+ xml.StartElement("Site");
+ xml.Attribute("BuildName", buildname);
+ xml.BreakAttributes();
+ xml.Attribute("BuildStamp", stamp);
+ xml.Attribute("Name", site);
+ xml.Attribute("Generator",
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
+ if(append)
+ {
+ xml.Attribute("Append", "true");
+ }
+ xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler"));
#ifdef _COMPILER_VERSION
- << "\tCompilerVersion=\"_COMPILER_VERSION\"\n"
+ xml.Attribute("CompilerVersion", _COMPILER_VERSION);
#endif
- << "\tOSName=\"" << info.GetOSName() << "\"\n"
- << "\tHostname=\"" << info.GetHostname() << "\"\n"
- << "\tOSRelease=\"" << info.GetOSRelease() << "\"\n"
- << "\tOSVersion=\"" << info.GetOSVersion() << "\"\n"
- << "\tOSPlatform=\"" << info.GetOSPlatform() << "\"\n"
- << "\tIs64Bits=\"" << info.Is64Bits() << "\"\n"
- << "\tVendorString=\"" << info.GetVendorString() << "\"\n"
- << "\tVendorID=\"" << info.GetVendorID() << "\"\n"
- << "\tFamilyID=\"" << info.GetFamilyID() << "\"\n"
- << "\tModelID=\"" << info.GetModelID() << "\"\n"
- << "\tProcessorCacheSize=\"" << info.GetProcessorCacheSize() << "\"\n"
- << "\tNumberOfLogicalCPU=\"" << info.GetNumberOfLogicalCPU() << "\"\n"
- << "\tNumberOfPhysicalCPU=\""<< info.GetNumberOfPhysicalCPU() << "\"\n"
- << "\tTotalVirtualMemory=\"" << info.GetTotalVirtualMemory() << "\"\n"
- << "\tTotalPhysicalMemory=\""<< info.GetTotalPhysicalMemory() << "\"\n"
- << "\tLogicalProcessorsPerPhysical=\""
- << info.GetLogicalProcessorsPerPhysical() << "\"\n"
- << "\tProcessorClockFrequency=\""
- << info.GetProcessorClockFrequency() << "\"\n"
- << ">" << std::endl;
- this->AddSiteProperties(ostr);
-}
-
-//----------------------------------------------------------------------
-void cmCTest::AddSiteProperties(std::ostream& ostr)
+ xml.Attribute("OSName", info.GetOSName());
+ xml.Attribute("Hostname", info.GetHostname());
+ xml.Attribute("OSRelease", info.GetOSRelease());
+ xml.Attribute("OSVersion", info.GetOSVersion());
+ xml.Attribute("OSPlatform", info.GetOSPlatform());
+ xml.Attribute("Is64Bits", info.Is64Bits());
+ xml.Attribute("VendorString", info.GetVendorString());
+ xml.Attribute("VendorID", info.GetVendorID());
+ xml.Attribute("FamilyID", info.GetFamilyID());
+ xml.Attribute("ModelID", info.GetModelID());
+ xml.Attribute("ProcessorCacheSize", info.GetProcessorCacheSize());
+ xml.Attribute("NumberOfLogicalCPU", info.GetNumberOfLogicalCPU());
+ xml.Attribute("NumberOfPhysicalCPU", info.GetNumberOfPhysicalCPU());
+ xml.Attribute("TotalVirtualMemory", info.GetTotalVirtualMemory());
+ xml.Attribute("TotalPhysicalMemory", info.GetTotalPhysicalMemory());
+ xml.Attribute("LogicalProcessorsPerPhysical",
+ info.GetLogicalProcessorsPerPhysical());
+ xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
+ this->AddSiteProperties(xml);
+}
+
+//----------------------------------------------------------------------
+void cmCTest::AddSiteProperties(cmXMLWriter& xml)
{
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
@@ -1562,92 +1567,95 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
->GetGlobalProperty("SubProject");
if(subproject)
{
- ostr << "<Subproject name=\"" << subproject << "\">\n";
+ xml.StartElement("Subproject");
+ xml.Attribute("name", subproject);
const char* labels =
ch->GetCMake()->GetState()
->GetGlobalProperty("SubProjectLabels");
if(labels)
{
- ostr << " <Labels>\n";
+ xml.StartElement("Labels");
std::string l = labels;
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(l, args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
- ostr << " <Label>" << *i << "</Label>\n";
+ xml.Element("Label", *i);
}
- ostr << " </Labels>\n";
+ xml.EndElement();
}
- ostr << "</Subproject>\n";
+ xml.EndElement();
}
// This code should stay when cdash only does label based sub-projects
const char* label = cm->GetState()->GetGlobalProperty("Label");
if(label)
{
- ostr << "<Labels>\n";
- ostr << " <Label>" << label << "</Label>\n";
- ostr << "</Labels>\n";
+ xml.StartElement("Labels");
+ xml.Element("Label", label);
+ xml.EndElement();
}
}
-
//----------------------------------------------------------------------
-void cmCTest::EndXML(std::ostream& ostr)
+void cmCTest::EndXML(cmXMLWriter& xml)
{
- ostr << "</Site>" << std::endl;
+ xml.EndElement(); // Site
+ xml.EndDocument();
}
//----------------------------------------------------------------------
-int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
+int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
const cmCTest::VectorOfStrings& files)
{
std::string buildname = cmCTest::SafeBuildIdField(
this->GetCTestConfiguration("BuildName"));
cmCTest::VectorOfStrings::const_iterator it;
- os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<?xml-stylesheet type=\"text/xsl\" "
+ xml.StartDocument();
+ xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
"href=\"Dart/Source/Server/XSL/Build.xsl "
- "<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
- << "<Site BuildName=\"" << buildname
- << "\" BuildStamp=\""
- << this->CurrentTag << "-" << this->GetTestModelString() << "\" Name=\""
- << this->GetCTestConfiguration("Site") << "\" Generator=\"ctest"
- << cmVersion::GetCMakeVersion()
- << "\">\n";
- this->AddSiteProperties(os);
- os << "<Notes>" << std::endl;
+ "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+ xml.StartElement("Site");
+ xml.Attribute("BuildName", buildname);
+ xml.Attribute("BuildStamp", this->CurrentTag+"-"+this->GetTestModelString());
+ xml.Attribute("Name", this->GetCTestConfiguration("Site"));
+ xml.Attribute("Generator",std::string("ctest")+cmVersion::GetCMakeVersion());
+ this->AddSiteProperties(xml);
+ xml.StartElement("Notes");
for ( it = files.begin(); it != files.end(); it ++ )
{
cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
std::string note_time = this->CurrentTime();
- os << "<Note Name=\"" << cmXMLSafe(*it) << "\">\n"
- << "<Time>" << cmSystemTools::GetTime() << "</Time>\n"
- << "<DateTime>" << note_time << "</DateTime>\n"
- << "<Text>" << std::endl;
+ xml.StartElement("Note");
+ xml.Attribute("Name", *it);
+ xml.Element("Time", cmSystemTools::GetTime());
+ xml.Element("DateTime", note_time);
+ xml.StartElement("Text");
cmsys::ifstream ifs(it->c_str());
if ( ifs )
{
std::string line;
while ( cmSystemTools::GetLineFromStream(ifs, line) )
{
- os << cmXMLSafe(line) << std::endl;
+ xml.Content(line);
+ xml.Content("\n");
}
ifs.close();
}
else
{
- os << "Problem reading file: " << *it << std::endl;
+ xml.Content("Problem reading file: " + *it + "\n");
cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it
<< " while creating notes" << std::endl);
}
- os << "</Text>\n"
- << "</Note>" << std::endl;
+ xml.EndElement(); // Text
+ xml.EndElement(); // Note
}
- os << "</Notes>\n"
- << "</Site>" << std::endl;
+ xml.EndElement(); // Notes
+ xml.EndElement(); // Site
+ xml.EndDocument();
return 1;
}
@@ -1660,8 +1668,8 @@ int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl);
return 1;
}
-
- this->GenerateCTestNotesOutput(ofs, files);
+ cmXMLWriter xml(ofs);
+ this->GenerateCTestNotesOutput(xml, files);
return 0;
}
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 3f033d9..db3ea10 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -24,6 +24,7 @@ class cmGeneratedFileStream;
class cmCTestCommand;
class cmCTestScriptHandler;
class cmCTestStartCommand;
+class cmXMLWriter;
#define cmCTestLog(ctSelf, logType, msg) \
do { \
@@ -273,10 +274,10 @@ public:
static std::string SafeBuildIdField(const std::string& value);
//! Start CTest XML output file
- void StartXML(std::ostream& ostr, bool append);
+ void StartXML(cmXMLWriter& xml, bool append);
//! End CTest XML output file
- void EndXML(std::ostream& ostr);
+ void EndXML(cmXMLWriter& xml);
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
@@ -420,7 +421,7 @@ public:
/** Direct process output to given streams. */
void SetStreams(std::ostream* out, std::ostream* err)
{ this->StreamOut = out; this->StreamErr = err; }
- void AddSiteProperties(std::ostream& );
+ void AddSiteProperties(cmXMLWriter& xml);
bool GetLabelSummary() { return this->LabelSummary;}
std::string GetCostDataFile();
@@ -553,7 +554,7 @@ private:
bool UpdateCTestConfiguration();
//! Create note from files.
- int GenerateCTestNotesOutput(std::ostream& os,
+ int GenerateCTestNotesOutput(cmXMLWriter& xml,
const VectorOfStrings& files);
//! Check if the argument is the one specified
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 289d0dc..108208e 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -407,14 +407,9 @@ bool cmCacheManager::SaveCache(const std::string& path)
" was created", cmState::INTERNAL);
fout << "# This is the CMakeCache file.\n"
- << "# For build in directory: " << currentcwd << "\n";
- cmCacheManager::CacheEntry* cmakeCacheEntry
- = this->GetCacheEntry("CMAKE_COMMAND");
- if ( cmakeCacheEntry )
- {
- fout << "# It was generated by CMake: " <<
- cmakeCacheEntry->Value << std::endl;
- }
+ << "# For build in directory: " << currentcwd << "\n"
+ << "# It was generated by CMake: "
+ << cmSystemTools::GetCMakeCommand() << std::endl;
fout << "# You can edit this file to change values found and used by cmake."
<< std::endl
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 0d1c86d..bd098a5 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -14,6 +14,7 @@
#include "cmSystemTools.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmLocalGenerator.h"
#include "cmCommandArgumentLexer.h"
@@ -139,14 +140,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
this->Makefile->GetHomeOutputDirectory()))
{
std::ostringstream msg;
- cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
cmListFileContext lfc;
- lfc.FilePath = this->FileName;
+ lfc.FilePath = this->Makefile->GetLocalGenerator()
+ ->Convert(this->FileName, cmLocalGenerator::HOME);
+
lfc.Line = this->FileLine;
- bt.push_back(lfc);
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str(), bt);
+ msg.str(), lfc);
}
}
return 0;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 73aface..61847d4 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -112,10 +112,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
{
- bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
- this->Makefile.GetBacktrace()[0]);
-
- if(!hasBeenReported)
+ if(!this->Makefile.HasCMP0054AlreadyBeenReported())
{
std::ostringstream e;
e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
@@ -161,10 +158,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
if(isKeyword && argument.WasQuoted() &&
this->Policy54Status == cmPolicies::WARN)
{
- bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
- this->Makefile.GetBacktrace()[0]);
-
- if(!hasBeenReported)
+ if(!this->Makefile.HasCMP0054AlreadyBeenReported())
{
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index c0a1aa9..62128a7 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -14,4 +14,5 @@
#cmakedefine CMAKE_USE_ELF_PARSER
#cmakedefine CMAKE_USE_MACH_PARSER
#cmakedefine CMAKE_ENCODING_UTF8
+#cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index f54bc4d..2dab169 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -18,35 +18,57 @@ cmDefinitions::Def cmDefinitions::NoDef;
//----------------------------------------------------------------------------
cmDefinitions::Def const& cmDefinitions::GetInternal(
- const std::string& key,
- std::list<cmDefinitions>::reverse_iterator rbegin,
- std::list<cmDefinitions>::reverse_iterator rend)
+ const std::string& key, StackIter begin, StackIter end, bool raise)
{
- assert(rbegin != rend);
- MapType::const_iterator i = rbegin->Map.find(key);
- if (i != rbegin->Map.end())
+ assert(begin != end);
+ MapType::iterator i = begin->Map.find(key);
+ if (i != begin->Map.end())
{
+ i->second.Used = true;
return i->second;
}
- std::list<cmDefinitions>::reverse_iterator rit = rbegin;
- ++rit;
- if (rit == rend)
+ StackIter it = begin;
+ ++it;
+ if (it == end)
{
return cmDefinitions::NoDef;
}
- Def const& def = cmDefinitions::GetInternal(key, rit, rend);
- return rbegin->Map.insert(MapType::value_type(key, def)).first->second;
+ Def const& def = cmDefinitions::GetInternal(key, it, end, raise);
+ if (!raise)
+ {
+ return def;
+ }
+ return begin->Map.insert(MapType::value_type(key, def)).first->second;
}
//----------------------------------------------------------------------------
const char* cmDefinitions::Get(const std::string& key,
- std::list<cmDefinitions>::reverse_iterator rbegin,
- std::list<cmDefinitions>::reverse_iterator rend)
+ StackIter begin, StackIter end)
{
- Def const& def = cmDefinitions::GetInternal(key, rbegin, rend);
+ Def const& def = cmDefinitions::GetInternal(key, begin, end, false);
return def.Exists? def.c_str() : 0;
}
+void cmDefinitions::Raise(const std::string& key,
+ StackIter begin, StackIter end)
+{
+ cmDefinitions::GetInternal(key, begin, end, true);
+}
+
+bool cmDefinitions::HasKey(const std::string& key,
+ StackConstIter begin, StackConstIter end)
+{
+ for (StackConstIter it = begin; it != end; ++it)
+ {
+ MapType::const_iterator i = it->Map.find(key);
+ if (i != it->Map.end())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
//----------------------------------------------------------------------------
void cmDefinitions::Set(const std::string& key, const char* value)
{
@@ -54,13 +76,8 @@ void cmDefinitions::Set(const std::string& key, const char* value)
this->Map[key] = def;
}
-void cmDefinitions::Erase(const std::string& key)
-{
- this->Map.erase(key);
-}
-
//----------------------------------------------------------------------------
-std::vector<std::string> cmDefinitions::LocalKeys() const
+std::vector<std::string> cmDefinitions::UnusedKeys() const
{
std::vector<std::string> keys;
keys.reserve(this->Map.size());
@@ -68,7 +85,7 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
for(MapType::const_iterator mi = this->Map.begin();
mi != this->Map.end(); ++mi)
{
- if (mi->second.Exists)
+ if (!mi->second.Used)
{
keys.push_back(mi->first);
}
@@ -77,36 +94,24 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
}
//----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure(
- std::list<cmDefinitions>::const_reverse_iterator rbegin,
- std::list<cmDefinitions>::const_reverse_iterator rend)
+cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
+ StackConstIter end)
{
- std::set<std::string> undefined;
cmDefinitions closure;
- closure.MakeClosure(undefined, rbegin, rend);
- return closure;
-}
-
-//----------------------------------------------------------------------------
-void
-cmDefinitions::MakeClosure(std::set<std::string>& undefined,
- std::list<cmDefinitions>::const_reverse_iterator rbegin,
- std::list<cmDefinitions>::const_reverse_iterator rend)
-{
- for (std::list<cmDefinitions>::const_reverse_iterator it = rbegin;
- it != rend; ++it)
+ std::set<std::string> undefined;
+ for (StackConstIter it = begin; it != end; ++it)
{
// Consider local definitions.
for(MapType::const_iterator mi = it->Map.begin();
mi != it->Map.end(); ++mi)
{
// Use this key if it is not already set or unset.
- if(this->Map.find(mi->first) == this->Map.end() &&
+ if(closure.Map.find(mi->first) == closure.Map.end() &&
undefined.find(mi->first) == undefined.end())
{
if(mi->second.Exists)
{
- this->Map.insert(*mi);
+ closure.Map.insert(*mi);
}
else
{
@@ -115,22 +120,29 @@ cmDefinitions::MakeClosure(std::set<std::string>& undefined,
}
}
}
+ return closure;
}
//----------------------------------------------------------------------------
std::vector<std::string>
-cmDefinitions::ClosureKeys(std::set<std::string>& bound) const
+cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end)
{
+ std::set<std::string> bound;
std::vector<std::string> defined;
- defined.reserve(this->Map.size());
- for(MapType::const_iterator mi = this->Map.begin();
- mi != this->Map.end(); ++mi)
+
+ for (StackConstIter it = begin; it != end; ++it)
{
- // Use this key if it is not already set or unset.
- if(bound.insert(mi->first).second && mi->second.Exists)
+ defined.reserve(defined.size() + it->Map.size());
+ for(MapType::const_iterator mi = it->Map.begin();
+ mi != it->Map.end(); ++mi)
{
- defined.push_back(mi->first);
+ // Use this key if it is not already set or unset.
+ if(bound.insert(mi->first).second && mi->second.Exists)
+ {
+ defined.push_back(mi->first);
+ }
}
}
+
return defined;
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index b244793..5fdcaab 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -14,8 +14,12 @@
#include "cmStandardIncludes.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
#include "cmsys/hash_map.hxx"
#endif
+#endif
#include <list>
@@ -28,27 +32,26 @@
*/
class cmDefinitions
{
+ typedef std::list<cmDefinitions>::reverse_iterator StackIter;
+ typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
public:
- /** Get the value associated with a key; null if none.
- Store the result locally if it came from a parent. */
static const char* Get(const std::string& key,
- std::list<cmDefinitions>::reverse_iterator rbegin,
- std::list<cmDefinitions>::reverse_iterator rend);
+ StackIter begin, StackIter end);
+
+ static void Raise(const std::string& key, StackIter begin, StackIter end);
+
+ static bool HasKey(const std::string& key,
+ StackConstIter begin, StackConstIter end);
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
- void Erase(const std::string& key);
+ std::vector<std::string> UnusedKeys() const;
- /** Get the set of all local keys. */
- std::vector<std::string> LocalKeys() const;
+ static std::vector<std::string> ClosureKeys(StackConstIter begin,
+ StackConstIter end);
- std::vector<std::string>
- ClosureKeys(std::set<std::string>& bound) const;
-
- static cmDefinitions MakeClosure(
- std::list<cmDefinitions>::const_reverse_iterator rbegin,
- std::list<cmDefinitions>::const_reverse_iterator rend);
+ static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);
private:
// String with existence boolean.
@@ -57,28 +60,32 @@ private:
private:
typedef std::string std_string;
public:
- Def(): std_string(), Exists(false) {}
- Def(const char* v): std_string(v?v:""), Exists(v?true:false) {}
- Def(const std_string& v): std_string(v), Exists(true) {}
- Def(Def const& d): std_string(d), Exists(d.Exists) {}
+ Def(): std_string(), Exists(false), Used(false) {}
+ Def(const char* v)
+ : std_string(v ? v : ""),
+ Exists(v ? true : false),
+ Used(false)
+ {}
+ Def(const std_string& v): std_string(v), Exists(true), Used(false) {}
+ Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {}
bool Exists;
+ bool Used;
};
static Def NoDef;
- // Local definitions, set or unset.
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, Def> MapType;
+#else
typedef cmsys::hash_map<std::string, Def> MapType;
+#endif
#else
typedef std::map<std::string, Def> MapType;
#endif
MapType Map;
static Def const& GetInternal(const std::string& key,
- std::list<cmDefinitions>::reverse_iterator rbegin,
- std::list<cmDefinitions>::reverse_iterator rend);
- void MakeClosure(std::set<std::string>& undefined,
- std::list<cmDefinitions>::const_reverse_iterator rbegin,
- std::list<cmDefinitions>::const_reverse_iterator rend);
+ StackIter begin, StackIter end, bool raise);
};
#endif
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index d4da5a4..201465d 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -12,47 +12,44 @@
#ifndef cmExecutionStatus_h
#define cmExecutionStatus_h
-#include "cmObject.h"
+#include "cmStandardIncludes.h"
/** \class cmExecutionStatus
* \brief Superclass for all command status classes
*
* when a command is involked it may set values on a command status instance
*/
-class cmExecutionStatus : public cmObject
+class cmExecutionStatus
{
public:
- cmTypeMacro(cmExecutionStatus, cmObject);
+ cmExecutionStatus() { this->Clear(); }
- cmExecutionStatus() { this->Clear();}
-
- virtual void SetReturnInvoked(bool val)
+ void SetReturnInvoked(bool val)
{ this->ReturnInvoked = val; }
- virtual bool GetReturnInvoked()
+ bool GetReturnInvoked()
{ return this->ReturnInvoked; }
- virtual void SetBreakInvoked(bool val)
+ void SetBreakInvoked(bool val)
{ this->BreakInvoked = val; }
- virtual bool GetBreakInvoked()
+ bool GetBreakInvoked()
{ return this->BreakInvoked; }
- virtual void SetContinueInvoked(bool val)
+ void SetContinueInvoked(bool val)
{ this->ContinueInvoked = val; }
- virtual bool GetContinueInvoked()
+ bool GetContinueInvoked()
{ return this->ContinueInvoked; }
- virtual void Clear()
+ void Clear()
{
this->ReturnInvoked = false;
this->BreakInvoked = false;
this->ContinueInvoked = false;
this->NestedError = false;
}
- virtual void SetNestedError(bool val) { this->NestedError = val; }
- virtual bool GetNestedError() { return this->NestedError; }
-
+ void SetNestedError(bool val) { this->NestedError = val; }
+ bool GetNestedError() { return this->NestedError; }
-protected:
+private:
bool ReturnInvoked;
bool BreakInvoked;
bool ContinueInvoked;
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 72a6a30..a81e53c 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -1008,7 +1008,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_ECLIPSE_MAKE_ARGUMENTS");
- const std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmGlobalGenerator* generator
= const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
@@ -1096,11 +1095,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::string cleanArgs = "-E chdir \"";
cleanArgs += makefile->GetCurrentBinaryDirectory();
cleanArgs += "\" \"";
- cleanArgs += cmake;
+ cleanArgs += cmSystemTools::GetCMakeCommand();
cleanArgs += "\" -P \"";
cleanArgs += (*it)->GetTargetDirectory(ti->second);
cleanArgs += "/cmake_clean.cmake\"";
- this->AppendTarget(fout, "Clean", cmake, cleanArgs, virtDir, "", "");
+ this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(),
+ cleanArgs, virtDir, "", "");
}
}
break;
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index ec141a9..578e7d3 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -247,7 +247,7 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const
return;
}
- fout << "#Generated by " << mf->GetRequiredDefinition("CMAKE_COMMAND")
+ fout << "#Generated by " << cmSystemTools::GetCMakeCommand()
<< ", do not edit.\n";
}
diff --git a/Source/cmExtraQbsGenerator.cxx b/Source/cmExtraQbsGenerator.cxx
deleted file mode 100644
index 4cc4650..0000000
--- a/Source/cmExtraQbsGenerator.cxx
+++ /dev/null
@@ -1,260 +0,0 @@
-#include "cmExtraQbsGenerator.h"
-
-#include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmSourceFile.h"
-
-cmExtraQbsGenerator::cmExtraQbsGenerator()
-{
-#if defined(_WIN32)
- this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
- this->SupportedGlobalGenerators.push_back("NMake Makefiles");
-#endif
- this->SupportedGlobalGenerators.push_back("Ninja");
- this->SupportedGlobalGenerators.push_back("Unix Makefiles");
-}
-
-cmExtraQbsGenerator::~cmExtraQbsGenerator() {}
-
-void cmExtraQbsGenerator::GetDocumentation(cmDocumentationEntry &entry,
- const std::string &) const
-{
- entry.Name = this->GetName();
- entry.Brief = "Generates Qbs project files.";
-}
-
-void cmExtraQbsGenerator::Generate()
-{
- for (std::map<std::string, std::vector<cmLocalGenerator *> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it)
- {
- // create a project file
- this->CreateProjectFile(it->first, it->second);
- }
-}
-
-void cmExtraQbsGenerator::CreateProjectFile(
- const std::string &name,
- const std::vector<cmLocalGenerator *> &lgs)
-{
- const cmMakefile *mf = lgs[0]->GetMakefile();
- std::string outputDir = mf->GetCurrentBinaryDirectory();
-
- const std::string filename = outputDir + "/" + name + ".qbs";
-
- this->CreateNewProjectFile(name, lgs, filename);
-}
-
-void cmExtraQbsGenerator::CreateNewProjectFile(
- const std::string &projectName, const std::vector<cmLocalGenerator *> &lgs,
- const std::string &filename)
-{
- cmGeneratedFileStream fout(filename.c_str());
- if (!fout)
- {
- return;
- }
-
- fout << "import qbs\n"
- << "import qbs.File\n\n"
- << "Project {\n"
- << "\tname:\"" << projectName << "\"\n";
- std::vector<cmLocalGenerator *>::const_iterator itr = lgs.begin();
- for (; itr != lgs.end(); ++itr)
- {
- cmLocalGenerator *lg = (*itr);
- this->AppendSubProject(fout, lg);
- }
- fout << "}\n";
-}
-
-void cmExtraQbsGenerator::AppendSubProject(cmGeneratedFileStream &fout,
- cmLocalGenerator *lg)
-{
- const cmMakefile *mk = lg->GetMakefile();
- if (!mk || mk->GetTargets().size() == 0)
- {
- return;
- }
-
- const std::string &relativePath = cmSystemTools::RelativePath(
- mk->GetHomeDirectory(), mk->GetCurrentSourceDirectory());
- fout << "\tProject {\n"
- << "\t\tname:\"" << relativePath << "\"\n";
- this->AppendProduct(fout, lg);
- fout << "\t}\n";
-}
-
-void cmExtraQbsGenerator::AppendProduct(cmGeneratedFileStream &fout,
- cmLocalGenerator *lg)
-{
- const cmMakefile *mk = lg->GetMakefile();
- const cmTargets &ts = mk->GetTargets();
- std::string cfg = mk->GetSafeDefinition("CMAKE_BUILD_TYPE");
- cmTargets::const_iterator itr = ts.begin();
- for (; itr != ts.end(); ++itr)
- {
- const cmTarget &t = itr->second;
- this->AppendTarget(fout, lg, t, cfg);
- }
-}
-
-void cmExtraQbsGenerator::AppendTarget(cmGeneratedFileStream &fout,
- cmLocalGenerator *lg, const cmTarget &t,
- const std::string &cfg)
-{
- std::string type;
- bool isBuildable = true;
- switch (t.GetType())
- {
- case cmTarget::EXECUTABLE:
- type = "application";
- break;
- case cmTarget::SHARED_LIBRARY:
- type = "dynamiclibrary";
- break;
- case cmTarget::STATIC_LIBRARY:
- type = "staticlibrary";
- break;
- default:
- isBuildable = false;
- break;
- }
-
- if (type.empty())
- {
- fout << "\t\tProject {\n";
- }
- else
- {
- fout << "\t\tProduct {\n";
- fout << "\t\t\tdestinationDirectory: \"" << t.GetDirectory(cfg) << "\"\n";
- }
- fout << "\t\t\tname:\"" << t.GetName() << "\"\n";
-
- if (!type.empty())
- {
- fout << "\t\t\ttype: \"" << type << "\"\n";
- fout << "\t\t\ttargetName: \"" << t.GetName() << "\"\n";
- }
-
- if (isBuildable)
- {
- fout << "\t\t\tDepends { name: \"cpp\" }\n";
- cmGeneratorTarget *gt = this->GlobalGenerator->GetGeneratorTarget(&t);
- this->AppendSources(fout, gt, t, cfg);
-
- std::set<std::string> langs, incPaths, defs;
- t.GetLanguages(langs, cfg);
- for (std::set<std::string>::const_iterator lang = langs.begin();
- lang != langs.end();
- ++ lang)
- {
- const std::vector<std::string> &paths =
- gt->GetIncludeDirectories(cfg, *lang);
- std::copy(paths.begin(), paths.end(),
- std::inserter(incPaths, incPaths.end()));
-
- lg->AddCompileDefinitions(defs, &t, cfg, *lang);
- }
- this->AppendIncludePaths(fout, incPaths);
- this->AppendCompileDefinitions(fout, defs);
- }
-
- fout << "\t\t}\n";
-}
-
-void cmExtraQbsGenerator::AppendSources(cmGeneratedFileStream &fout,
- cmGeneratorTarget *gt,
- const cmTarget &t,
- const std::string &cfg)
-{
- std::vector<cmSourceFile *> sources;
- gt->GetSourceFiles(sources, cfg);
- if (sources.empty())
- {
- return;
- }
-
- std::vector<cmSourceFile *> genSources;
- std::vector<cmSourceFile *>::const_iterator itr = sources.begin();
- fout << "\t\t\tfiles: [\n"
- << "\t\t\t\t\"" << t.GetMakefile()->GetCurrentListFile() << "\",\n";
- for (; itr != sources.end(); ++itr)
- {
- if (!(*itr)->GetPropertyAsBool("GENERATED"))
- {
- fout << "\t\t\t\t\"" << (*itr)->GetFullPath() << "\",\n";
- }
- else
- {
- genSources.push_back(*itr);
- }
- }
- fout << "\t\t\t]\n";
-
- if (!genSources.empty())
- {
- fout << "\t\t\tGroup {\n"
- << "\t\t\t\tname:\"Generated\"\n"
- << "\t\t\t\tfiles: [\n";
- itr = genSources.begin();
- std::string groupCondition;
- bool initialCondition = true;
- for (; itr != genSources.end(); ++itr)
- {
- const std::string &path = (*itr)->GetFullPath();
- fout << "\t\t\t\t\t\"" << path << "\",\n";
- if (initialCondition)
- {
- initialCondition = false;
- }
- else
- {
- groupCondition += "\t\t\t\t\t && ";
- }
- groupCondition += "File.exists(\"" + path + "\")\n";
- }
- fout << "\t\t\t\t]\n"
- << "\t\t\t\tcondition: " << groupCondition << "\t\t\t}\n";
- }
-}
-
-void cmExtraQbsGenerator::AppendIncludePaths(
- cmGeneratedFileStream &fout,
- const std::set<std::string> &paths)
-{
- if (paths.empty())
- {
- return;
- }
-
- std::set<std::string>::const_iterator itr = paths.begin();
- fout << "\t\t\tcpp.includePaths: [\n";
- for (; itr != paths.end(); ++ itr)
- {
- fout << "\t\t\t\t\"" << (*itr) << "\",\n";
- }
- fout << "\t\t\t]\n";
-}
-
-void cmExtraQbsGenerator::AppendCompileDefinitions(
- cmGeneratedFileStream &fout,
- const std::set<std::string> &defs)
-{
- if (defs.empty())
- {
- return;
- }
-
- std::set<std::string>::const_iterator itr = defs.begin();
- fout << "\t\t\tcpp.defines: [\n";
- for (; itr != defs.end(); ++ itr)
- {
- fout << "\t\t\t\t'" << (*itr) << "',\n";
- }
- fout << "\t\t\t]\n";
-}
diff --git a/Source/cmExtraQbsGenerator.h b/Source/cmExtraQbsGenerator.h
deleted file mode 100644
index 531ccc9..0000000
--- a/Source/cmExtraQbsGenerator.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CMEXTRAQBSGENERATOR_H
-#define CMEXTRAQBSGENERATOR_H
-
-#include "cmExternalMakefileProjectGenerator.h"
-
-class cmGeneratorTarget;
-
-class cmExtraQbsGenerator : public cmExternalMakefileProjectGenerator
-{
-public:
- cmExtraQbsGenerator();
- ~cmExtraQbsGenerator();
-
- virtual std::string GetName() const
- { return cmExtraQbsGenerator::GetActualName(); }
- static std::string GetActualName() { return "Qbs"; }
- static cmExternalMakefileProjectGenerator *New()
- { return new cmExtraQbsGenerator; }
-
- /** Get the documentation entry for this generator. */
- virtual void GetDocumentation(cmDocumentationEntry &entry,
- const std::string &fullName) const;
-
- virtual void Generate();
-
-private:
- void CreateProjectFile(const std::string &name,
- const std::vector<cmLocalGenerator *> &lgs);
- void CreateNewProjectFile(const std::string &projectName,
- const std::vector<cmLocalGenerator *> &lgs,
- const std::string &filename);
- void AppendSubProject(cmGeneratedFileStream &fout, cmLocalGenerator *lg);
- void AppendProduct(cmGeneratedFileStream &fout, cmLocalGenerator *lg);
- void AppendTarget(cmGeneratedFileStream &fout,
- cmLocalGenerator *lg,
- const cmTarget &t,
- const std::string &cfg);
- void AppendSources(cmGeneratedFileStream &fout,
- cmGeneratorTarget *gt,
- const cmTarget &t,
- const std::string &cfg);
- void AppendIncludePaths(cmGeneratedFileStream &fout,
- const std::set<std::string> &paths);
- void AppendCompileDefinitions(cmGeneratedFileStream &fout,
- const std::set<std::string> &defs);
-};
-
-#endif // CMEXTRAQBSGENERATOR_H
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 0af4688..4698468 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2798,13 +2798,36 @@ namespace {
static size_t
- cmFileCommandCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
+ cmFileCommandCurlDebugCallback(CURL *, curl_infotype type, char *chPtr,
size_t size, void *data)
{
cmFileCommandVectorOfChar *vec
= static_cast<cmFileCommandVectorOfChar*>(data);
- vec->insert(vec->end(), chPtr, chPtr + size);
- return size;
+ switch(type)
+ {
+ case CURLINFO_TEXT:
+ case CURLINFO_HEADER_IN:
+ case CURLINFO_HEADER_OUT:
+ vec->insert(vec->end(), chPtr, chPtr + size);
+ break;
+ case CURLINFO_DATA_IN:
+ case CURLINFO_DATA_OUT:
+ case CURLINFO_SSL_DATA_IN:
+ case CURLINFO_SSL_DATA_OUT:
+ {
+ char buf[128];
+ int n = sprintf(buf, "[%" cmIML_INT_PRIu64 " bytes data]\n",
+ static_cast<cmIML_INT_uint64_t>(size));
+ if (n > 0)
+ {
+ vec->insert(vec->end(), buf, buf + n);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return 0;
}
@@ -2963,7 +2986,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
long timeout = 0;
long inactivity_timeout = 0;
- std::string verboseLog;
+ std::string logVar;
std::string statusVar;
bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY");
const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
@@ -3008,7 +3031,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
this->SetError("DOWNLOAD missing VAR for LOG.");
return false;
}
- verboseLog = *i;
+ logVar = *i;
}
else if(*i == "STATUS")
{
@@ -3200,7 +3223,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: ");
- if(!verboseLog.empty())
+ if(!logVar.empty())
{
res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
check_curl_result(res, "DOWNLOAD cannot set verbose: ");
@@ -3287,22 +3310,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
}
}
- if(!chunkDebug.empty())
+ if (!logVar.empty())
{
chunkDebug.push_back(0);
- if(CURLE_OPERATION_TIMEOUTED == res)
- {
- std::string output = &*chunkDebug.begin();
-
- if(!verboseLog.empty())
- {
- this->Makefile->AddDefinition(verboseLog,
- &*chunkDebug.begin());
- }
- }
-
- this->Makefile->AddDefinition(verboseLog,
- &*chunkDebug.begin());
+ this->Makefile->AddDefinition(logVar, &*chunkDebug.begin());
}
return true;
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 5727470..13e2a66 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -13,8 +13,12 @@
// Use a hash table to avoid duplicate file time checks from disk.
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
# include <cmsys/hash_map.hxx>
#endif
+#endif
#include <cmsys/Encoding.hxx>
@@ -47,9 +51,17 @@ private:
{
return h(s.c_str());
}
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ std::hash<const char*> h;
+#else
cmsys::hash<const char*> h;
+#endif
};
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string,
+#else
typedef cmsys::hash_map<std::string,
+#endif
cmFileTimeComparison_Type, HashString> FileStatsMap;
FileStatsMap Files;
#endif
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 8e3510d..e983bfb 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -13,6 +13,17 @@
#include <cmsys/auto_ptr.hxx>
+cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf):
+ Makefile(mf), Depth(0)
+{
+ this->Makefile->PushLoopBlock();
+}
+
+cmForEachFunctionBlocker::~cmForEachFunctionBlocker()
+{
+ this->Makefile->PopLoopBlock();
+}
+
bool cmForEachFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus)
@@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endofreach for this statement
if (!this->Depth)
{
- cmMakefile::LoopBlockPop loopBlockPop(&mf);
-
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -44,8 +53,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
std::vector<std::string>::const_iterator j = this->Args.begin();
++j;
- std::string tmps;
- cmListFileArgument arg;
for( ; j != this->Args.end(); ++j)
{
// set the variable to the loop value
@@ -130,7 +137,7 @@ bool cmForEachCommand
}
// create a function blocker
- cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker();
+ cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(this->Makefile);
if ( args.size() > 1 )
{
if ( args[1] == "RANGE" )
@@ -206,15 +213,14 @@ bool cmForEachCommand
}
this->Makefile->AddFunctionBlocker(f);
- this->Makefile->PushLoopBlock();
-
return true;
}
//----------------------------------------------------------------------------
bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
{
- cmsys::auto_ptr<cmForEachFunctionBlocker> f(new cmForEachFunctionBlocker());
+ cmsys::auto_ptr<cmForEachFunctionBlocker>
+ f(new cmForEachFunctionBlocker(this->Makefile));
f->Args.push_back(args[0]);
enum Doing { DoingNone, DoingLists, DoingItems };
@@ -252,7 +258,5 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
- this->Makefile->PushLoopBlock();
-
return true;
}
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index 9b7c85a..36e8808 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -19,8 +19,8 @@
class cmForEachFunctionBlocker : public cmFunctionBlocker
{
public:
- cmForEachFunctionBlocker() {this->Depth = 0;}
- virtual ~cmForEachFunctionBlocker() {}
+ cmForEachFunctionBlocker(cmMakefile* mf);
+ ~cmForEachFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf,
cmExecutionStatus &);
@@ -29,6 +29,7 @@ public:
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
private:
+ cmMakefile* Makefile;
int Depth;
};
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index fdd1018..001adb1 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -94,8 +94,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
}
// we push a scope on the makefile
- cmMakefile::LexicalPushPop lexScope(this->Makefile);
cmMakefile::ScopePushPop varScope(this->Makefile);
+ cmMakefile::LexicalPushPop lexScope(this->Makefile);
static_cast<void>(varScope);
// Push a weak policy scope which restores the policies recorded at
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index d191056..87665a0 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -14,14 +14,19 @@
#include "cmMakefile.h"
#include "cmake.h"
-cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
+cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->EmptyRuleHackDepends = "NUL";
this->FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
- this->WindowsShell = true;
+ cm->GetState()->SetWindowsShell(true);
+ this->IncludeDirective = "!include";
+ this->DefineWindowsNULL = true;
+ this->PassMakeflags = true;
+ this->UnixCD = false;
}
@@ -39,15 +44,11 @@ void cmGlobalBorlandMakefileGenerator
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
- cmLocalGenerator* parent)
+ cmLocalGenerator* parent, cmState::Snapshot snapshot)
{
cmLocalUnixMakefileGenerator3* lg =
- new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetIncludeDirective("!include");
- lg->SetDefineWindowsNULL(true);
+ new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
lg->SetMakefileVariableSize(32);
- lg->SetPassMakeflags(true);
- lg->SetUnixCD(false);
lg->SetMakeCommandEscapeTargetTwice(true);
lg->SetBorlandMakeCurlyHack(true);
return lg;
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 4f24d2d..2ec510d 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalBorlandMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalBorlandMakefileGenerator();
+ cmGlobalBorlandMakefileGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalBorlandMakefileGenerator>(); }
@@ -36,7 +36,8 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 1c9c475..cd05c54 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -48,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;
@@ -71,13 +72,6 @@ cmGlobalGenerator::cmGlobalGenerator()
this->ExtraGenerator = 0;
this->CurrentLocalGenerator = 0;
this->TryCompileOuterMakefile = 0;
-
- this->WindowsShell = false;
- this->WindowsVSIDE = false;
- this->WatcomWMake = false;
- this->MinGWMake = false;
- this->NMake = false;
- this->MSYSShell = false;
}
cmGlobalGenerator::~cmGlobalGenerator()
@@ -1099,7 +1093,7 @@ 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
@@ -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 ||
@@ -1882,9 +1884,22 @@ void cmGlobalGenerator::EnableInstallTarget()
}
cmLocalGenerator *
-cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent)
+cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot,
+ cmLocalGenerator *parent)
{
- return new cmLocalGenerator(this, parent);
+ 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,
@@ -2127,17 +2142,10 @@ 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->GetCurrentBinaryDirectory();
@@ -2252,7 +2260,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.");
@@ -2273,7 +2281,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);
@@ -2315,7 +2323,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());
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 3b2a41f..979e971 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -21,10 +21,15 @@
#include "cmExportSetMap.h" // For cmExportSetMap
#include "cmGeneratorTarget.h"
#include "cmGeneratorExpression.h"
+#include "cmState.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include "cmFileLockPool.h"
-# include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+# include <unordered_map>
+# else
+# include <cmsys/hash_map.hxx>
+# endif
#endif
class cmake;
@@ -49,11 +54,12 @@ class cmGlobalGenerator
{
public:
///! Free any memory allocated with the GlobalGenerator
- cmGlobalGenerator();
+ cmGlobalGenerator(cmake* cm);
virtual ~cmGlobalGenerator();
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ cmLocalGenerator* MakeLocalGenerator(
+ cmState::Snapshot snapshot = cmState::Snapshot(),
+ cmLocalGenerator* parent = 0);
///! Get the name for this generator
virtual std::string GetName() const { return "Generic"; }
@@ -118,7 +124,7 @@ public:
* Try running cmake and building a file. This is used for dynamically
* loaded commands, not as part of the usual build process.
*/
- virtual int TryCompile(const std::string& srcdir, const std::string& bindir,
+ int TryCompile(const std::string& srcdir, const std::string& bindir,
const std::string& projectName,
const std::string& targetName,
bool fast, std::string& output, cmMakefile* mf);
@@ -155,9 +161,6 @@ public:
const std::string& native,
bool ignoreErrors);
- ///! Set the CMake instance
- void SetCMakeInstance(cmake *cm);
-
///! Get the CMake instance
cmake *GetCMakeInstance() const { return this->CMakeInstance; }
@@ -354,20 +357,14 @@ public:
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
#endif
- bool WindowsShell;
- bool WindowsVSIDE;
- bool WatcomWMake;
- bool MinGWMake;
- bool NMake;
- bool MSYSShell;
-
+ std::string MakeSilentFlag;
protected:
virtual void Generate();
typedef std::vector<cmLocalGenerator*> GeneratorVector;
// for a project collect all its targets by following depend
// information, and also collect all the targets
- virtual void GetTargetSets(TargetDependSet& projectTargets,
+ void GetTargetSets(TargetDependSet& projectTargets,
TargetDependSet& originalTargets,
cmLocalGenerator* root, GeneratorVector const&);
bool IsRootOnlyTarget(cmTarget* target) const;
@@ -429,7 +426,11 @@ protected:
// All targets in the entire project.
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, cmTarget*> TargetMap;
+#else
typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+#endif
#else
typedef std::map<std::string,cmTarget *> TargetMap;
#endif
@@ -438,10 +439,14 @@ protected:
TargetMap ImportedTargets;
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
- virtual const char* GetPredefinedTargetsFolder();
+ const char* GetPredefinedTargetsFolder();
virtual bool UseFolderProperty();
private:
+ ///! Create a local generator appropriate to this Global Generator
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
+
cmMakefile* TryCompileOuterMakefile;
float FirstTimeProgress;
// If you add a new map here, make sure it is copied
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 3c2cd60..ebba599 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -15,6 +15,7 @@
#include "cmStandardIncludes.h"
+class cmake;
class cmGlobalGenerator;
struct cmDocumentationEntry;
@@ -30,7 +31,7 @@ public:
/** Create a GlobalGenerator */
virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& n) const = 0;
+ const std::string& n, cmake* cm) const = 0;
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
@@ -44,10 +45,10 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const {
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const {
if (name != T::GetActualName()) return 0;
- return new T; }
+ return new T(cm); }
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index d6bf75c..f764418 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -21,8 +21,8 @@
const char *cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
const char *cmGlobalGhsMultiGenerator::DEFAULT_MAKE_PROGRAM = "gbuild";
-cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator()
- : OSDirRelative(false)
+cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
+ : cmGlobalGenerator(cm), OSDirRelative(false)
{
this->GhsBuildCommandInitialized = false;
}
@@ -33,11 +33,10 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
}
cmLocalGenerator *
-cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- cmLocalGenerator *lg = new cmLocalGhsMultiGenerator(this, parent);
- this->SetCurrentLocalGenerator(lg);
- return lg;
+ return new cmLocalGhsMultiGenerator(this, parent, snapshot);
}
void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index 6464f5c..f1a3ed7 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -24,14 +24,15 @@ public:
/// The default name of GHS MULTI's build file. Typically: monolith.gpj.
static const char *FILE_EXTENSION;
- cmGlobalGhsMultiGenerator();
+ cmGlobalGhsMultiGenerator(cmake* cm);
~cmGlobalGhsMultiGenerator();
static cmGlobalGeneratorFactory *NewFactory()
{ return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); }
///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/// @return the name of this generator.
static std::string GetActualName() { return "Green Hills MULTI"; }
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index 25613eb..50e7053 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -13,14 +13,19 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
-cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator()
+cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->FindMakeProgramFile = "CMakeJOMFindMake.cmake";
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
- this->WindowsShell = true;
- this->NMake = true;
+ cm->GetState()->SetWindowsShell(true);
+ cm->GetState()->SetNMake(true);
+ this->DefineWindowsNULL = true;
+ this->PassMakeflags = true;
+ this->UnixCD = false;
+ this->MakeSilentFlag = "/nologo";
}
void cmGlobalJOMMakefileGenerator
@@ -46,20 +51,6 @@ void cmGlobalJOMMakefileGenerator
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalJOMMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalUnixMakefileGenerator3* lg
- = new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetDefineWindowsNULL(true);
- lg->SetMakeSilentFlag("/nologo");
- lg->SetIgnoreLibPrefix(true);
- lg->SetPassMakeflags(true);
- lg->SetUnixCD(false);
- return lg;
-}
-
//----------------------------------------------------------------------------
void cmGlobalJOMMakefileGenerator
::GetDocumentation(cmDocumentationEntry& entry)
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 4831309..2185b23 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalJOMMakefileGenerator();
+ cmGlobalJOMMakefileGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalJOMMakefileGenerator>(); }
@@ -36,9 +36,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx
index b6adcbb..a84923b 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.cxx
+++ b/Source/cmGlobalMSYSMakefileGenerator.cxx
@@ -15,13 +15,14 @@
#include "cmake.h"
#include <cmsys/FStream.hxx>
-cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
+cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
this->ForceUnixPaths = true;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
- this->MSYSShell = true;
+ cm->GetState()->SetMSYSShell(true);
}
std::string
@@ -93,18 +94,6 @@ void cmGlobalMSYSMakefileGenerator
}
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalMSYSMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalUnixMakefileGenerator3* lg =
- new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetIgnoreLibPrefix(true);
- lg->SetPassMakeflags(false);
- lg->SetUnixCD(true);
- return lg;
-}
-
//----------------------------------------------------------------------------
void cmGlobalMSYSMakefileGenerator
::GetDocumentation(cmDocumentationEntry& entry)
diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h
index 1795d86..2cefc97 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.h
+++ b/Source/cmGlobalMSYSMakefileGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalMSYSMakefileGenerator();
+ cmGlobalMSYSMakefileGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalMSYSMakefileGenerator>(); }
@@ -35,9 +35,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx
index 5b92eeb..b6e52d7 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.cxx
+++ b/Source/cmGlobalMinGWMakefileGenerator.cxx
@@ -13,14 +13,15 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
-cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator()
+cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
this->ForceUnixPaths = true;
this->ToolSupportsColor = true;
this->UseLinkScript = true;
- this->WindowsShell = true;
- this->MinGWMake = true;
+ cm->GetState()->SetWindowsShell(true);
+ cm->GetState()->SetMinGWMake(true);
}
void cmGlobalMinGWMakefileGenerator
@@ -58,18 +59,6 @@ void cmGlobalMinGWMakefileGenerator
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalMinGWMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalUnixMakefileGenerator3* lg =
- new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetIgnoreLibPrefix(true);
- lg->SetPassMakeflags(false);
- lg->SetUnixCD(true);
- return lg;
-}
-
//----------------------------------------------------------------------------
void cmGlobalMinGWMakefileGenerator
::GetDocumentation(cmDocumentationEntry& entry)
diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h
index 93f67be..3b00126 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.h
+++ b/Source/cmGlobalMinGWMakefileGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalMinGWMakefileGenerator();
+ cmGlobalMinGWMakefileGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalMinGWMakefileGenerator>(); }
@@ -34,9 +34,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index 98d7fb4..4219c34 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -13,14 +13,19 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
-cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
+cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
- this->WindowsShell = true;
- this->NMake = true;
+ cm->GetState()->SetWindowsShell(true);
+ cm->GetState()->SetNMake(true);
+ this->DefineWindowsNULL = true;
+ this->PassMakeflags = true;
+ this->UnixCD = false;
+ this->MakeSilentFlag = "/nologo";
}
void cmGlobalNMakeMakefileGenerator
@@ -46,20 +51,6 @@ void cmGlobalNMakeMakefileGenerator
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalNMakeMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalUnixMakefileGenerator3* lg =
- new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetDefineWindowsNULL(true);
- lg->SetMakeSilentFlag("/nologo");
- lg->SetIgnoreLibPrefix(true);
- lg->SetPassMakeflags(true);
- lg->SetUnixCD(false);
- return lg;
-}
-
//----------------------------------------------------------------------------
void cmGlobalNMakeMakefileGenerator
::GetDocumentation(cmDocumentationEntry& entry)
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index cb898ba..dd72c49 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalNMakeMakefileGenerator();
+ cmGlobalNMakeMakefileGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalNMakeMakefileGenerator>(); }
@@ -34,9 +34,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 9a952a3..103d75a 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -21,6 +21,7 @@
#include <algorithm>
#include <assert.h>
+#include <ctype.h>
const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
@@ -57,6 +58,28 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
os << "# " << replace.substr(lpos) << "\n\n";
}
+std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
+{
+ // Ninja rule names must match "[a-zA-Z0-9_.-]+". Use ".xx" to encode
+ // "." and all invalid characters as hexadecimal.
+ std::string encoded;
+ for (std::string::const_iterator i = name.begin();
+ i != name.end(); ++i)
+ {
+ if (isalnum(*i) || *i == '_' || *i == '-')
+ {
+ encoded += *i;
+ }
+ else
+ {
+ char buf[16];
+ sprintf(buf, ".%02x", static_cast<unsigned int>(*i));
+ encoded += buf;
+ }
+ }
+ return encoded;
+}
+
static bool IsIdentChar(char c)
{
return
@@ -120,7 +143,8 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
const cmNinjaDeps& orderOnlyDeps,
const cmNinjaVars& variables,
const std::string& rspfile,
- int cmdLineLimit)
+ int cmdLineLimit,
+ bool* usedResponseFile)
{
// Make sure there is a rule.
if(rule.empty())
@@ -205,15 +229,20 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
std::string buildstr = build;
std::string assignments = variable_assignments.str();
const std::string& args = arguments;
+ bool useResponseFile = false;
if (cmdLineLimit > 0
&& args.size() + buildstr.size() + assignments.size()
> (size_t) cmdLineLimit) {
- buildstr += "_RSP_FILE";
variable_assignments.str(std::string());
cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
"RSP_FILE", rspfile, "", 1);
assignments += variable_assignments.str();
+ useResponseFile = true;
}
+ if (usedResponseFile)
+ {
+ *usedResponseFile = useResponseFile;
+ }
os << buildstr << args << assignments;
}
@@ -300,12 +329,10 @@ void
cmGlobalNinjaGenerator::AddMacOSXContentRule()
{
cmLocalGenerator *lg = this->LocalGenerators[0];
- cmMakefile* mfRoot = lg->GetMakefile();
std::ostringstream cmd;
- cmd << lg->ConvertToOutputFormat(
- mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
- cmLocalGenerator::SHELL)
+ cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
+ cmLocalGenerator::SHELL)
<< " -E copy $in $out";
this->AddRule("COPY_OSX_CONTENT",
@@ -477,8 +504,8 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os,
}
-cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
- : cmGlobalGenerator()
+cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
+ : cmGlobalGenerator(cm)
, BuildFileStream(0)
, RulesFileStream(0)
, CompileCommandsStream(0)
@@ -489,7 +516,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, PolicyCMP0058(cmPolicies::WARN)
{
#ifdef _WIN32
- this->WindowsShell = true;
+ cm->GetState()->SetWindowsShell(true);
#endif
// // Ninja is not ported to non-Unix OS yet.
// this->ForceUnixPaths = true;
@@ -501,9 +528,10 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
// Virtual public methods.
cmLocalGenerator*
-cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- return new cmLocalNinjaGenerator(this, parent);
+ return new cmLocalNinjaGenerator(this, parent, snapshot);
}
void cmGlobalNinjaGenerator
@@ -1155,9 +1183,8 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
cmMakefile* mfRoot = lg->GetMakefile();
std::ostringstream cmd;
- cmd << lg->ConvertToOutputFormat(
- mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
- cmLocalGenerator::SHELL)
+ cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
+ cmLocalGenerator::SHELL)
<< " -H"
<< lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(),
cmLocalGenerator::SHELL)
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 00dc237..ffd1cdc 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -61,6 +61,7 @@ public:
/// Write a divider in the given output stream @a os.
static void WriteDivider(std::ostream& os);
+ static std::string EncodeRuleName(std::string const& name);
static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
static std::string EncodeLiteral(const std::string &lit);
std::string EncodePath(const std::string &path);
@@ -87,7 +88,8 @@ public:
const cmNinjaDeps& orderOnlyDeps,
const cmNinjaVars& variables,
const std::string& rspfile = std::string(),
- int cmdLineLimit = -1);
+ int cmdLineLimit = -1,
+ bool* usedResponseFile = 0);
/**
* Helper to write a build statement with the special 'phony' rule.
@@ -158,8 +160,7 @@ public:
bool IsGCCOnWindows() const { return UsingGCCOnWindows; }
public:
- /// Default constructor.
- cmGlobalNinjaGenerator();
+ cmGlobalNinjaGenerator(cmake* cm);
/// Convenience method for creating an instance of this class.
static cmGlobalGeneratorFactory* NewFactory() {
@@ -169,7 +170,8 @@ public:
virtual ~cmGlobalNinjaGenerator() { }
/// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator()
- virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/// Overloaded methods. @see cmGlobalGenerator::GetName().
virtual std::string GetName() const {
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index a4df493..4fe52dd 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -20,7 +20,8 @@
#include "cmGeneratorTarget.h"
#include "cmAlgorithms.h"
-cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
+cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
+ : cmGlobalGenerator(cm)
{
// This type of makefile always requires unix style paths
this->ForceUnixPaths = true;
@@ -33,6 +34,11 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
this->UseLinkScript = true;
#endif
this->CommandDatabase = NULL;
+
+ this->IncludeDirective = "include";
+ this->DefineWindowsNULL = false;
+ this->PassMakeflags = false;
+ this->UnixCD = true;
}
void cmGlobalUnixMakefileGenerator3
@@ -54,9 +60,10 @@ void cmGlobalUnixMakefileGenerator3
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- return new cmLocalUnixMakefileGenerator3(this, parent);
+ return new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
}
//----------------------------------------------------------------------------
@@ -580,7 +587,7 @@ void cmGlobalUnixMakefileGenerator3
else
{
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
- (this->CreateLocalGenerator());
+ (this->MakeLocalGenerator());
// set the Start directories
lg->GetMakefile()->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory());
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 165a3c8..a639ff0 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -54,7 +54,7 @@ class cmLocalUnixMakefileGenerator3;
class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
{
public:
- cmGlobalUnixMakefileGenerator3();
+ cmGlobalUnixMakefileGenerator3(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalUnixMakefileGenerator3>(); }
@@ -68,7 +68,8 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator3
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/**
* Try to determine system information such as shared library
@@ -132,6 +133,11 @@ public:
virtual bool AllowDeleteOnError() const { return true; }
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
+ std::string IncludeDirective;
+ bool DefineWindowsNULL;
+ bool PassMakeflags;
+ bool UnixCD;
protected:
void WriteMainMakefile2();
void WriteMainCMakefile();
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 04bb6ce..4e8ada4 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -42,8 +42,8 @@ class cmGlobalVisualStudio10Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const
{
std::string genName;
const char* p = cmVS10GenName(name, genName);
@@ -51,20 +51,17 @@ public:
{ return 0; }
if(!*p)
{
- return new cmGlobalVisualStudio10Generator(
- genName, "");
+ return new cmGlobalVisualStudio10Generator(cm, genName, "");
}
if(*p++ != ' ')
{ return 0; }
if(strcmp(p, "Win64") == 0)
{
- return new cmGlobalVisualStudio10Generator(
- genName, "x64");
+ return new cmGlobalVisualStudio10Generator(cm, genName, "x64");
}
if(strcmp(p, "IA64") == 0)
{
- return new cmGlobalVisualStudio10Generator(
- genName, "Itanium");
+ return new cmGlobalVisualStudio10Generator(cm, genName, "Itanium");
}
return 0;
}
@@ -93,9 +90,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
+cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio8Generator(name, platformName)
+ : cmGlobalVisualStudio8Generator(cm, name, platformName)
{
std::string vc10Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@@ -105,6 +102,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->SystemIsWindowsPhone = false;
this->SystemIsWindowsStore = false;
this->MSBuildCommandInitialized = false;
+ this->Version = VS10;
}
//----------------------------------------------------------------------------
@@ -309,10 +307,10 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- return new cmLocalVisualStudio10Generator(
- cmLocalVisualStudioGenerator::VS10, this, parent);
+ return new cmLocalVisualStudio10Generator(this, parent, snapshot);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 8cb2588..74d5022 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -24,7 +24,7 @@ class cmGlobalVisualStudio10Generator :
public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio10Generator(const std::string& name,
+ cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
@@ -46,7 +46,8 @@ public:
);
///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 36ae0a4..419bf8a 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -37,8 +37,8 @@ class cmGlobalVisualStudio11Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const
{
std::string genName;
const char* p = cmVS11GenName(name, genName);
@@ -46,20 +46,17 @@ public:
{ return 0; }
if(!*p)
{
- return new cmGlobalVisualStudio11Generator(
- genName, "");
+ return new cmGlobalVisualStudio11Generator(cm, genName, "");
}
if(*p++ != ' ')
{ return 0; }
if(strcmp(p, "Win64") == 0)
{
- return new cmGlobalVisualStudio11Generator(
- genName, "x64");
+ return new cmGlobalVisualStudio11Generator(cm, genName, "x64");
}
if(strcmp(p, "ARM") == 0)
{
- return new cmGlobalVisualStudio11Generator(
- genName, "ARM");
+ return new cmGlobalVisualStudio11Generator(cm, genName, "ARM");
}
std::set<std::string> installedSDKs =
@@ -71,7 +68,7 @@ public:
}
cmGlobalVisualStudio11Generator* ret =
- new cmGlobalVisualStudio11Generator(name, p);
+ new cmGlobalVisualStudio11Generator(cm, name, p);
ret->WindowsCEVersion = "8.00";
return ret;
}
@@ -108,15 +105,16 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
+cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio10Generator(name, platformName)
+ : cmGlobalVisualStudio10Generator(cm, name, platformName)
{
std::string vc11Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
"ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v110";
+ this->Version = VS11;
}
//----------------------------------------------------------------------------
@@ -237,14 +235,6 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
}
//----------------------------------------------------------------------------
-cmLocalGenerator *
-cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- return new cmLocalVisualStudio10Generator(
- cmLocalVisualStudioGenerator::VS11, this, parent);
-}
-
-//----------------------------------------------------------------------------
bool cmGlobalVisualStudio11Generator::UseFolderProperty()
{
// Intentionally skip over the parent class implementation and call the
diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h
index ae4b888..b50f4c9 100644
--- a/Source/cmGlobalVisualStudio11Generator.h
+++ b/Source/cmGlobalVisualStudio11Generator.h
@@ -20,7 +20,7 @@ class cmGlobalVisualStudio11Generator:
public cmGlobalVisualStudio10Generator
{
public:
- cmGlobalVisualStudio11Generator(const std::string& name,
+ cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
@@ -28,9 +28,6 @@ public:
virtual void WriteSLNHeader(std::ostream& fout);
- ///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 17b2fc7..efa1133 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -37,8 +37,8 @@ class cmGlobalVisualStudio12Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const
{
std::string genName;
const char* p = cmVS12GenName(name, genName);
@@ -46,20 +46,17 @@ public:
{ return 0; }
if(!*p)
{
- return new cmGlobalVisualStudio12Generator(
- genName, "");
+ return new cmGlobalVisualStudio12Generator(cm, genName, "");
}
if(*p++ != ' ')
{ return 0; }
if(strcmp(p, "Win64") == 0)
{
- return new cmGlobalVisualStudio12Generator(
- genName, "x64");
+ return new cmGlobalVisualStudio12Generator(cm, genName, "x64");
}
if(strcmp(p, "ARM") == 0)
{
- return new cmGlobalVisualStudio12Generator(
- genName, "ARM");
+ return new cmGlobalVisualStudio12Generator(cm, genName, "ARM");
}
return 0;
}
@@ -88,15 +85,16 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
+cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio11Generator(name, platformName)
+ : cmGlobalVisualStudio11Generator(cm, name, platformName)
{
std::string vc12Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;"
"ProductDir", vc12Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v120";
+ this->Version = VS12;
}
//----------------------------------------------------------------------------
@@ -217,14 +215,6 @@ void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
}
//----------------------------------------------------------------------------
-cmLocalGenerator *
-cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- return new cmLocalVisualStudio10Generator(
- cmLocalVisualStudioGenerator::VS12, this, parent);
-}
-
-//----------------------------------------------------------------------------
bool
cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const
{
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index d304bc1..bce9e0c 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -20,7 +20,7 @@ class cmGlobalVisualStudio12Generator:
public cmGlobalVisualStudio11Generator
{
public:
- cmGlobalVisualStudio12Generator(const std::string& name,
+ cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
@@ -28,9 +28,6 @@ public:
virtual void WriteSLNHeader(std::ostream& fout);
- ///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
//in Visual Studio 2013 they detached the MSBuild tools version
//from the .Net Framework version and instead made it have it's own
//version number
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 90fcc7e..2cf55d4 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -37,8 +37,8 @@ class cmGlobalVisualStudio14Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const
{
std::string genName;
const char* p = cmVS14GenName(name, genName);
@@ -46,20 +46,17 @@ public:
{ return 0; }
if(!*p)
{
- return new cmGlobalVisualStudio14Generator(
- genName, "");
+ return new cmGlobalVisualStudio14Generator(cm, genName, "");
}
if(*p++ != ' ')
{ return 0; }
if(strcmp(p, "Win64") == 0)
{
- return new cmGlobalVisualStudio14Generator(
- genName, "x64");
+ return new cmGlobalVisualStudio14Generator(cm, genName, "x64");
}
if(strcmp(p, "ARM") == 0)
{
- return new cmGlobalVisualStudio14Generator(
- genName, "ARM");
+ return new cmGlobalVisualStudio14Generator(cm, genName, "ARM");
}
return 0;
}
@@ -88,15 +85,16 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
+cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio12Generator(name, platformName)
+ : cmGlobalVisualStudio12Generator(cm, name, platformName)
{
std::string vc14Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
"ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v140";
+ this->Version = VS14;
}
//----------------------------------------------------------------------------
@@ -126,11 +124,3 @@ void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
fout << "# Visual Studio 14\n";
}
}
-
-//----------------------------------------------------------------------------
-cmLocalGenerator *
-cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- return new cmLocalVisualStudio10Generator(
- cmLocalVisualStudioGenerator::VS14, this, parent);
-}
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 59f1e60..aa817be 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -20,7 +20,7 @@ class cmGlobalVisualStudio14Generator:
public cmGlobalVisualStudio12Generator
{
public:
- cmGlobalVisualStudio14Generator(const std::string& name,
+ cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
@@ -28,9 +28,6 @@ public:
virtual void WriteSLNHeader(std::ostream& fout);
- ///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
virtual const char* GetToolsVersion() { return "14.0"; }
protected:
virtual const char* GetIDEVersion() { return "14.0"; }
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 570314e..632141a 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -31,9 +31,11 @@ std::string GetVS6TargetName(const std::string& targetName)
return name;
}
-cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
+cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator(cmake* cm)
+ : cmGlobalVisualStudioGenerator(cm)
{
this->MSDevCommandInitialized = false;
+ this->Version = VS6;
}
void cmGlobalVisualStudio6Generator
@@ -171,9 +173,10 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- return new cmLocalVisualStudio6Generator(this, parent);
+ return new cmLocalVisualStudio6Generator(this, parent, snapshot);
}
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index d748a85..2460158 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -25,7 +25,7 @@ class cmTarget;
class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator
{
public:
- cmGlobalVisualStudio6Generator();
+ cmGlobalVisualStudio6Generator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalVisualStudio6Generator>(); }
@@ -39,7 +39,8 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 308e858..1ab4c9c 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -16,23 +16,12 @@
#include "cmake.h"
//----------------------------------------------------------------------------
-cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
+cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(cmake* cm,
const std::string& platformName)
- : cmGlobalVisualStudio7Generator(platformName)
+ : cmGlobalVisualStudio7Generator(cm, platformName)
{
this->ProjectConfigurationSectionName = "ProjectConfiguration";
-}
-
-//----------------------------------------------------------------------------
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio71Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalVisualStudio7Generator *lg =
- new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71,
- this, parent);
- lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
- return lg;
+ this->Version = VS71;
}
//----------------------------------------------------------------------------
@@ -94,6 +83,9 @@ void cmGlobalVisualStudio71Generator
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
+ std::vector<std::string> configs;
+ root->GetMakefile()->GetConfigurations(configs);
+
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
@@ -115,11 +107,11 @@ void cmGlobalVisualStudio71Generator
// Write out the configurations information for the solution
fout << "Global\n";
// Write out the configurations for the solution
- this->WriteSolutionConfigurations(fout);
+ this->WriteSolutionConfigurations(fout, configs);
fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName
<< ") = postSolution\n";
// Write out the configurations for all the targets in the project
- this->WriteTargetConfigurations(fout, orderedProjectTargets);
+ this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n";
if (useFolderProperty)
@@ -140,11 +132,12 @@ void cmGlobalVisualStudio71Generator
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio71Generator
-::WriteSolutionConfigurations(std::ostream& fout)
+::WriteSolutionConfigurations(std::ostream& fout,
+ std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\t" << *i << " = " << *i << "\n";
}
@@ -280,14 +273,15 @@ void cmGlobalVisualStudio71Generator
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
std::string const& platformMapping)
{
const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << platformName << std::endl;
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index ad6c153..fbb9ecc 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -23,7 +23,8 @@
class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
{
public:
- cmGlobalVisualStudio71Generator(const std::string& platformName = "");
+ cmGlobalVisualStudio71Generator(cmake* cm,
+ const std::string& platformName = "");
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalVisualStudio71Generator>(); }
@@ -36,9 +37,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Where does this version of Visual Studio look for macros for the
* current user? Returns the empty string if this version of Visual
@@ -57,7 +55,8 @@ protected:
virtual void WriteSLNFile(std::ostream& fout,
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
- virtual void WriteSolutionConfigurations(std::ostream& fout);
+ virtual void WriteSolutionConfigurations(
+ std::ostream& fout, std::vector<std::string> const& configs);
virtual void WriteProject(std::ostream& fout,
const std::string& name, const char* path,
cmTarget const& t);
@@ -66,6 +65,7 @@ protected:
cmTarget const& t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = "");
virtual void WriteExternalProject(std::ostream& fout,
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index a2faddd..4dd54d0 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -18,8 +18,35 @@
#include "cmake.h"
#include <cmsys/Encoding.hxx>
-cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
+//----------------------------------------------------------------------------
+static cmVS7FlagTable cmVS7ExtraFlagTable[] =
+{
+ // Precompiled header and related options. Note that the
+ // UsePrecompiledHeader entries are marked as "Continue" so that the
+ // corresponding PrecompiledHeaderThrough entry can be found.
+ {"UsePrecompiledHeader", "YX", "Automatically Generate", "2",
+ cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
+ {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
+ cmVS7FlagTable::UserValueRequired},
+ {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
+ cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
+ {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
+ cmVS7FlagTable::UserValueRequired},
+ {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0},
+
+ // Exception handling mode. If no entries match, it will be FALSE.
+ {"ExceptionHandling", "GX", "enable c++ exceptions", "true", 0},
+ {"ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0},
+ // The EHa option does not have an IDE setting. Let it go to false,
+ // and have EHa passed on the command line by leaving out the table
+ // entry.
+
+ {0,0,0,0,0}
+};
+
+cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(cmake *cm,
const std::string& platformName)
+ : cmGlobalVisualStudioGenerator(cm)
{
this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
@@ -33,6 +60,8 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
{
this->DefaultPlatformName = platformName;
}
+ this->ExtraFlagTable = cmVS7ExtraFlagTable;
+ this->Version = VS7;
}
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
@@ -94,7 +123,6 @@ void cmGlobalVisualStudio7Generator
// Create list of configurations requested by user's cache, if any.
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
- this->GenerateConfigurations(mf);
// if this environment variable is set, then copy it to
// a static cache entry. It will be used by
@@ -251,12 +279,11 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
cmLocalVisualStudio7Generator *lg =
- new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7,
- this, parent);
- lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
+ new cmLocalVisualStudio7Generator(this, parent, snapshot);
return lg;
}
@@ -295,50 +322,6 @@ bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p,
return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf);
}
-void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
-{
- // process the configurations
- const char* ct
- = this->CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES");
- if ( ct )
- {
- std::vector<std::string> argsOut;
- cmSystemTools::ExpandListArgument(ct, argsOut);
- for(std::vector<std::string>::iterator i = argsOut.begin();
- i != argsOut.end(); ++i)
- {
- if(std::find(this->Configurations.begin(),
- this->Configurations.end(),
- *i) == this->Configurations.end())
- {
- this->Configurations.push_back(*i);
- }
- }
- }
- // default to at least Debug and Release
- if(this->Configurations.size() == 0)
- {
- this->Configurations.push_back("Debug");
- this->Configurations.push_back("Release");
- }
-
- // Reset the entry to have a semi-colon separated list.
- std::string configs = this->Configurations[0];
- for(unsigned int i=1; i < this->Configurations.size(); ++i)
- {
- configs += ";";
- configs += this->Configurations[i];
- }
-
- mf->AddCacheDefinition(
- "CMAKE_CONFIGURATION_TYPES",
- configs.c_str(),
- "Semicolon separated list of supported configuration types, "
- "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
- "anything else will be ignored.",
- cmState::STRING);
-}
-
void cmGlobalVisualStudio7Generator::Generate()
{
// first do the superclass method
@@ -410,6 +393,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile()
void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::ostream& fout,
+ std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets)
{
// loop over again and write out configurations for each target
@@ -425,23 +409,22 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
if(expath)
{
- std::set<std::string> allConfigurations(this->Configurations.begin(),
- this->Configurations.end());
+ std::set<std::string> allConfigurations(configs.begin(), configs.end());
const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
this->WriteProjectConfigurations(
fout, target->GetName().c_str(), target->GetType(),
- allConfigurations, mapping ? mapping : "");
+ configs, allConfigurations, mapping ? mapping : "");
}
else
{
const std::set<std::string>& configsPartOfDefaultBuild =
- this->IsPartOfDefaultBuild(projectTargets, target);
+ this->IsPartOfDefaultBuild(configs, projectTargets, target);
const char *vcprojName =
target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName)
{
this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
- configsPartOfDefaultBuild);
+ configs, configsPartOfDefaultBuild);
}
}
}
@@ -576,6 +559,9 @@ void cmGlobalVisualStudio7Generator
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
+ std::vector<std::string> configs;
+ root->GetMakefile()->GetConfigurations(configs);
+
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
@@ -599,8 +585,8 @@ void cmGlobalVisualStudio7Generator
<< "\tGlobalSection(SolutionConfiguration) = preSolution\n";
int c = 0;
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\tConfigName." << c << " = " << *i << "\n";
c++;
@@ -621,7 +607,7 @@ void cmGlobalVisualStudio7Generator
// Write out the configurations for all the targets in the project
fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
- this->WriteTargetConfigurations(fout, orderedProjectTargets);
+ this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n";
// Write out global sections
@@ -777,14 +763,15 @@ cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping)
{
const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << platformName << "\n";
@@ -902,6 +889,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
{
+ std::vector<std::string> configs;
+ target->GetMakefile()->GetConfigurations(configs);
std::string pname = target->GetName();
pname += "_UTILITY";
std::string fname = target->GetMakefile()->GetCurrentBinaryDirectory();
@@ -925,8 +914,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
"\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
"\t<Configurations>\n"
;
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout <<
"\t\t<Configuration\n"
@@ -991,11 +980,6 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
cmState::INTERNAL);
}
-std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
-{
- return &this->Configurations;
-};
-
//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator
::GetDocumentation(cmDocumentationEntry& entry)
@@ -1022,6 +1006,7 @@ cmGlobalVisualStudio7Generator
std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
+ std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets, cmTarget const* target)
{
std::set<std::string> activeConfigs;
@@ -1034,8 +1019,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
if(target->GetName() == "INSTALL")
{
// inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
const char* propertyValue = target->GetMakefile()
->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
@@ -1055,8 +1040,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
return activeConfigs;
}
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
const char* propertyValue =
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
@@ -1086,36 +1071,6 @@ cmGlobalVisualStudio7Generator
return false;
}
-//----------------------------------------------------------------------------
-static cmVS7FlagTable cmVS7ExtraFlagTable[] =
-{
- // Precompiled header and related options. Note that the
- // UsePrecompiledHeader entries are marked as "Continue" so that the
- // corresponding PrecompiledHeaderThrough entry can be found.
- {"UsePrecompiledHeader", "YX", "Automatically Generate", "2",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
- {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired},
- {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
- {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired},
- {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0},
-
- // Exception handling mode. If no entries match, it will be FALSE.
- {"ExceptionHandling", "GX", "enable c++ exceptions", "true", 0},
- {"ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0},
- // The EHa option does not have an IDE setting. Let it go to false,
- // and have EHa passed on the command line by leaving out the table
- // entry.
-
- {0,0,0,0,0}
-};
-cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7()
-{
- return cmVS7ExtraFlagTable;
-}
-
std::string cmGlobalVisualStudio7Generator::Encoding()
{
std::ostringstream encoding;
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 92c5f1a..c98d269 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -26,7 +26,8 @@ struct cmIDEFlagTable;
class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
{
public:
- cmGlobalVisualStudio7Generator(const std::string& platformName = "");
+ cmGlobalVisualStudio7Generator(cmake* cm,
+ const std::string& platformName = "");
~cmGlobalVisualStudio7Generator();
static cmGlobalGeneratorFactory* NewFactory() {
@@ -42,7 +43,8 @@ public:
std::string const& GetPlatformName() const;
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
@@ -78,11 +80,6 @@ public:
*/
virtual void OutputSLNFile();
- /**
- * Get the list of configurations
- */
- std::vector<std::string> *GetConfigurations();
-
///! Create a GUID or get an existing one.
void CreateGUID(const std::string& name);
std::string GetGUID(const std::string& name);
@@ -111,6 +108,8 @@ public:
// Encoding for Visual Studio files
virtual std::string Encoding();
+ cmIDEFlagTable const* ExtraFlagTable;
+
protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "7.0"; }
@@ -120,7 +119,6 @@ protected:
static const char* ExternalProjectType(const char* location);
- static cmIDEFlagTable const* GetExtraFlagTableVS7();
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
@@ -133,6 +131,7 @@ protected:
cmTarget const&t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = "");
virtual void WriteSLNGlobalSections(std::ostream& fout,
@@ -150,10 +149,9 @@ protected:
OrderedTargetDependSet const& projectTargets);
virtual void WriteTargetConfigurations(
std::ostream& fout,
+ std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets);
- void GenerateConfigurations(cmMakefile* mf);
-
virtual void WriteExternalProject(std::ostream& fout,
const std::string& name,
const char* path,
@@ -164,11 +162,11 @@ protected:
std::string ConvertToSolutionPath(const char* path);
std::set<std::string>
- IsPartOfDefaultBuild(OrderedTargetDependSet const& projectTargets,
+ IsPartOfDefaultBuild(std::vector<std::string> const& configs,
+ OrderedTargetDependSet const& projectTargets,
cmTarget const* target);
bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
cmTarget const* target);
- std::vector<std::string> Configurations;
std::map<std::string, std::string> GUIDMap;
virtual void WriteFolders(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index ff9ff10..a3ebc61 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -24,8 +24,8 @@ class cmGlobalVisualStudio8Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const {
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const {
if(strncmp(name.c_str(), vs8generatorName,
sizeof(vs8generatorName) - 1) != 0)
{
@@ -35,8 +35,7 @@ public:
const char* p = name.c_str() + sizeof(vs8generatorName) - 1;
if(p[0] == '\0')
{
- return new cmGlobalVisualStudio8Generator(
- name, "");
+ return new cmGlobalVisualStudio8Generator(cm, name, "");
}
if(p[0] != ' ')
@@ -48,8 +47,7 @@ public:
if(!strcmp(p, "Win64"))
{
- return new cmGlobalVisualStudio8Generator(
- name, "x64");
+ return new cmGlobalVisualStudio8Generator(cm, name, "x64");
}
cmVisualStudioWCEPlatformParser parser(p);
@@ -59,8 +57,8 @@ public:
return 0;
}
- cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator(
- name, p);
+ cmGlobalVisualStudio8Generator* ret =
+ new cmGlobalVisualStudio8Generator(cm, name, p);
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
@@ -95,12 +93,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
+cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio71Generator(platformName)
+ : cmGlobalVisualStudio71Generator(cm, platformName)
{
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->Name = name;
+ this->ExtraFlagTable = this->GetExtraFlagTableVS8();
+ this->Version = VS8;
}
//----------------------------------------------------------------------------
@@ -124,18 +124,6 @@ std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand()
}
//----------------------------------------------------------------------------
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio8Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalVisualStudio7Generator *lg =
- new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8,
- this, parent);
- lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
- return lg;
-}
-
-//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator
::EnableLanguage(std::vector<std::string>const & lang,
cmMakefile *mf, bool optional)
@@ -262,7 +250,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
return false;
}
- std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLines noCommandLines;
cmTarget* tgt =
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
@@ -320,9 +307,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Create a rule to re-run CMake.
std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
stampName += "generate.stamp";
- const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
- commandLine.push_back(dsprule);
+ commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string argH = "-H";
argH += lg->Convert(mf->GetHomeDirectory(),
cmLocalGenerator::START_OUTPUT,
@@ -387,11 +373,12 @@ void cmGlobalVisualStudio8Generator::Generate()
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio8Generator
-::WriteSolutionConfigurations(std::ostream& fout)
+::WriteSolutionConfigurations(std::ostream& fout,
+ std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\t" << *i << "|" << this->GetPlatformName()
<< " = " << *i << "|" << this->GetPlatformName() << "\n";
@@ -404,12 +391,13 @@ void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
std::string const& platformMapping)
{
std::string guid = this->GetGUID(name);
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index ee5ba9f..cc02b78 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -23,7 +23,7 @@
class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
{
public:
- cmGlobalVisualStudio8Generator(const std::string& name,
+ cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
@@ -33,9 +33,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional);
virtual void AddPlatformDefinitions(cmMakefile* mf);
@@ -84,9 +81,11 @@ protected:
static cmIDEFlagTable const* GetExtraFlagTableVS8();
virtual void WriteSLNHeader(std::ostream& fout);
- virtual void WriteSolutionConfigurations(std::ostream& fout);
+ virtual void WriteSolutionConfigurations(
+ std::ostream& fout, std::vector<std::string> const& configs);
virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = "");
virtual bool ComputeTargetDepends();
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 8adde23..d98793a 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -22,8 +22,8 @@ class cmGlobalVisualStudio9Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const {
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const {
if(strncmp(name.c_str(), vs9generatorName,
sizeof(vs9generatorName) - 1) != 0)
{
@@ -33,8 +33,7 @@ public:
const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
if(p[0] == '\0')
{
- return new cmGlobalVisualStudio9Generator(
- name, "");
+ return new cmGlobalVisualStudio9Generator(cm, name, "");
}
if(p[0] != ' ')
@@ -46,14 +45,12 @@ public:
if(!strcmp(p, "IA64"))
{
- return new cmGlobalVisualStudio9Generator(
- name, "Itanium");
+ return new cmGlobalVisualStudio9Generator(cm, name, "Itanium");
}
if(!strcmp(p, "Win64"))
{
- return new cmGlobalVisualStudio9Generator(
- name, "x64");
+ return new cmGlobalVisualStudio9Generator(cm, name, "x64");
}
cmVisualStudioWCEPlatformParser parser(p);
@@ -63,8 +60,8 @@ public:
return 0;
}
- cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
- name, p);
+ cmGlobalVisualStudio9Generator* ret =
+ new cmGlobalVisualStudio9Generator(cm, name, p);
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
@@ -100,10 +97,11 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
}
//----------------------------------------------------------------------------
-cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
+cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(cmake* cm,
const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio8Generator(name, platformName)
+ : cmGlobalVisualStudio8Generator(cm, name, platformName)
{
+ this->Version = VS9;
}
//----------------------------------------------------------------------------
@@ -113,17 +111,6 @@ void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
fout << "# Visual Studio 2008\n";
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalVisualStudio7Generator *lg
- = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9,
- this, parent);
- lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
- return lg;
-}
-
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
{
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index 97b7804..e25a4be 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -24,13 +24,10 @@ class cmGlobalVisualStudio9Generator :
public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio9Generator(const std::string& name,
+ cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
- ///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b74ba6f..585d19a 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -21,10 +21,11 @@
#include <cmsys/Encoding.hxx>
//----------------------------------------------------------------------------
-cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
+cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm)
+ : cmGlobalGenerator(cm)
{
- this->WindowsShell = true;
- this->WindowsVSIDE = true;
+ cm->GetState()->SetWindowsShell(true);
+ cm->GetState()->SetWindowsVSIDE(true);
}
//----------------------------------------------------------------------------
@@ -33,6 +34,19 @@ cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
}
//----------------------------------------------------------------------------
+cmGlobalVisualStudioGenerator::VSVersion
+cmGlobalVisualStudioGenerator::GetVersion() const
+{
+ return this->Version;
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
+{
+ this->Version = v;
+}
+
+//----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
{
return cmGlobalVisualStudioGenerator::GetRegistryBase(
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index cb54132..69b4564 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -23,9 +23,27 @@
class cmGlobalVisualStudioGenerator : public cmGlobalGenerator
{
public:
- cmGlobalVisualStudioGenerator();
+ /** Known versions of Visual Studio. */
+ enum VSVersion
+ {
+ VS6 = 60,
+ VS7 = 70,
+ VS71 = 71,
+ VS8 = 80,
+ VS9 = 90,
+ VS10 = 100,
+ VS11 = 110,
+ VS12 = 120,
+ /* VS13 = 130 was skipped */
+ VS14 = 140
+ };
+
+ cmGlobalVisualStudioGenerator(cmake* cm);
virtual ~cmGlobalVisualStudioGenerator();
+ VSVersion GetVersion() const;
+ void SetVersion(VSVersion v);
+
/**
* Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory.
@@ -107,6 +125,9 @@ protected:
typedef std::map<cmTarget const*, std::string> UtilityDependsMap;
UtilityDependsMap UtilityDepends;
+protected:
+ VSVersion Version;
+
private:
virtual std::string GetVSMakeProgram() = 0;
void PrintCompilerAdvice(std::ostream&, std::string const&,
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 181178f..153773f 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -13,7 +13,8 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
-cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
+cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm)
+ : cmGlobalUnixMakefileGenerator3(cm)
{
this->FindMakeProgramFile = "CMakeFindWMake.cmake";
#ifdef _WIN32
@@ -23,9 +24,13 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
this->NeedSymbolicMark = true;
this->EmptyRuleHackCommand = "@cd .";
#ifdef _WIN32
- this->WindowsShell = true;
+ cm->GetState()->SetWindowsShell(true);
#endif
- this->WatcomWMake = true;
+ cm->GetState()->SetWatcomWMake(true);
+ this->IncludeDirective = "!include";
+ this->DefineWindowsNULL = true;
+ this->UnixCD = false;
+ this->MakeSilentFlag = "-h";
}
void cmGlobalWatcomWMakeGenerator
@@ -44,21 +49,6 @@ void cmGlobalWatcomWMakeGenerator
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalWatcomWMakeGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
-{
- cmLocalUnixMakefileGenerator3* lg
- = new cmLocalUnixMakefileGenerator3(this, parent);
- lg->SetDefineWindowsNULL(true);
- lg->SetMakeSilentFlag("-h");
- lg->SetIgnoreLibPrefix(true);
- lg->SetPassMakeflags(false);
- lg->SetUnixCD(false);
- lg->SetIncludeDirective("!include");
- return lg;
-}
-
//----------------------------------------------------------------------------
void cmGlobalWatcomWMakeGenerator
::GetDocumentation(cmDocumentationEntry& entry)
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index 3af2f9d..4bfcf06 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -22,7 +22,7 @@
class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
- cmGlobalWatcomWMakeGenerator();
+ cmGlobalWatcomWMakeGenerator(cmake* cm);
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalWatcomWMakeGenerator>(); }
@@ -34,9 +34,6 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
-
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 4a7411c..7464e90 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -117,8 +117,8 @@ public:
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(
- const std::string& name) const;
+ virtual cmGlobalGenerator*
+ CreateGlobalGenerator(const std::string& name, cmake* cm) const;
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
cmGlobalXCodeGenerator::GetDocumentation(entry); }
@@ -128,7 +128,9 @@ public:
};
//----------------------------------------------------------------------------
-cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
+cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm,
+ std::string const& version)
+ : cmGlobalGenerator(cm)
{
this->VersionString = version;
@@ -154,7 +156,7 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
-::CreateGlobalGenerator(const std::string& name) const
+::CreateGlobalGenerator(const std::string& name, cmake* cm) const
{
if (name != GetActualName())
return 0;
@@ -187,7 +189,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
("/Developer/Applications/Xcode.app/Contents/version.plist");
}
cmsys::auto_ptr<cmGlobalXCodeGenerator>
- gg(new cmGlobalXCodeGenerator(parser.Version));
+ gg(new cmGlobalXCodeGenerator(cm, parser.Version));
if (gg->XcodeVersion == 20)
{
cmSystemTools::Message("Xcode 2.0 not really supported by cmake, "
@@ -198,7 +200,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
#else
std::cerr << "CMake should be built with cmake to use Xcode, "
"default to Xcode 1.5\n";
- return new cmGlobalXCodeGenerator;
+ return new cmGlobalXCodeGenerator(cm);
#endif
}
@@ -369,9 +371,10 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
//----------------------------------------------------------------------------
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
+cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
{
- return new cmLocalXCodeGenerator(this, parent);
+ return new cmLocalXCodeGenerator(this, parent, snapshot);
}
//----------------------------------------------------------------------------
@@ -582,8 +585,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
{
makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
}
- std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND");
- makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str())
+ makefileStream << "\n\t" <<
+ this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
<< " -H" << this->ConvertToRelativeForMake(
mf->GetHomeDirectory())
<< " -B" << this->ConvertToRelativeForMake(
@@ -1447,7 +1450,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
{
cmCustomCommandLines cmd;
cmd.resize(1);
- cmd[0].push_back(this->CurrentMakefile->GetDefinition("CMAKE_COMMAND"));
+ cmd[0].push_back(cmSystemTools::GetCMakeCommand());
cmd[0].push_back("-E");
cmd[0].push_back("cmake_symlink_library");
std::string str_file = "$<TARGET_FILE:";
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 6c911a4..c36e4af 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -29,7 +29,7 @@ class cmSourceGroup;
class cmGlobalXCodeGenerator : public cmGlobalGenerator
{
public:
- cmGlobalXCodeGenerator(std::string const& version);
+ cmGlobalXCodeGenerator(cmake* cm, std::string const& version);
static cmGlobalGeneratorFactory* NewFactory();
///! Get the name for the generator.
@@ -41,7 +41,8 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 99542a9..7f4c4c9 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -65,9 +65,10 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
const char* fallbackSettingsFileName)
{
cmake cm;
- cmGlobalGenerator ggi;
- ggi.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator());
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cmGlobalGenerator ggi(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(ggi.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile();
const char* inFileName = settingsFileName;
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index ddcea9b..2756cd2 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -400,6 +400,11 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
}
}
+void cmListFileBacktrace::Append(cmListFileContext const& context)
+{
+ this->push_back(context);
+}
+
//----------------------------------------------------------------------------
void cmListFileBacktrace::MakeRelative()
{
@@ -416,6 +421,31 @@ void cmListFileBacktrace::MakeRelative()
this->Relative = true;
}
+void cmListFileBacktrace::PrintTitle(std::ostream& out)
+{
+ if (this->empty())
+ {
+ return;
+ }
+ out << (this->front().Line ? " at " : " in ") << this->front();
+}
+
+void cmListFileBacktrace::PrintCallStack(std::ostream& out)
+{
+ if (size() <= 1)
+ {
+ return;
+ }
+
+ const_iterator i = this->begin() + 1;
+ out << "Call Stack (most recent call first):\n";
+ while(i != this->end())
+ {
+ cmListFileContext const& lfc = *i;
+ out << " " << lfc << "\n";
+ ++i;
+ }
+}
//----------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
@@ -431,3 +461,22 @@ std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
}
return os;
}
+
+bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs)
+{
+ if(lhs.Line != rhs.Line)
+ {
+ return lhs.Line < rhs.Line;
+ }
+ return lhs.FilePath < rhs.FilePath;
+}
+
+bool operator==(const cmListFileContext& lhs, const cmListFileContext& rhs)
+{
+ return lhs.Line == rhs.Line && lhs.FilePath == rhs.FilePath;
+}
+
+bool operator!=(const cmListFileContext& lhs, const cmListFileContext& rhs)
+{
+ return !(lhs == rhs);
+}
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 544ff1b..4a1d181 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -62,13 +62,16 @@ struct cmListFileContext
};
std::ostream& operator<<(std::ostream&, cmListFileContext const&);
+bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
+bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
+bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
struct cmListFileFunction: public cmListFileContext
{
std::vector<cmListFileArgument> Arguments;
};
-class cmListFileBacktrace: public std::vector<cmListFileContext>
+class cmListFileBacktrace: private std::vector<cmListFileContext>
{
public:
cmListFileBacktrace(cmLocalGenerator* localGen)
@@ -77,7 +80,12 @@ class cmListFileBacktrace: public std::vector<cmListFileContext>
{
}
+ void Append(cmListFileContext const& context);
+
void MakeRelative();
+
+ void PrintTitle(std::ostream& out);
+ void PrintCallStack(std::ostream& out);
private:
cmLocalGenerator* LocalGenerator;
bool Relative;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 74362ae..eb6b871 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -44,30 +44,24 @@
#endif
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent)
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : StateSnapshot(snapshot)
{
+ assert(snapshot.IsValid());
this->GlobalGenerator = gg;
this->Parent = parent;
if (parent)
{
parent->AddChild(this);
- this->StateSnapshot =
- this->GetState()->CreateSnapshot(parent->StateSnapshot);
- }
- else
- {
- this->StateSnapshot =
- this->GetState()->CreateSnapshot(cmState::Snapshot(this->GetState()));
}
+
this->Makefile = new cmMakefile(this);
this->LinkScriptShell = false;
- this->IgnoreLibPrefix = false;
this->UseRelativePaths = false;
this->Configured = false;
this->EmitUniversalBinaryFlags = true;
- this->RelativePathsConfigured = false;
- this->PathConversionsSetup = false;
this->BackwardsCompatibility = 0;
this->BackwardsCompatibilityFinal = false;
}
@@ -79,7 +73,7 @@ cmLocalGenerator::~cmLocalGenerator()
bool cmLocalGenerator::IsRootMakefile() const
{
- return !this->GetParent();
+ return !this->StateSnapshot.GetParent().IsValid();
}
//----------------------------------------------------------------------------
@@ -87,11 +81,14 @@ class cmLocalGeneratorCurrent
{
cmGlobalGenerator* GG;
cmLocalGenerator* LG;
+ cmState::Snapshot Snapshot;
public:
cmLocalGeneratorCurrent(cmLocalGenerator* lg)
{
this->GG = lg->GetGlobalGenerator();
this->LG = this->GG->GetCurrentLocalGenerator();
+ this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
+ this->GG->GetCMakeInstance()->SetCurrentSnapshot(lg->GetStateSnapshot());
this->GG->SetCurrentLocalGenerator(lg);
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PushFileScope();
@@ -103,6 +100,7 @@ public:
this->GG->GetFileLockPool().PopFileScope();
#endif
this->GG->SetCurrentLocalGenerator(this->LG);
+ this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
}
};
@@ -118,8 +116,10 @@ void cmLocalGenerator::Configure()
filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str());
- // find & read the list file
- this->ReadInputFile();
+ std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
+ currentStart += "/CMakeLists.txt";
+ assert(cmSystemTools::FileExists(currentStart.c_str(), true));
+ this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
// at the end of the ReadListFile handle any old style subdirs
// first get all the subdirectories
@@ -186,39 +186,6 @@ void cmLocalGenerator::ComputeObjectMaxPath()
this->ObjectMaxPathViolations.clear();
}
-//----------------------------------------------------------------------------
-void cmLocalGenerator::ReadInputFile()
-{
- // Look for the CMakeLists.txt file.
- std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
- currentStart += "/CMakeLists.txt";
- assert(cmSystemTools::FileExists(currentStart.c_str(), true));
- this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
-}
-
-void cmLocalGenerator::SetupPathConversions()
-{
- // Setup the current output directory components for use by
- // Convert
- std::string outdir;
- outdir =
- cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory());
- cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
- outdir = cmSystemTools::CollapseFullPath(
- this->StateSnapshot.GetCurrentSourceDirectory());
- cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
-
- outdir = cmSystemTools::CollapseFullPath
- (this->GetState()->GetBinaryDirectory());
- cmSystemTools::SplitPath(outdir,
- this->HomeOutputDirectoryComponents);
-
- outdir = cmSystemTools::CollapseFullPath
- (this->StateSnapshot.GetCurrentBinaryDirectory());
- cmSystemTools::SplitPath(outdir,
- this->StartOutputDirectoryComponents);
-}
-
void cmLocalGenerator::ConfigureFinalPass()
{
this->Makefile->ConfigureFinalPass();
@@ -390,12 +357,8 @@ void cmLocalGenerator::GenerateInstallRules()
// Create the install script file.
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
std::string homedir = this->GetState()->GetBinaryDirectory();
- std::string currdir = this->StateSnapshot.GetCurrentBinaryDirectory();
- cmSystemTools::ConvertToUnixSlashes(file);
- cmSystemTools::ConvertToUnixSlashes(homedir);
- cmSystemTools::ConvertToUnixSlashes(currdir);
int toplevel_install = 0;
- if ( currdir == homedir )
+ if (file == homedir)
{
toplevel_install = 1;
}
@@ -1031,12 +994,10 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
}
if(variable == "CMAKE_COMMAND")
{
- const char* cmcommand =
- this->GetMakefile()->GetDefinition("CMAKE_COMMAND");
- return this->Convert(cmcommand, FULL, SHELL);
+ return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL);
}
- std::vector<std::string> enabledLanguages;
- this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);
+ std::vector<std::string> enabledLanguages =
+ this->GetState()->GetEnabledLanguages();
// loop over language specific replace variables
int pos = 0;
while(ruleReplaceVars[pos])
@@ -1215,7 +1176,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
// If this is a windows shell, the result has a space, and the path
// already exists, we can use a short-path to reference it without a
// space.
- if(this->GlobalGenerator->WindowsShell && result.find(' ') != result.npos &&
+ if(this->GetState()->UseWindowsShell() && result.find(' ') != result.npos &&
cmSystemTools::FileExists(remote.c_str()))
{
std::string tmp;
@@ -1878,7 +1839,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
fdi != fwDirs.end(); ++fdi)
{
frameworkPath += fwSearchFlag;
- frameworkPath += this->Convert(*fdi, NONE, shellFormat, false);
+ frameworkPath += this->Convert(*fdi, NONE, shellFormat);
frameworkPath += " ";
}
}
@@ -1932,7 +1893,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
ri != runtimeDirs.end(); ++ri)
{
rpath += cli.GetRuntimeFlag();
- rpath += this->Convert(*ri, NONE, shellFormat, false);
+ rpath += this->Convert(*ri, NONE, shellFormat);
rpath += " ";
}
fout << rpath;
@@ -2288,7 +2249,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
static void AddVisibilityCompileOption(std::string &flags,
cmTarget const* target,
cmLocalGenerator *lg,
- const std::string& lang)
+ const std::string& lang,
+ std::string* warnCMP0063)
{
std::string l(lang);
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
@@ -2304,6 +2266,11 @@ static void AddVisibilityCompileOption(std::string &flags,
{
return;
}
+ if (warnCMP0063)
+ {
+ *warnCMP0063 += " " + flagDefine + "\n";
+ return;
+ }
if (strcmp(prop, "hidden") != 0
&& strcmp(prop, "default") != 0
&& strcmp(prop, "protected") != 0
@@ -2321,7 +2288,8 @@ static void AddVisibilityCompileOption(std::string &flags,
static void AddInlineVisibilityCompileOption(std::string &flags,
cmTarget const* target,
- cmLocalGenerator *lg)
+ cmLocalGenerator *lg,
+ std::string* warnCMP0063)
{
std::string compileOption
= "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
@@ -2336,6 +2304,11 @@ static void AddInlineVisibilityCompileOption(std::string &flags,
{
return;
}
+ if (warnCMP0063)
+ {
+ *warnCMP0063 += " VISIBILITY_INLINES_HIDDEN\n";
+ return;
+ }
lg->AppendFlags(flags, opt);
}
@@ -2344,25 +2317,49 @@ void cmLocalGenerator
::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target,
const std::string& lang)
{
- int targetType = target->GetType();
- bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
- || (targetType == cmTarget::MODULE_LIBRARY)
- || (target->IsExecutableWithExports()));
-
- if (!suitableTarget)
+ if (lang.empty())
{
return;
}
- if (lang.empty())
+ std::string warnCMP0063;
+ std::string *pWarnCMP0063 = 0;
+ if (target->GetType() != cmTarget::SHARED_LIBRARY &&
+ target->GetType() != cmTarget::MODULE_LIBRARY &&
+ !target->IsExecutableWithExports())
{
- return;
+ switch (target->GetPolicyStatusCMP0063())
+ {
+ case cmPolicies::OLD:
+ return;
+ case cmPolicies::WARN:
+ pWarnCMP0063 = &warnCMP0063;
+ break;
+ default:
+ break;
+ }
}
- AddVisibilityCompileOption(flags, target, this, lang);
+
+ AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
if(lang == "CXX")
{
- AddInlineVisibilityCompileOption(flags, target, this);
+ AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
+ }
+
+ if (!warnCMP0063.empty() &&
+ this->WarnCMP0063.insert(target).second)
+ {
+ std::ostringstream w;
+ w <<
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n"
+ "Target \"" << target->GetName() << "\" of "
+ "type \"" << cmTarget::GetTargetTypeName(target->GetType()) << "\" "
+ "has the following visibility properties set for " << lang << ":\n" <<
+ warnCMP0063 <<
+ "For compatibility CMake is not honoring them for this target.";
+ target->GetMakefile()->GetCMakeInstance()
+ ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace());
}
}
@@ -2587,7 +2584,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
{
// Append the definition with proper escaping.
std::string def = dflag;
- if(this->GlobalGenerator->WatcomWMake)
+ if(this->GetState()->UseWatcomWMake())
{
// The Watcom compiler does its own command line parsing instead
// of using the windows shell rules. Definitions are one of
@@ -2705,13 +2702,6 @@ std::string cmLocalGenerator::Convert(const std::string& source,
OutputFormat output,
bool optional)
{
- // Make sure the relative path conversion components are set.
- if(!this->PathConversionsSetup)
- {
- this->SetupPathConversions();
- this->PathConversionsSetup = true;
- }
-
// Convert the path to a relative path.
std::string result = source;
@@ -2721,25 +2711,23 @@ std::string cmLocalGenerator::Convert(const std::string& source,
{
case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->GetState()->GetSourceDirectoryComponents(), result);
break;
case START:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result = this->ConvertToRelativePath(this->StartDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result);
break;
case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result =
- this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->GetState()->GetBinaryDirectoryComponents(), result);
break;
case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result =
- this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result);
break;
case FULL:
result = cmSystemTools::CollapseFullPath(result);
@@ -2766,7 +2754,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
// For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to
// avoid problems with the shell path translation.
- if(this->GlobalGenerator->MSYSShell && !this->LinkScriptShell)
+ if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell)
{
if(result.size() > 2 && result[1] == ':')
{
@@ -2774,7 +2762,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
result[0] = '/';
}
}
- if(this->GlobalGenerator->WindowsShell)
+ if(this->GetState()->UseWindowsShell())
{
std::replace(result.begin(), result.end(), '/', '\\');
}
@@ -2812,97 +2800,6 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::FindRelativePathTopSource()
-{
- cmState::Snapshot snapshot = this->StateSnapshot;
- std::vector<cmState::Snapshot> snapshots;
- snapshots.push_back(snapshot);
- while (true)
- {
- snapshot = snapshot.GetParent();
- if (snapshot.IsValid())
- {
- snapshots.push_back(snapshot);
- }
- else
- {
- break;
- }
- }
-
- std::string result = snapshots.front().GetCurrentSourceDirectory();
-
- for (std::vector<cmState::Snapshot>::const_iterator it =
- snapshots.begin() + 1; it != snapshots.end(); ++it)
- {
- std::string currentSource = it->GetCurrentSourceDirectory();
- if(cmSystemTools::IsSubDirectory(result, currentSource))
- {
- result = currentSource;
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-std::string cmLocalGenerator::FindRelativePathTopBinary()
-{
- cmState::Snapshot snapshot = this->StateSnapshot;
- std::vector<cmState::Snapshot> snapshots;
- snapshots.push_back(snapshot);
- while (true)
- {
- snapshot = snapshot.GetParent();
- if (snapshot.IsValid())
- {
- snapshots.push_back(snapshot);
- }
- else
- {
- break;
- }
- }
-
- std::string result = snapshots.front().GetCurrentBinaryDirectory();
-
- for (std::vector<cmState::Snapshot>::const_iterator it =
- snapshots.begin() + 1; it != snapshots.end(); ++it)
- {
- std::string currentBinary = it->GetCurrentBinaryDirectory();
- if(cmSystemTools::IsSubDirectory(result, currentBinary))
- {
- result = currentBinary;
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-void cmLocalGenerator::ConfigureRelativePaths()
-{
- // Relative path conversion inside the source tree is not used to
- // construct relative paths passed to build tools so it is safe to
- // even when the source is a network path.
- std::string source = this->FindRelativePathTopSource();
- this->RelativePathTopSource = source;
-
- // The current working directory on Windows cannot be a network
- // path. Therefore relative paths cannot work when the binary tree
- // is a network path.
- std::string binary = this->FindRelativePathTopBinary();
- if(binary.size() < 2 || binary.substr(0, 2) != "//")
- {
- this->RelativePathTopBinary = binary;
- }
- else
- {
- this->RelativePathTopBinary = "";
- }
-}
-
-//----------------------------------------------------------------------------
static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
{
return (cmSystemTools::ComparePath(a, b) ||
@@ -2927,26 +2824,19 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
return in_remote;
}
- // Make sure relative path conversion is configured.
- if(!this->RelativePathsConfigured)
- {
- this->ConfigureRelativePaths();
- this->RelativePathsConfigured = true;
- }
-
if(!force)
{
// Skip conversion if the path and local are not both in the source
// or both in the binary tree.
std::string local_path = cmSystemTools::JoinPath(local);
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
- this->RelativePathTopBinary.c_str()) &&
+ this->StateSnapshot.GetRelativePathTopBinary()) &&
cmLocalGeneratorNotAbove(in_remote.c_str(),
- this->RelativePathTopBinary.c_str())) ||
+ this->StateSnapshot.GetRelativePathTopBinary())) ||
(cmLocalGeneratorNotAbove(local_path.c_str(),
- this->RelativePathTopSource.c_str()) &&
+ this->StateSnapshot.GetRelativePathTopSource()) &&
cmLocalGeneratorNotAbove(in_remote.c_str(),
- this->RelativePathTopSource.c_str()))))
+ this->StateSnapshot.GetRelativePathTopSource()))))
{
return in_remote;
}
@@ -3287,22 +3177,22 @@ void cmLocalGenerator::ComputeObjectFilenames(
bool cmLocalGenerator::IsWindowsShell() const
{
- return this->GlobalGenerator->WindowsShell;
+ return this->GetState()->UseWindowsShell();
}
bool cmLocalGenerator::IsWatcomWMake() const
{
- return this->GlobalGenerator->WatcomWMake;
+ return this->GetState()->UseWatcomWMake();
}
bool cmLocalGenerator::IsMinGWMake() const
{
- return this->GlobalGenerator->MinGWMake;
+ return this->GetState()->UseMinGWMake();
}
bool cmLocalGenerator::IsNMake() const
{
- return this->GlobalGenerator->NMake;
+ return this->GetState()->UseNMake();
}
void cmLocalGenerator::SetConfiguredCMP0014(bool configured)
@@ -3453,7 +3343,7 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
// Compute the flags for the target shell environment.
int flags = 0;
- if(this->GlobalGenerator->WindowsVSIDE)
+ if(this->GetState()->UseWindowsVSIDE())
{
flags |= cmsysSystem_Shell_Flag_VSIDE;
}
@@ -3473,27 +3363,27 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
{
flags |= cmsysSystem_Shell_Flag_WatcomQuote;
}
- if(this->GlobalGenerator->WatcomWMake)
+ if(this->GetState()->UseWatcomWMake())
{
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
}
- if(this->GlobalGenerator->MinGWMake)
+ if(this->GetState()->UseMinGWMake())
{
flags |= cmsysSystem_Shell_Flag_MinGWMake;
}
- if(this->GlobalGenerator->NMake)
+ if(this->GetState()->UseNMake())
{
flags |= cmsysSystem_Shell_Flag_NMake;
}
// Compute the buffer size needed.
- int size = (this->GlobalGenerator->WindowsShell ?
+ int size = (this->GetState()->UseWindowsShell() ?
cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags));
// Compute the shell argument itself.
std::vector<char> arg(size);
- if(this->GlobalGenerator->WindowsShell)
+ if(this->GetState()->UseWindowsShell())
{
cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index fa2f712..32b17f5 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -34,7 +34,8 @@ class cmCustomCommandGenerator;
class cmLocalGenerator
{
public:
- cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
+ cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalGenerator();
/// @return whether we are processing the top CMakeLists.txt file.
@@ -395,7 +396,7 @@ public:
protected:
///! put all the libraries for a target on into the given stream
- virtual void OutputLinkLibraries(std::string& linkLibraries,
+ void OutputLinkLibraries(std::string& linkLibraries,
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget &,
@@ -440,11 +441,6 @@ protected:
std::string const& dir_max);
void ComputeObjectMaxPath();
- void ConfigureRelativePaths();
- std::string FindRelativePathTopSource();
- std::string FindRelativePathTopBinary();
- void SetupPathConversions();
-
virtual std::string ConvertToLinkReference(std::string const& lib,
OutputFormat format = SHELL);
@@ -452,25 +448,19 @@ protected:
definition. Issues a warning. */
virtual bool CheckDefinition(std::string const& define) const;
- /** Read the input CMakeLists.txt file. */
- void ReadInputFile();
-
cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator;
- std::vector<std::string> HomeDirectoryComponents;
- std::vector<std::string> StartDirectoryComponents;
- std::vector<std::string> HomeOutputDirectoryComponents;
- std::vector<std::string> StartOutputDirectoryComponents;
cmLocalGenerator* Parent;
std::vector<cmLocalGenerator*> Children;
std::map<std::string, std::string> UniqueObjectNamesMap;
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
+ std::set<cmTarget const*> WarnCMP0063;
+
bool LinkScriptShell;
bool UseRelativePaths;
- bool IgnoreLibPrefix;
bool Configured;
bool EmitUniversalBinaryFlags;
@@ -478,16 +468,6 @@ protected:
// committed.
std::string TargetImplib;
- // The top-most directories for relative path conversion. Both the
- // source and destination location of a relative path conversion
- // must be underneath one of these directories (both under source or
- // both under binary) in order for the relative path to be evaluated
- // safely by the build tools.
- std::string RelativePathTopSource;
- std::string RelativePathTopBinary;
- bool RelativePathsConfigured;
- bool PathConversionsSetup;
-
cmIML_INT_uint64_t BackwardsCompatibility;
bool BackwardsCompatibilityFinal;
private:
diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx
index ddef3f5..870b9b9 100644
--- a/Source/cmLocalGhsMultiGenerator.cxx
+++ b/Source/cmLocalGhsMultiGenerator.cxx
@@ -17,8 +17,9 @@
#include "cmGeneratedFileStream.h"
cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent)
- : cmLocalGenerator(gg, parent)
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : cmLocalGenerator(gg, parent, snapshot)
{
}
@@ -27,31 +28,16 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {}
void cmLocalGhsMultiGenerator::Generate()
{
cmGeneratorTargetsType tgts = this->GetMakefile()->GetGeneratorTargets();
- if (!tgts.empty())
+
+ for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end();
+ ++l)
{
- for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end();
- ++l)
+ if (l->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY
+ || l->second->Target->IsImported())
{
- cmGhsMultiTargetGenerator tg(l->second->Target);
- tg.Generate();
+ continue;
}
+ cmGhsMultiTargetGenerator tg(l->second->Target);
+ tg.Generate();
}
}
-
-// Implemented in:
-// cmLocalGenerator.
-// Used in:
-// Source/cmMakefile.cxx
-// Source/cmGlobalGenerator.cxx
-void cmLocalGhsMultiGenerator::Configure()
-{
- // Compute the path to use when referencing the current output
- // directory from the top output directory.
- this->HomeRelativeOutputPath =
- this->Convert(this->Makefile->GetCurrentBinaryDirectory(), HOME_OUTPUT);
- if (this->HomeRelativeOutputPath == ".")
- {
- this->HomeRelativeOutputPath = "";
- }
- this->cmLocalGenerator::Configure();
-}
diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h
index ec25cba..f52ef39 100644
--- a/Source/cmLocalGhsMultiGenerator.h
+++ b/Source/cmLocalGhsMultiGenerator.h
@@ -25,32 +25,15 @@ class cmGeneratedFileStream;
class cmLocalGhsMultiGenerator : public cmLocalGenerator
{
public:
- cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
+ cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalGhsMultiGenerator();
- /// @returns the relative path between the HomeOutputDirectory and this
- /// local generators StartOutputDirectory.
- std::string GetHomeRelativeOutputPath() const
- {
- return this->HomeRelativeOutputPath;
- }
-
/**
* Generate the makefile for this directory.
*/
virtual void Generate();
-
- /// Overloaded methods. @see cmLocalGenerator::Configure()
- virtual void Configure();
- const char *GetBuildFileName() { return this->BuildFileName.c_str(); }
-
-protected:
- virtual bool CustomCommandUseLocal() const { return true; }
-
-private:
- std::string BuildFileName;
- std::string HomeRelativeOutputPath;
};
#endif
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index f1f1202..c08c91f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -23,8 +23,9 @@
#include <assert.h>
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent)
- : cmLocalGenerator(gg, parent)
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : cmLocalGenerator(gg, parent, snapshot)
, ConfigName("")
, HomeRelativeOutputPath("")
{
@@ -305,8 +306,8 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os
<< "# Write statements declared in CMakeLists.txt:" << std::endl
- << "# " << this->Makefile->GetCurrentListFile() << std::endl
- ;
+ << "# "
+ << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl;
if(this->IsRootMakefile())
os << "# Which is the root file." << std::endl;
cmGlobalNinjaGenerator::WriteDivider(os);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 3a6e030..7ae97de 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -31,28 +31,20 @@ class cmake;
class cmLocalNinjaGenerator : public cmLocalGenerator
{
public:
- /// Default constructor.
- cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
+ cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
- /// Destructor.
virtual ~cmLocalNinjaGenerator();
- /// Overloaded methods. @see cmLocalGenerator::Generate()
virtual void Generate();
- /// Overloaded methods. @see cmLocalGenerator::Configure()
virtual void Configure();
- /// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory()
virtual std::string GetTargetDirectory(cmTarget const& target) const;
const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();
- /**
- * Shortcut to get the cmake instance throw the global generator.
- * @return an instance of the cmake object.
- */
const cmake* GetCMakeInstance() const;
cmake* GetCMakeInstance();
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index f11c79e..3eea59b 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -80,15 +80,11 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::
-cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent)
- : cmLocalGenerator(gg, parent)
+cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : cmLocalGenerator(gg, parent, snapshot)
{
- this->IncludeDirective = "include";
this->MakefileVariableSize = 0;
- this->IgnoreLibPrefix = false;
- this->PassMakeflags = false;
- this->DefineWindowsNULL = false;
- this->UnixCD = true;
this->ColorMakefile = false;
this->SkipPreprocessedSourceRules = false;
this->SkipAssemblySourceRules = false;
@@ -545,9 +541,11 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
// Setup relative path conversion tops.
infoFileStream
<< "# Relative path conversion top directories.\n"
- << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource
+ << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \""
+ << this->StateSnapshot.GetRelativePathTopSource()
<< "\")\n"
- << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary
+ << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \""
+ << this->StateSnapshot.GetRelativePathTopBinary()
<< "\")\n"
<< "\n";
@@ -720,7 +718,9 @@ cmLocalUnixMakefileGenerator3
makefileStream
<< "# Set environment variables for the build.\n"
<< "\n";
- if(this->DefineWindowsNULL)
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+ if(gg->DefineWindowsNULL)
{
makefileStream
<< "!IF \"$(OS)\" == \"Windows_NT\"\n"
@@ -745,18 +745,16 @@ cmLocalUnixMakefileGenerator3
#endif
}
- std::string cmakecommand =
- this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
makefileStream
<< "# The CMake executable.\n"
<< "CMAKE_COMMAND = "
- << this->ConvertShellCommand(cmakecommand, FULL)
+ << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
<< "\n"
<< "\n";
makefileStream
<< "# The command to remove a file.\n"
<< "RM = "
- << this->ConvertShellCommand(cmakecommand, FULL)
+ << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
<< " -E remove -f\n"
<< "\n";
makefileStream
@@ -1613,16 +1611,15 @@ cmLocalUnixMakefileGenerator3
}
// Setup relative path top directories.
- this->RelativePathsConfigured = true;
if(const char* relativePathTopSource =
mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE"))
{
- this->RelativePathTopSource = relativePathTopSource;
+ this->StateSnapshot.SetRelativePathTopSource(relativePathTopSource);
}
if(const char* relativePathTopBinary =
mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY"))
{
- this->RelativePathTopBinary = relativePathTopBinary;
+ this->StateSnapshot.SetRelativePathTopBinary(relativePathTopBinary);
}
}
else
@@ -2143,10 +2140,12 @@ cmLocalUnixMakefileGenerator3
cmd += this->Convert(makefile,NONE,SHELL);
cmd += " ";
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
// Pass down verbosity level.
- if(!this->GetMakeSilentFlag().empty())
+ if(!gg->MakeSilentFlag.empty())
{
- cmd += this->GetMakeSilentFlag();
+ cmd += gg->MakeSilentFlag;
cmd += " ";
}
@@ -2154,7 +2153,7 @@ cmLocalUnixMakefileGenerator3
// sub-invoked makes via an environment variable. However, some
// makes do not support that, so you have to pass the flags
// explicitly.
- if(this->GetPassMakeflags())
+ if(gg->PassMakeflags)
{
cmd += "-$(MAKEFLAGS) ";
}
@@ -2346,7 +2345,9 @@ void cmLocalUnixMakefileGenerator3
// support changing the drive letter with just "d:").
const char* cd_cmd = this->IsMinGWMake() ? "cd /d " : "cd ";
- if(!this->UnixCD)
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+ if(!gg->UnixCD)
{
// On Windows we must perform each step separately and then change
// back because the shell keeps the working directory between
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 7b436a5..988d660 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -35,7 +35,8 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator
{
public:
cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg,
- cmLocalGenerator* parent);
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalUnixMakefileGenerator3();
/**
@@ -67,52 +68,11 @@ public:
void WriteMakeVariables(std::ostream& makefileStream);
/**
- * If true, then explicitly pass MAKEFLAGS on the make all target for makes
- * that do not use environment variables.
- *
- */
- void SetPassMakeflags(bool s){this->PassMakeflags = s;}
- bool GetPassMakeflags() { return this->PassMakeflags; }
-
- /**
- * Set the flag used to keep the make program silent.
- */
- void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; }
- std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; }
-
- /**
- * If set to true, then NULL is set to nil for non Windows_NT.
- * This uses make syntax used by nmake and borland.
- * The default is false.
- */
- void SetDefineWindowsNULL(bool v) {this->DefineWindowsNULL = v;}
-
- /**
- * If set to true, cd dir && command is used to
- * run commands in a different directory.
- */
- void SetUnixCD(bool v) {this->UnixCD = v;}
-
- /**
- * Set the string used to include one makefile into another default
- * is include.
- */
- void SetIncludeDirective(const std::string& s)
- { this->IncludeDirective = s; }
- const std::string& GetIncludeDirective() { return this->IncludeDirective; }
-
- /**
* Set max makefile variable size, default is 0 which means unlimited.
*/
void SetMakefileVariableSize(int s) { this->MakefileVariableSize = s; }
/**
- * If ignore lib prefix is true, then do not strip lib from the name
- * of a library.
- */
- void SetIgnoreLibPrefix(bool s) { this->IgnoreLibPrefix = s; }
-
- /**
* Set whether passing a make target on a command line requires an
* extra level of escapes.
*/
@@ -303,12 +263,7 @@ private:
//==========================================================================
// Configuration settings.
int MakefileVariableSize;
- std::string IncludeDirective;
- std::string MakeSilentFlag;
std::string ConfigurationName;
- bool DefineWindowsNULL;
- bool UnixCD;
- bool PassMakeflags;
bool MakeCommandEscapeTargetTwice;
bool BorlandMakeCurlyHack;
//==========================================================================
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 06a3b6c..ad6a020 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -62,9 +62,10 @@ class cmVS10XMLParser : public cmXMLParser
//----------------------------------------------------------------------------
cmLocalVisualStudio10Generator
-::cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent):
- cmLocalVisualStudio7Generator(v, gg, parent)
+::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot):
+ cmLocalVisualStudio7Generator(gg, parent, snapshot)
{
}
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index 987e08b..c588aaf 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -25,8 +25,9 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent);
+ cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio10Generator();
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 42da639..ad34857 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -25,8 +25,9 @@
cmLocalVisualStudio6Generator
::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent):
- cmLocalVisualStudioGenerator(VS6, gg, parent)
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot):
+ cmLocalVisualStudioGenerator(gg, parent, snapshot)
{
}
@@ -221,10 +222,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
{
std::string dspname = GetVS6TargetName(tgt.GetName());
dspname += ".dsp.cmake";
- const char* dsprule =
- this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
- commandLine.push_back(dsprule);
+ commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
@@ -817,7 +816,7 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
// Add a pre-link event to create the directory.
cmCustomCommandLine command;
- command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"));
+ command.push_back(cmSystemTools::GetCMakeCommand());
command.push_back("-E");
command.push_back("make_directory");
command.push_back(outDir);
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index a6e0b3d..8f4d521 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -30,7 +30,8 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
public:
///! Set cache only and recurse to false by default.
cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent);
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio6Generator();
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 63c18a7..9c031cf 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -55,11 +55,11 @@ static void cmConvertToWindowsSlash(std::string& s)
//----------------------------------------------------------------------------
cmLocalVisualStudio7Generator
-::cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent):
- cmLocalVisualStudioGenerator(v, gg, parent)
+::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot):
+ cmLocalVisualStudioGenerator(gg, parent, snapshot)
{
- this->ExtraFlagTable = 0;
this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
}
@@ -241,18 +241,17 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
void cmLocalVisualStudio7Generator
::CreateSingleVCProj(const std::string& lname, cmTarget &target)
{
- this->FortranProject =
- static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetIsFortranOnly(target);
- this->WindowsCEProject =
- static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetsWindowsCE();
+ cmGlobalVisualStudioGenerator* gg
+ = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
+ this->FortranProject = gg->TargetIsFortranOnly(target);
+ this->WindowsCEProject = gg->TargetsWindowsCE();
// Intel Fortran for VS10 uses VS9 format ".vfproj" files.
- VSVersion realVersion = this->Version;
- if(this->FortranProject && this->Version >= VS10)
+ cmGlobalVisualStudioGenerator::VSVersion realVersion = gg->GetVersion();
+ if(this->FortranProject
+ && gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS10)
{
- this->Version = VS9;
+ gg->SetVersion(cmGlobalVisualStudioGenerator::VS9);
}
// add to the list of projects
@@ -282,7 +281,7 @@ void cmLocalVisualStudio7Generator
this->GlobalGenerator->FileReplacedDuringGenerate(fname);
}
- this->Version = realVersion;
+ gg->SetVersion(realVersion);
}
//----------------------------------------------------------------------------
@@ -292,10 +291,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
stampName += "/";
stampName += cmake::GetCMakeFilesDirectoryPostSlash();
stampName += "generate.stamp";
- const char* dsprule =
- this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
- commandLine.push_back(dsprule);
+ commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
@@ -343,17 +340,14 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
}
}
-void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
- const std::string& libName,
- cmTarget &target)
+void cmLocalVisualStudio7Generator::WriteConfigurations(
+ std::ostream& fout, std::vector<std::string> const& configs,
+ const std::string& libName, cmTarget &target
+ )
{
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
-
fout << "\t<Configurations>\n";
- for( std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for (std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
this->WriteConfiguration(fout, i->c_str(), libName, target);
}
@@ -773,7 +767,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
}
Options targetOptions(this, t,
table,
- this->ExtraFlagTable);
+ gg->ExtraFlagTable);
targetOptions.FixExceptionHandlingDefault();
std::string asmLocation = configName + "/";
targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
@@ -995,7 +989,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// end of <Tool Name=VCMIDLTool
// Check if we need the FAT32 workaround.
- if(targetBuilds && this->Version >= VS8)
+ if(targetBuilds && this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
{
// Check the filesystem type where the target will be written.
if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
@@ -1130,7 +1124,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
- if(this->GetVersion() < VS8 || this->FortranProject)
+ if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
+ || this->FortranProject)
{
std::ostringstream libdeps;
this->Internal->OutputObjects(libdeps, &target);
@@ -1190,7 +1185,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8 || this->FortranProject)
+ if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
+ || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1218,7 +1214,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
if(this->WindowsCEProject)
{
- if(this->GetVersion() < VS9)
+ if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
{
fout << "\t\t\t\tSubSystem=\"9\"\n";
}
@@ -1288,7 +1284,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8 || this->FortranProject)
+ if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
+ || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1316,7 +1313,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
if ( this->WindowsCEProject )
{
- if(this->GetVersion() < VS9)
+ if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
{
fout << "\t\t\t\tSubSystem=\"9\"\n";
}
@@ -1469,10 +1466,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
const std::string& libName,
cmTarget &target)
{
- // get the configurations
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
@@ -1505,7 +1500,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// open the project
this->WriteProjectStart(fout, libName, target, sourceGroups);
// write the configuration information
- this->WriteConfigurations(fout, libName, target);
+ this->WriteConfigurations(fout, configs, libName, target);
fout << "\t<Files>\n";
@@ -1517,7 +1512,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
this->WriteGroup(&sg, target, fout, libName, configs);
}
- if(this->GetVersion() >= VS8 && !this->FortranProject)
+ if(this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8
+ && !this->FortranProject)
{
// VS >= 8 support per-config source locations so we
// list object library content as external objects.
@@ -1561,7 +1557,7 @@ public:
cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
cmTarget& target,
cmSourceFile const& sf,
- std::vector<std::string>* configs);
+ std::vector<std::string> const& configs);
std::map<std::string, cmLVS7GFileConfig> FileConfigMap;
};
@@ -1569,7 +1565,7 @@ cmLocalVisualStudio7GeneratorFCInfo
::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
cmTarget& target,
cmSourceFile const& sf,
- std::vector<std::string>* configs)
+ std::vector<std::string> const& configs)
{
cmGeneratorTarget* gt =
lg->GetGlobalGenerator()->GetGeneratorTarget(&target);
@@ -1580,8 +1576,8 @@ cmLocalVisualStudio7GeneratorFCInfo
}
// Compute per-source, per-config information.
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
std::string configUpper = cmSystemTools::UpperCase(*i);
cmLVS7GFileConfig fc;
@@ -1691,13 +1687,13 @@ std::string
cmLocalVisualStudio7Generator
::ComputeLongestObjectDirectory(cmTarget& target) const
{
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
+ std::vector<std::string> configs;
+ target.GetMakefile()->GetConfigurations(configs);
+
// Compute the maximum length configuration name.
std::string config_max;
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::iterator i = configs.begin();
+ i != configs.end(); ++i)
{
if(i->size() > config_max.size())
{
@@ -1721,7 +1717,7 @@ cmLocalVisualStudio7Generator
bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const std::string& libName,
- std::vector<std::string> *configs)
+ std::vector<std::string> const& configs)
{
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
@@ -1771,7 +1767,8 @@ bool cmLocalVisualStudio7Generator
fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
if(cmCustomCommand const* command = (*sf)->GetCustomCommand())
{
- this->WriteCustomRule(fout, source.c_str(), *command, fcinfo);
+ this->WriteCustomRule(fout, configs, source.c_str(),
+ *command, fcinfo);
}
else if(!fcinfo.FileConfigMap.empty())
{
@@ -1842,7 +1839,7 @@ bool cmLocalVisualStudio7Generator
table = cmLocalVisualStudio7GeneratorFortranFlagTable;
}
Options fileOptions(this, tool, table,
- this->ExtraFlagTable);
+ gg->ExtraFlagTable);
fileOptions.Parse(fc.CompileFlags.c_str());
fileOptions.AddDefines(fc.CompileDefs.c_str());
fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
@@ -1887,6 +1884,7 @@ bool cmLocalVisualStudio7Generator
void cmLocalVisualStudio7Generator::
WriteCustomRule(std::ostream& fout,
+ std::vector<std::string> const& configs,
const char* source,
const cmCustomCommand& command,
FCInfo& fcinfo)
@@ -1895,10 +1893,6 @@ WriteCustomRule(std::ostream& fout,
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
// Write the rule for each configuration.
- std::vector<std::string>::iterator i;
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
const char* compileTool = "VCCLCompilerTool";
if(this->FortranProject)
{
@@ -1909,7 +1903,8 @@ WriteCustomRule(std::ostream& fout,
{
customTool = "VFCustomBuildTool";
}
- for(i = configs->begin(); i != configs->end(); ++i)
+ for (std::vector<std::string>::const_iterator i = configs.begin();
+ i != configs.end(); ++i)
{
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
@@ -2149,13 +2144,13 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
<< gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n"
<< "\tProjectType=\"Visual C++\"\n";
- if(this->Version == VS71)
+ if(gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71)
{
fout << "\tVersion=\"7.10\"\n";
}
else
{
- fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n";
+ fout << "\tVersion=\"" << (gg->GetVersion()/10) << ".00\"\n";
}
const char* projLabel = target.GetProperty("PROJECT_LABEL");
if(!projLabel)
@@ -2168,7 +2163,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
keyword = "Win32Proj";
}
fout << "\tName=\"" << projLabel << "\"\n";
- if(this->Version >= VS8)
+ if(gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
{
fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
}
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 1891369..43f3af9 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -35,8 +35,9 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent);
+ cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio7Generator();
@@ -54,8 +55,6 @@ public:
*/
void SetBuildType(BuildType,const std::string& name);
- void SetExtraFlagTable(cmVS7FlagTable const* table)
- { this->ExtraFlagTable = table; }
virtual std::string GetTargetDirectory(cmTarget const&) const;
cmSourceFile* CreateVCProjBuildRule();
void WriteStampFiles();
@@ -79,6 +78,7 @@ private:
void WriteVCProjFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt);
void WriteConfigurations(std::ostream& fout,
+ std::vector<std::string> const& configs,
const std::string& libName, cmTarget &tgt);
void WriteConfiguration(std::ostream& fout,
const std::string& configName,
@@ -103,6 +103,7 @@ private:
void WriteVCProjEndGroup(std::ostream& fout);
void WriteCustomRule(std::ostream& fout,
+ std::vector<std::string> const& configs,
const char* source,
const cmCustomCommand& command,
FCInfo& fcinfo);
@@ -111,7 +112,7 @@ private:
bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout,
const std::string& libName,
- std::vector<std::string> *configs);
+ std::vector<std::string> const& configs);
friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals;
@@ -119,7 +120,6 @@ private:
class EventWriter;
friend class EventWriter;
- cmVS7FlagTable const* ExtraFlagTable;
std::string ModuleDefinitionFile;
bool FortranProject;
bool WindowsCEProject;
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 4a596d5..ca72939 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -19,11 +19,11 @@
//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator
-::cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent)
- : cmLocalGenerator(gg, parent)
+::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : cmLocalGenerator(gg, parent, snapshot)
{
- this->Version = v;
}
//----------------------------------------------------------------------------
@@ -32,6 +32,15 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
}
//----------------------------------------------------------------------------
+cmGlobalVisualStudioGenerator::VSVersion
+cmLocalVisualStudioGenerator::GetVersion() const
+{
+ cmGlobalVisualStudioGenerator* gg =
+ static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
+ return gg->GetVersion();
+}
+
+//----------------------------------------------------------------------------
void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
cmGeneratorTarget const* gt)
@@ -91,7 +100,7 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
// Add a pre-build event to create the directory.
cmCustomCommandLine command;
- command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"));
+ command.push_back(cmSystemTools::GetCMakeCommand());
command.push_back("-E");
command.push_back("make_directory");
command.push_back(impDir);
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 1152e82..d414651 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -13,6 +13,7 @@
#define cmLocalVisualStudioGenerator_h
#include "cmLocalGenerator.h"
+#include "cmGlobalVisualStudioGenerator.h"
#include <cmsys/auto_ptr.hxx>
@@ -30,23 +31,9 @@ class cmCustomCommandGenerator;
class cmLocalVisualStudioGenerator : public cmLocalGenerator
{
public:
- /** Known versions of Visual Studio. */
- enum VSVersion
- {
- VS6 = 60,
- VS7 = 70,
- VS71 = 71,
- VS8 = 80,
- VS9 = 90,
- VS10 = 100,
- VS11 = 110,
- VS12 = 120,
- /* VS13 = 130 was skipped */
- VS14 = 140
- };
-
- cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg,
- cmLocalGenerator* parent);
+ cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */
@@ -57,8 +44,7 @@ public:
sequence of custom commands. */
const char* GetReportErrorLabel() const;
- /** Version of Visual Studio. */
- VSVersion GetVersion() const { return this->Version; }
+ cmGlobalVisualStudioGenerator::VSVersion GetVersion() const;
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const = 0;
@@ -76,8 +62,6 @@ protected:
cmsys::auto_ptr<cmCustomCommand>
MaybeCreateImplibDir(cmTarget& target, const std::string& config,
bool isFortran);
-
- VSVersion Version;
};
#endif
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index a957c27..804dd7d 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -16,8 +16,9 @@
//----------------------------------------------------------------------------
cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent)
- : cmLocalGenerator(gg, parent)
+ cmLocalGenerator* parent,
+ cmState::Snapshot snapshot)
+ : cmLocalGenerator(gg, parent, snapshot)
{
// the global generator does this, so do not
// put these flags into the language flags
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 54bc6df..26fff9c 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -24,7 +24,8 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
+ cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
+ cmState::Snapshot snapshot);
virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7b8d3af..ee6c1da 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -38,7 +38,6 @@
#include <cmsys/FStream.hxx>
#include <cmsys/auto_ptr.hxx>
-#include <stack>
#include <list>
#include <ctype.h> // for isspace
#include <assert.h>
@@ -47,8 +46,6 @@ class cmMakefile::Internals
{
public:
std::list<cmDefinitions> VarStack;
- std::stack<std::set<std::string> > VarInitStack;
- std::stack<std::set<std::string> > VarUsageStack;
bool IsSourceFileTryCompile;
void PushDefinitions()
@@ -69,6 +66,12 @@ public:
this->VarStack.rend());
}
+ bool IsInitialized(std::string const& name)
+ {
+ return cmDefinitions::HasKey(name, this->VarStack.rbegin(),
+ this->VarStack.rend());
+ }
+
void SetDefinition(std::string const& name, std::string const& value)
{
this->VarStack.back().Set(name, value.c_str());
@@ -76,34 +79,18 @@ public:
void RemoveDefinition(std::string const& name)
{
- if (this->VarStack.size() > 1)
- {
- // In lower scopes we store keys, defined or not.
- this->VarStack.back().Set(name, 0);
- }
- else
- {
- this->VarStack.back().Erase(name);
- }
+ this->VarStack.back().Set(name, 0);
}
- std::vector<std::string> LocalKeys() const
+ std::vector<std::string> UnusedKeys() const
{
- return this->VarStack.back().LocalKeys();
+ return this->VarStack.back().UnusedKeys();
}
std::vector<std::string> ClosureKeys() const
{
- std::vector<std::string> closureKeys;
- std::set<std::string> bound;
- for (std::list<cmDefinitions>::const_reverse_iterator it =
- this->VarStack.rbegin(); it != this->VarStack.rend(); ++it)
- {
- std::vector<std::string> const& localKeys = it->ClosureKeys(bound);
- closureKeys.insert(closureKeys.end(),
- localKeys.begin(), localKeys.end());
- }
- return closureKeys;
+ return cmDefinitions::ClosureKeys(this->VarStack.rbegin(),
+ this->VarStack.rend());
}
void PopDefinitions()
@@ -113,35 +100,32 @@ public:
bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
{
- assert(this->VarStack.size() > 0);
-
std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
+ assert(it != this->VarStack.rend());
++it;
if(it == this->VarStack.rend())
{
- if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
+ cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent();
+ if(!plg)
{
- // Update the definition in the parent directory top scope. This
- // directory's scope was initialized by the closure of the parent
- // scope, so we do not need to localize the definition first.
- cmMakefile* parent = plg->GetMakefile();
- if (varDef)
- {
- parent->AddDefinition(var, varDef);
- }
- else
- {
- parent->RemoveDefinition(var);
- }
- return true;
+ return false;
+ }
+ // Update the definition in the parent directory top scope. This
+ // directory's scope was initialized by the closure of the parent
+ // scope, so we do not need to localize the definition first.
+ cmMakefile* parent = plg->GetMakefile();
+ if (varDef)
+ {
+ parent->AddDefinition(var, varDef);
}
else
{
- return false;
+ parent->RemoveDefinition(var);
}
+ return true;
}
// First localize the definition in the current scope.
- this->GetDefinition(var);
+ cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend());
// Now update the definition in the parent scope.
it->Set(var, varDef);
@@ -156,13 +140,11 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
StateSnapshot(localGenerator->GetStateSnapshot())
{
this->Internal->PushDefinitions();
- this->Internal->VarInitStack.push(std::set<std::string>());
- this->Internal->VarUsageStack.push(std::set<std::string>());
this->Internal->IsSourceFileTryCompile = false;
// Initialize these first since AddDefaultDefinitions calls AddDefinition
- this->WarnUnused = false;
- this->CheckSystemVars = false;
+ this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
+ this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
this->GeneratingBuildSystem = false;
this->SuppressWatches = false;
@@ -232,24 +214,16 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
#endif
this->Properties.SetCMakeInstance(this->GetCMakeInstance());
- this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
- this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
{
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
- if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") )
- {
- this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
- }
+ this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
}
{
const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
this->AddDefinition("CMAKE_BINARY_DIR", dir);
- if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") )
- {
- this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
- }
+ this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
}
}
@@ -270,99 +244,34 @@ cmMakefile::~cmMakefile()
}
}
-void cmMakefile::PrintStringVector(const char* s,
- const std::vector<std::string>& v) const
-{
- std::cout << s << ": ( \n" << cmWrap('"', v, '"', " ") << ")\n";
-}
-
-void cmMakefile
-::PrintStringVector(const char* s,
- const std::vector<std::pair<std::string, bool> >& v) const
-{
- std::cout << s << ": ( \n";
- for(std::vector<std::pair<std::string, bool> >::const_iterator i
- = v.begin(); i != v.end(); ++i)
- {
- std::cout << i->first << " " << i->second;
- }
- std::cout << " )\n";
-}
-
-
-// call print on all the classes in the makefile
-void cmMakefile::Print() const
-{
- // print the class lists
- std::cout << "classes:\n";
-
- std::cout << " this->Targets: ";
- for (cmTargets::iterator l = this->Targets.begin();
- l != this->Targets.end(); l++)
- {
- std::cout << l->first << std::endl;
- }
-
- std::cout << " this->StartOutputDirectory; " <<
- this->GetCurrentBinaryDirectory() << std::endl;
- std::cout << " this->HomeOutputDirectory; " <<
- this->GetHomeOutputDirectory() << std::endl;
- std::cout << " this->cmStartDirectory; " <<
- this->GetCurrentSourceDirectory() << std::endl;
- std::cout << " this->cmHomeDirectory; " <<
- this->GetHomeDirectory() << std::endl;
- std::cout << " this->ProjectName; "
- << this->ProjectName << std::endl;
- this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- for( std::vector<cmSourceGroup>::const_iterator i =
- this->SourceGroups.begin(); i != this->SourceGroups.end(); ++i)
- {
- std::cout << "Source Group: " << i->GetName() << std::endl;
- }
-#endif
-}
-
//----------------------------------------------------------------------------
void cmMakefile::IssueMessage(cmake::MessageType t,
std::string const& text) const
{
// Collect context information.
- cmLocalGenerator* localGen = this->GetLocalGenerator();
- if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile())
- {
- localGen = 0;
- }
- cmListFileBacktrace backtrace(localGen);
if(!this->CallStack.empty())
{
if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR))
{
this->CallStack.back().Status->SetNestedError(true);
}
- backtrace = this->GetBacktrace();
+ this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
}
else
{
cmListFileContext lfc;
- if(this->ListFileStack.empty())
- {
- // We are not processing the project. Add the directory-level context.
- lfc.FilePath = this->GetCurrentSourceDirectory();
- lfc.FilePath += "/CMakeLists.txt";
- }
- else
+ // We are not currently executing a command. Add whatever context
+ // information we have.
+ lfc.FilePath = this->ListFileStack.back();
+
+ if(!this->GetCMakeInstance()->GetIsInTryCompile())
{
- // We are processing the project but are not currently executing a
- // command. Add whatever context information we have.
- lfc.FilePath = this->ListFileStack.back();
+ lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
+ cmLocalGenerator::HOME);
}
lfc.Line = 0;
- backtrace.push_back(lfc);
+ this->GetCMakeInstance()->IssueMessage(t, text, lfc);
}
-
- // Issue the message.
- this->GetCMakeInstance()->IssueMessage(t, text, backtrace);
}
//----------------------------------------------------------------------------
@@ -372,12 +281,18 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
i != this->CallStack.rend(); ++i)
{
- backtrace.push_back(*i->Context);
+ backtrace.Append(*i->Context);
}
return backtrace;
}
//----------------------------------------------------------------------------
+cmListFileContext cmMakefile::GetExecutionContext() const
+{
+ return *this->CallStack.back().Context;
+}
+
+//----------------------------------------------------------------------------
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
std::ostringstream msg;
@@ -603,7 +518,6 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
{
this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile);
- this->cmCurrentListFile = listfile;
std::string curSrc = this->GetCurrentSourceDirectory();
return this->ReadListFile(listfile, true,
curSrc == this->GetHomeDirectory());
@@ -611,17 +525,20 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope)
{
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile());
- this->cmCurrentListFile =
- cmSystemTools::CollapseFullPath(listfile,
- this->GetCurrentSourceDirectory());
- return this->ReadListFile(this->cmCurrentListFile.c_str(),
- noPolicyScope);
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE",
+ this->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
+ bool result = this->ReadListFile(listfile, noPolicyScope, false);
+ this->ListFileStack.pop_back();
+ return result;
+}
+
+bool cmMakefile::ReadListFile(const char* listfile)
+{
+ bool result = this->ReadListFile(listfile, true, false);
+ this->ListFileStack.pop_back();
+ return result;
}
-//----------------------------------------------------------------------------
-// Parse the given CMakeLists.txt file executing all commands
-//
bool cmMakefile::ReadListFile(const char* listfile,
bool noPolicyScope,
bool requireProjectCommand)
@@ -656,11 +573,8 @@ bool cmMakefile::ReadListFile(const char* listfile,
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
- this->ListFileStack.pop_back();
-
if (res)
{
- // Check for unused variables
this->CheckForUnusedVariables();
}
@@ -1704,9 +1618,12 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
return;
}
+ cmState::Snapshot newSnapshot = this->GetState()
+ ->CreateSnapshot(this->StateSnapshot);
+
// create a new local generator and set its parent
cmLocalGenerator *lg2 = this->GetGlobalGenerator()
- ->CreateLocalGenerator(this->LocalGenerator);
+ ->MakeLocalGenerator(newSnapshot, this->LocalGenerator);
this->GetGlobalGenerator()->AddLocalGenerator(lg2);
// set the subdirs start dirs
@@ -1795,14 +1712,11 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
return;
}
- this->Internal->SetDefinition(name, value);
- if (!this->Internal->VarUsageStack.empty() &&
- this->VariableInitialized(name))
+ if (this->VariableInitialized(name))
{
- this->CheckForUnused("changing definition", name);
- this->Internal->VarUsageStack.top().erase(name);
+ this->LogUnused("changing definition", name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->SetDefinition(name, value);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
@@ -1871,14 +1785,11 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
void cmMakefile::AddDefinition(const std::string& name, bool value)
{
- this->Internal->SetDefinition(name, value ? "ON" : "OFF");
- if (!this->Internal->VarUsageStack.empty() &&
- this->VariableInitialized(name))
+ if (this->VariableInitialized(name))
{
- this->CheckForUnused("changing definition", name);
- this->Internal->VarUsageStack.top().erase(name);
+ this->LogUnused("changing definition", name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->SetDefinition(name, value ? "ON" : "OFF");
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -1895,61 +1806,46 @@ void cmMakefile::CheckForUnusedVariables() const
{
return;
}
- const std::vector<std::string>& locals = this->Internal->LocalKeys();
- std::vector<std::string>::const_iterator it = locals.begin();
- for (; it != locals.end(); ++it)
+ const std::vector<std::string>& unused = this->Internal->UnusedKeys();
+ std::vector<std::string>::const_iterator it = unused.begin();
+ for (; it != unused.end(); ++it)
{
- this->CheckForUnused("out of scope", *it);
+ this->LogUnused("out of scope", *it);
}
}
void cmMakefile::MarkVariableAsUsed(const std::string& var)
{
- this->Internal->VarUsageStack.top().insert(var);
+ this->Internal->GetDefinition(var);
}
bool cmMakefile::VariableInitialized(const std::string& var) const
{
- if(this->Internal->VarInitStack.top().find(var) !=
- this->Internal->VarInitStack.top().end())
- {
- return true;
- }
- return false;
+ return this->Internal->IsInitialized(var);
}
-bool cmMakefile::VariableUsed(const std::string& var) const
-{
- if(this->Internal->VarUsageStack.top().find(var) !=
- this->Internal->VarUsageStack.top().end())
- {
- return true;
- }
- return false;
-}
-
-void cmMakefile::CheckForUnused(const char* reason,
+void cmMakefile::LogUnused(const char* reason,
const std::string& name) const
{
- if (this->WarnUnused && !this->VariableUsed(name))
+ if (this->WarnUnused)
{
std::string path;
- cmListFileBacktrace bt(this->GetLocalGenerator());
+ cmListFileContext lfc;
if (!this->CallStack.empty())
{
- const cmListFileContext* file = this->CallStack.back().Context;
- bt.push_back(*file);
- path = file->FilePath.c_str();
+ lfc = this->GetExecutionContext();
+ path = lfc.FilePath;
}
else
{
path = this->GetCurrentSourceDirectory();
path += "/CMakeLists.txt";
- cmListFileContext lfc;
lfc.FilePath = path;
lfc.Line = 0;
- bt.push_back(lfc);
}
+ lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
+ cmLocalGenerator::HOME);
+
if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(path,
this->GetHomeDirectory()) ||
@@ -1962,21 +1858,18 @@ void cmMakefile::CheckForUnused(const char* reason,
msg << "unused variable (" << reason << ") \'" << name << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
msg.str(),
- bt);
+ lfc);
}
}
}
void cmMakefile::RemoveDefinition(const std::string& name)
{
- this->Internal->RemoveDefinition(name);
- if (!this->Internal->VarUsageStack.empty() &&
- this->VariableInitialized(name))
+ if (this->VariableInitialized(name))
{
- this->CheckForUnused("unsetting", name);
- this->Internal->VarUsageStack.top().erase(name);
+ this->LogUnused("unsetting", name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->RemoveDefinition(name);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -2443,7 +2336,6 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
const char* def = this->Internal->GetDefinition(name);
- this->Internal->VarUsageStack.top().insert(name);
if(!def)
{
def = this->GetState()->GetInitializedCacheValue(name);
@@ -2464,10 +2356,6 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
const char* cmMakefile::GetDefinition(const std::string& name) const
{
- if (this->WarnUnused)
- {
- this->Internal->VarUsageStack.top().insert(name);
- }
const char* def = this->Internal->GetDefinition(name);
if(!def)
{
@@ -2874,14 +2762,13 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
this->GetHomeOutputDirectory()))
{
std::ostringstream msg;
- cmListFileBacktrace bt(this->GetLocalGenerator());
cmListFileContext lfc;
- lfc.FilePath = filename;
+ lfc.FilePath = this->LocalGenerator
+ ->Convert(filename, cmLocalGenerator::HOME);
lfc.Line = line;
- bt.push_back(lfc);
msg << "uninitialized variable \'" << lookup << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str(), bt);
+ msg.str(), lfc);
}
}
}
@@ -3410,7 +3297,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
if(!this->CallStack.empty())
{
// Record the context in which the blocker is created.
- fb->SetStartingContext(*(this->CallStack.back().Context));
+ fb->SetStartingContext(this->GetExecutionContext());
}
this->FunctionBlockers.push_back(fb);
@@ -3576,7 +3463,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// make sure the same generator is used
// use this program as the cmake to be run, it should not
// be run that way but the cmake object requires a vailid path
- std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND");
cmake cm;
cm.SetIsInTryCompile(true);
cmGlobalGenerator *gg = cm.CreateGlobalGenerator
@@ -4365,13 +4251,13 @@ void cmMakefile::AddCMakeDependFilesFromUser()
}
}
-std::string cmMakefile::GetListFileStack() const
+std::string cmMakefile::FormatListFileStack() const
{
std::ostringstream tmp;
size_t depth = this->ListFileStack.size();
if (depth > 0)
{
- std::deque<std::string>::const_iterator it = this->ListFileStack.end();
+ std::vector<std::string>::const_iterator it = this->ListFileStack.end();
do
{
if (depth != this->ListFileStack.size())
@@ -4394,10 +4280,6 @@ std::string cmMakefile::GetListFileStack() const
void cmMakefile::PushScope()
{
this->Internal->PushDefinitions();
- const std::set<std::string>& init = this->Internal->VarInitStack.top();
- const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
- this->Internal->VarInitStack.push(init);
- this->Internal->VarUsageStack.push(usage);
this->PushLoopBlockBarrier();
@@ -4414,31 +4296,9 @@ void cmMakefile::PopScope()
this->PopLoopBlockBarrier();
- std::set<std::string> init = this->Internal->VarInitStack.top();
- std::set<std::string> usage = this->Internal->VarUsageStack.top();
- const std::vector<std::string>& locals = this->Internal->LocalKeys();
- // Remove initialization and usage information for variables in the local
- // scope.
- std::vector<std::string>::const_iterator it = locals.begin();
- for (; it != locals.end(); ++it)
- {
- init.erase(*it);
- if (!this->VariableUsed(*it))
- {
- this->CheckForUnused("out of scope", *it);
- }
- else
- {
- usage.erase(*it);
- }
- }
+ this->CheckForUnusedVariables();
this->Internal->PopDefinitions();
- this->Internal->VarInitStack.pop();
- this->Internal->VarUsageStack.pop();
- // Push initialization and usage up to the parent scope.
- this->Internal->VarInitStack.top().insert(init.begin(), init.end());
- this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end());
}
void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
@@ -4935,20 +4795,9 @@ bool cmMakefile::SetPolicyVersion(const char *version)
}
//----------------------------------------------------------------------------
-bool cmMakefile::HasCMP0054AlreadyBeenReported(
- cmListFileContext context) const
+bool cmMakefile::HasCMP0054AlreadyBeenReported() const
{
- cmCMP0054Id id(context);
-
- bool alreadyReported =
- this->CMP0054ReportedIds.find(id) != this->CMP0054ReportedIds.end();
-
- if(!alreadyReported)
- {
- this->CMP0054ReportedIds.insert(id);
- }
-
- return alreadyReported;
+ return !this->CMP0054ReportedIds.insert(this->GetExecutionContext()).second;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index e0eef6f..27ef075 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -31,11 +31,14 @@
#include <cmsys/auto_ptr.hxx>
#include <cmsys/RegularExpression.hxx>
#if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+# include <unordered_map>
+# else
+# include <cmsys/hash_map.hxx>
+# endif
#endif
#include <stack>
-#include <deque>
class cmFunctionBlocker;
class cmCommand;
@@ -62,14 +65,10 @@ class cmMakefile
class Internals;
cmsys::auto_ptr<Internals> Internal;
public:
- /* Check for unused variables in this scope */
- void CheckForUnusedVariables() const;
/* Mark a variable as used */
void MarkVariableAsUsed(const std::string& var);
/* return true if a variable has been initialized */
bool VariableInitialized(const std::string& ) const;
- /* return true if a variable has been used */
- bool VariableUsed(const std::string& ) const;
/**
* Construct an empty makefile.
@@ -81,12 +80,7 @@ public:
*/
~cmMakefile();
- /**
- * Read and parse a CMakeLists.txt file.
- */
- bool ReadListFile(const char* listfile,
- bool noPolicyScope = true,
- bool requireProjectCommand = false);
+ bool ReadListFile(const char* listfile);
bool ReadDependentFile(const char* listfile, bool noPolicyScope = true);
@@ -117,15 +111,6 @@ public:
};
friend class LexicalPushPop;
- class LoopBlockPop
- {
- public:
- LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
- ~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
- private:
- cmMakefile* Makefile;
- };
-
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -159,11 +144,6 @@ public:
*/
void FinalPass();
- /**
- * Print the object state to std::cout.
- */
- void Print() const;
-
/** Add a custom command to the build. */
void AddCustomCommandToTarget(const std::string& target,
const std::vector<std::string>& byproducts,
@@ -387,33 +367,13 @@ public:
*/
cmPolicies *GetPolicies() const;
- struct cmCMP0054Id
- {
- cmCMP0054Id(cmListFileContext const& context):
- Context(context)
- {
-
- }
-
- bool operator< (cmCMP0054Id const& id) const
- {
- if(this->Context.FilePath != id.Context.FilePath)
- return this->Context.FilePath < id.Context.FilePath;
-
- return this->Context.Line < id.Context.Line;
- }
-
- cmListFileContext Context;
- };
-
- mutable std::set<cmCMP0054Id> CMP0054ReportedIds;
+ mutable std::set<cmListFileContext> CMP0054ReportedIds;
/**
* Determine if the given context, name pair has already been reported
* in context of CMP0054.
*/
- bool HasCMP0054AlreadyBeenReported(
- cmListFileContext context) const;
+ bool HasCMP0054AlreadyBeenReported() const;
bool IgnoreErrorsCMP0061() const;
@@ -435,14 +395,6 @@ public:
void SetCurrentBinaryDirectory(const std::string& dir);
const char* GetCurrentBinaryDirectory() const;
- /* Get the current CMakeLists.txt file that is being processed. This
- * is just used in order to be able to 'branch' from one file to a second
- * transparently */
- const char* GetCurrentListFile() const
- {
- return this->cmCurrentListFile.c_str();
- }
-
//@}
/**
@@ -605,12 +557,13 @@ public:
{ this->ListFiles.push_back(file);}
void AddCMakeDependFilesFromUser();
- std::string GetListFileStack() const;
+ std::string FormatListFileStack() const;
/**
* Get the current context backtrace.
*/
cmListFileBacktrace GetBacktrace() const;
+ cmListFileContext GetExecutionContext() const;
/**
* Get the vector of files created by this makefile
@@ -859,16 +812,18 @@ protected:
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
// Check for a an unused variable
- void CheckForUnused(const char* reason, const std::string& name) const;
-
- std::string cmCurrentListFile;
+ void LogUnused(const char* reason, const std::string& name) const;
std::string ProjectName; // project name
// libraries, classes, and executables
mutable cmTargets Targets;
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, cmTarget*> TargetMap;
+#else
typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+#endif
#else
typedef std::map<std::string, cmTarget*> TargetMap;
#endif
@@ -924,6 +879,10 @@ private:
cmState::Snapshot StateSnapshot;
+ bool ReadListFile(const char* listfile,
+ bool noPolicyScope,
+ bool requireProjectCommand);
+
bool ReadListFileInternal(const char* filenametoread,
bool noPolicyScope,
bool requireProjectCommand);
@@ -935,10 +894,6 @@ private:
friend class cmMakeDepend; // make depend needs direct access
// to the Sources array
- void PrintStringVector(const char* s, const
- std::vector<std::pair<std::string, bool> >& v) const;
- void PrintStringVector(const char* s,
- const std::vector<std::string>& v) const;
void AddDefaultDefinitions();
typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
@@ -963,7 +918,7 @@ private:
bool CheckSystemVars;
// stack of list files being read
- std::deque<std::string> ListFileStack;
+ std::vector<std::string> ListFileStack;
// stack of commands being invoked.
struct CallStackEntry
@@ -971,7 +926,7 @@ private:
cmListFileContext const* Context;
cmExecutionStatus* Status;
};
- typedef std::deque<CallStackEntry> CallStackType;
+ typedef std::vector<CallStackEntry> CallStackType;
CallStackType CallStack;
friend class cmMakefileCall;
@@ -1041,7 +996,11 @@ private:
// A map for fast output to input look up.
#if defined(CMAKE_BUILD_WITH_CMAKE)
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+ typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap;
+#else
typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap;
+#endif
#else
typedef std::map<std::string, cmSourceFile*> OutputToSourceMap;
#endif
@@ -1070,6 +1029,8 @@ private:
bool HaveCxxStandardAvailable(cmTarget const* target,
const std::string& feature) const;
+ void CheckForUnusedVariables() const;
+
mutable bool SuppressWatches;
};
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index c001622..450f573 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -626,7 +626,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
install_name_dir =
this->LocalGenerator->Convert(install_name_dir,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL, false);
+ cmLocalGenerator::SHELL);
vars.TargetInstallNameDir = install_name_dir.c_str();
}
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 2ee23d1..7b88bc7 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -226,7 +226,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
dependFileNameFull += "/depend.make";
*this->BuildFileStream
<< "# Include any dependencies generated for this target.\n"
- << this->LocalGenerator->IncludeDirective << " " << root
+ << this->GlobalGenerator->IncludeDirective << " " << root
<< this->Convert(dependFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKERULE)
@@ -237,7 +237,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
// Include the progress variables for the target.
*this->BuildFileStream
<< "# Include the progress variables for this target.\n"
- << this->LocalGenerator->IncludeDirective << " " << root
+ << this->GlobalGenerator->IncludeDirective << " " << root
<< this->Convert(this->ProgressFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKERULE)
@@ -270,7 +270,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
// Include the flags for the target.
*this->BuildFileStream
<< "# Include the compile flags for this target's objects.\n"
- << this->LocalGenerator->IncludeDirective << " " << root
+ << this->GlobalGenerator->IncludeDirective << " " << root
<< this->Convert(this->FlagFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKERULE)
@@ -761,6 +761,20 @@ cmMakefileTargetGenerator
source.GetFullPath(), workingDirectory, compileCommand);
}
+ // Maybe insert an include-what-you-use runner.
+ if (!compileCommands.empty() && (lang == "C" || lang == "CXX"))
+ {
+ std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
+ const char *iwyu = this->Target->GetProperty(iwyu_prop);
+ if (iwyu && *iwyu)
+ {
+ std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu --iwyu=";
+ run_iwyu += this->LocalGenerator->EscapeForShell(iwyu);
+ run_iwyu += " -- ";
+ compileCommands.front().insert(0, run_iwyu);
+ }
+ }
+
// Expand placeholders in the commands.
for(std::vector<std::string>::iterator i = compileCommands.begin();
i != compileCommands.end(); ++i)
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 617214f..25d929c 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -51,7 +51,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Include the progress variables for the target.
*this->BuildFileStream
<< "# Include the progress variables for this target.\n"
- << this->LocalGenerator->IncludeDirective << " " << root
+ << this->GlobalGenerator->IncludeDirective << " " << root
<< this->Convert(this->ProgressFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKERULE)
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 771ecc4..bbf03ff 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -94,8 +94,6 @@ void cmNinjaNormalTargetGenerator::Generate()
}
else
{
- this->WriteLinkRule(false); // write rule without rspfile support
- this->WriteLinkRule(true); // write rule with rspfile support
this->WriteLinkStatement();
}
}
@@ -160,7 +158,9 @@ cmNinjaNormalTargetGenerator
return this->TargetLinkLanguage
+ "_"
+ cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
- + "_LINKER";
+ + "_LINKER__"
+ + cmGlobalNinjaGenerator::EncodeRuleName(this->GetTarget()->GetName())
+ ;
}
void
@@ -169,8 +169,6 @@ cmNinjaNormalTargetGenerator
{
cmTarget::TargetType targetType = this->GetTarget()->GetType();
std::string ruleName = this->LanguageLinkerRule();
- if (useResponseFile)
- ruleName += "_RSP_FILE";
// Select whether to use a response file for objects.
std::string rspfile;
@@ -284,8 +282,7 @@ cmNinjaNormalTargetGenerator
!this->GetTarget()->IsFrameworkOnApple()) {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
- cmLocalGenerator::SHELL);
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
if (targetType == cmTarget::EXECUTABLE)
this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE",
cmakeCommand +
@@ -339,8 +336,7 @@ cmNinjaNormalTargetGenerator
{
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
- mf->GetRequiredDefinition("CMAKE_COMMAND"),
- cmLocalGenerator::SHELL);
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
}
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
@@ -529,8 +525,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
{
vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL,
- false);
+ cmLocalGenerator::SHELL);
}
}
}
@@ -661,6 +656,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
// Write the build statement for this target.
+ bool usedResponseFile = false;
globalGen.WriteBuild(this->GetBuildFileStream(),
comment.str(),
this->LanguageLinkerRule(),
@@ -670,7 +666,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
orderOnlyDeps,
vars,
rspfile,
- commandLineLengthLimit);
+ commandLineLengthLimit,
+ &usedResponseFile);
+ this->WriteLinkRule(usedResponseFile);
if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple())
{
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 128a35b..879d6b7 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -97,6 +97,13 @@ std::string const& cmNinjaTargetGenerator::GetConfigName() const
return this->LocalGenerator->GetConfigName();
}
+std::string cmNinjaTargetGenerator::LanguageCompilerRule(
+ const std::string& lang) const
+{
+ return lang + "_COMPILER__" +
+ cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName());
+}
+
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
{
@@ -451,6 +458,23 @@ cmNinjaTargetGenerator
std::vector<std::string> compileCmds;
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+ // Maybe insert an include-what-you-use runner.
+ if (!compileCmds.empty() && (lang == "C" || lang == "CXX"))
+ {
+ std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
+ const char *iwyu = this->Target->GetProperty(iwyu_prop);
+ if (iwyu && *iwyu)
+ {
+ std::string run_iwyu =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
+ run_iwyu += " -E __run_iwyu --iwyu=";
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+ run_iwyu += " -- ";
+ compileCmds.front().insert(0, run_iwyu);
+ }
+ }
+
if (!compileCmds.empty())
{
compileCmds.front().insert(0, cldeps);
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 5733fde..4e7d8b3 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -67,8 +67,7 @@ protected:
std::string const& GetConfigName() const;
- std::string LanguageCompilerRule(const std::string& lang) const
- { return lang + "_COMPILER"; }
+ std::string LanguageCompilerRule(const std::string& lang) const;
const char* GetFeature(const std::string& feature);
bool GetFeatureAsBool(const std::string& feature);
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index eb56494..00d857a 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -214,6 +214,9 @@ class cmPolicy;
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0062, \
"Disallow install() of export() result.", \
+ 3, 3, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0063, \
+ "Honor visibility properties for all target types.", \
3, 3, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 457de11..cbb06cd 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -20,7 +20,7 @@
#include "cmAlgorithms.h"
#if defined(_WIN32) && !defined(__CYGWIN__)
-# include "cmLocalVisualStudioGenerator.h"
+# include "cmGlobalVisualStudioGenerator.h"
#endif
#include <sys/stat.h>
@@ -320,7 +320,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
std::string targetDir = getAutogenTargetDir(target);
cmCustomCommandLine currentLine;
- currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND"));
+ currentLine.push_back(cmSystemTools::GetCMakeCommand());
currentLine.push_back("-E");
currentLine.push_back("cmake_autogen");
currentLine.push_back(targetDir);
@@ -372,13 +372,13 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
cmGlobalGenerator* gg = localGen->GetGlobalGenerator();
if(gg->GetName().find("Visual Studio") != std::string::npos)
{
- cmLocalVisualStudioGenerator* vslg =
- static_cast<cmLocalVisualStudioGenerator*>(localGen);
+ cmGlobalVisualStudioGenerator* vsgg =
+ static_cast<cmGlobalVisualStudioGenerator*>(gg);
// Under VS >= 7 use a PRE_BUILD event instead of a separate target to
// reduce the number of targets loaded into the IDE.
// This also works around a VS 11 bug that may skip updating the target:
// https://connect.microsoft.com/VisualStudio/feedback/details/769495
- usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7;
+ usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
if(usePRE_BUILD)
{
for (std::vector<std::string>::iterator it = depends.begin();
@@ -1203,23 +1203,6 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target)
return std::string();
}
-static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
- const std::string& targetDirectory)
-{
- cmGlobalGenerator* gg = new cmGlobalGenerator();
- gg->SetCMakeInstance(cm);
-
- cm->SetHomeOutputDirectory(targetDirectory);
- cm->SetHomeDirectory(targetDirectory);
-
- cmLocalGenerator* lg = gg->CreateLocalGenerator();
- lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
- lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
- gg->SetCurrentLocalGenerator(lg);
-
- return gg;
-}
-
bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
const std::string& config)
{
@@ -1227,25 +1210,26 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
cmake cm;
cm.SetHomeOutputDirectory(targetDirectory);
cm.SetHomeDirectory(targetDirectory);
- cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory);
- cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile();
+ cmGlobalGenerator gg(&cm);
+
+ cmLocalGenerator* lg = gg.MakeLocalGenerator();
+ lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
+ lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
+ gg.SetCurrentLocalGenerator(lg);
- this->ReadAutogenInfoFile(makefile, targetDirectory, config);
- this->ReadOldMocDefinitionsFile(makefile, targetDirectory);
+ this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config);
+ this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory);
this->Init();
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
{
- success = this->RunAutogen(makefile);
+ success = this->RunAutogen(lg->GetMakefile());
}
this->WriteOldMocDefinitionsFile(targetDirectory);
- delete gg->GetCurrentLocalGenerator();
- delete gg;
- gg = NULL;
- makefile = NULL;
+ delete lg;
return success;
}
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 82a2939..58885d3 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -20,9 +20,14 @@
cmState::cmState(cmake* cm)
: CMakeInstance(cm),
- IsInTryCompile(false)
+ IsInTryCompile(false),
+ WindowsShell(false),
+ WindowsVSIDE(false),
+ WatcomWMake(false),
+ MinGWMake(false),
+ NMake(false),
+ MSYSShell(false)
{
- this->Initialize();
}
cmState::~cmState()
@@ -190,15 +195,35 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
}
-void cmState::Initialize()
+void cmState::Reset()
{
this->GlobalProperties.clear();
this->PropertyDefinitions.clear();
- this->Locations.clear();
- this->OutputLocations.clear();
- this->ParentPositions.clear();
- this->CreateSnapshot(Snapshot());
+ assert(this->Locations.size() > 0);
+ assert(this->OutputLocations.size() > 0);
+ assert(this->ParentPositions.size() > 0);
+ assert(this->CurrentSourceDirectoryComponents.size() > 0);
+ assert(this->CurrentBinaryDirectoryComponents.size() > 0);
+ assert(this->RelativePathTopSource.size() > 0);
+ assert(this->RelativePathTopBinary.size() > 0);
+
+ this->Locations.erase(this->Locations.begin() + 1, this->Locations.end());
+ this->OutputLocations.erase(this->OutputLocations.begin() + 1,
+ this->OutputLocations.end());
+ this->ParentPositions.erase(this->ParentPositions.begin() + 1,
+ this->ParentPositions.end());
+ this->CurrentSourceDirectoryComponents.erase(
+ this->CurrentSourceDirectoryComponents.begin() + 1,
+ this->CurrentSourceDirectoryComponents.end());
+ this->CurrentBinaryDirectoryComponents.erase(
+ this->CurrentBinaryDirectoryComponents.begin() + 1,
+ this->CurrentBinaryDirectoryComponents.end());
+ this->RelativePathTopSource.erase(this->RelativePathTopSource.begin() + 1,
+ this->RelativePathTopSource.end());
+ this->RelativePathTopBinary.erase(this->RelativePathTopBinary.begin() + 1,
+ this->RelativePathTopBinary.end());
+
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
"", "", true);
@@ -458,6 +483,10 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory)
{
this->SourceDirectory = sourceDirectory;
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
+
+ cmSystemTools::SplitPath(
+ cmSystemTools::CollapseFullPath(this->SourceDirectory),
+ this->SourceDirectoryComponents);
}
const char* cmState::GetSourceDirectory() const
@@ -465,10 +494,79 @@ const char* cmState::GetSourceDirectory() const
return this->SourceDirectory.c_str();
}
+std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const
+{
+ return this->SourceDirectoryComponents;
+}
+
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
{
this->BinaryDirectory = binaryDirectory;
cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
+
+ cmSystemTools::SplitPath(
+ cmSystemTools::CollapseFullPath(this->BinaryDirectory),
+ this->BinaryDirectoryComponents);
+}
+
+void cmState::SetWindowsShell(bool windowsShell)
+{
+ this->WindowsShell = windowsShell;
+}
+
+bool cmState::UseWindowsShell() const
+{
+ return this->WindowsShell;
+}
+
+void cmState::SetWindowsVSIDE(bool windowsVSIDE)
+{
+ this->WindowsVSIDE = windowsVSIDE;
+}
+
+bool cmState::UseWindowsVSIDE() const
+{
+ return this->WindowsVSIDE;
+}
+
+void cmState::SetWatcomWMake(bool watcomWMake)
+{
+ this->WatcomWMake = watcomWMake;
+}
+
+bool cmState::UseWatcomWMake() const
+{
+ return this->WatcomWMake;
+}
+
+void cmState::SetMinGWMake(bool minGWMake)
+{
+ this->MinGWMake = minGWMake;
+}
+
+bool cmState::UseMinGWMake() const
+{
+ return this->MinGWMake;
+}
+
+void cmState::SetNMake(bool nMake)
+{
+ this->NMake = nMake;
+}
+
+bool cmState::UseNMake() const
+{
+ return this->NMake;
+}
+
+void cmState::SetMSYSShell(bool mSYSShell)
+{
+ this->MSYSShell = mSYSShell;
+}
+
+bool cmState::UseMSYSShell() const
+{
+ return this->MSYSShell;
}
const char* cmState::GetBinaryDirectory() const
@@ -476,12 +574,107 @@ const char* cmState::GetBinaryDirectory() const
return this->BinaryDirectory.c_str();
}
+std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
+{
+ return this->BinaryDirectoryComponents;
+}
+
+void cmState::Snapshot::ComputeRelativePathTopSource()
+{
+ // Relative path conversion inside the source tree is not used to
+ // construct relative paths passed to build tools so it is safe to use
+ // even when the source is a network path.
+
+ cmState::Snapshot snapshot = *this;
+ std::vector<cmState::Snapshot> snapshots;
+ snapshots.push_back(snapshot);
+ while (true)
+ {
+ snapshot = snapshot.GetParent();
+ if (snapshot.IsValid())
+ {
+ snapshots.push_back(snapshot);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ std::string result = snapshots.front().GetCurrentSourceDirectory();
+
+ for (std::vector<cmState::Snapshot>::const_iterator it =
+ snapshots.begin() + 1; it != snapshots.end(); ++it)
+ {
+ std::string currentSource = it->GetCurrentSourceDirectory();
+ if(cmSystemTools::IsSubDirectory(result, currentSource))
+ {
+ result = currentSource;
+ }
+ }
+ this->State->RelativePathTopSource[this->Position] = result;
+}
+
+void cmState::Snapshot::ComputeRelativePathTopBinary()
+{
+ cmState::Snapshot snapshot = *this;
+ std::vector<cmState::Snapshot> snapshots;
+ snapshots.push_back(snapshot);
+ while (true)
+ {
+ snapshot = snapshot.GetParent();
+ if (snapshot.IsValid())
+ {
+ snapshots.push_back(snapshot);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ std::string result =
+ snapshots.front().GetCurrentBinaryDirectory();
+
+ for (std::vector<cmState::Snapshot>::const_iterator it =
+ snapshots.begin() + 1; it != snapshots.end(); ++it)
+ {
+ std::string currentBinary = it->GetCurrentBinaryDirectory();
+ if(cmSystemTools::IsSubDirectory(result, currentBinary))
+ {
+ result = currentBinary;
+ }
+ }
+
+ // The current working directory on Windows cannot be a network
+ // path. Therefore relative paths cannot work when the binary tree
+ // is a network path.
+ if(result.size() < 2 || result.substr(0, 2) != "//")
+ {
+ this->State->RelativePathTopBinary[this->Position] = result;
+ }
+ else
+ {
+ this->State->RelativePathTopBinary[this->Position] = "";
+ }
+}
+
cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
{
+ if (!originSnapshot.IsValid())
+ {
+ originSnapshot.State = this;
+ }
PositionType pos = this->ParentPositions.size();
this->ParentPositions.push_back(originSnapshot.Position);
this->Locations.resize(this->Locations.size() + 1);
this->OutputLocations.resize(this->OutputLocations.size() + 1);
+ this->CurrentSourceDirectoryComponents.resize(
+ this->CurrentSourceDirectoryComponents.size() + 1);
+ this->CurrentBinaryDirectoryComponents.resize(
+ this->CurrentBinaryDirectoryComponents.size() + 1);
+ this->RelativePathTopSource.resize(this->RelativePathTopSource.size() + 1);
+ this->RelativePathTopBinary.resize(this->RelativePathTopBinary.size() + 1);
return cmState::Snapshot(this, pos);
}
@@ -499,12 +692,18 @@ const char* cmState::Snapshot::GetCurrentSourceDirectory() const
void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
{
+ assert(this->State);
assert(this->State->Locations.size() > this->Position);
this->State->Locations[this->Position] = dir;
cmSystemTools::ConvertToUnixSlashes(
this->State->Locations[this->Position]);
this->State->Locations[this->Position] =
cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
+
+ cmSystemTools::SplitPath(
+ this->State->Locations[this->Position],
+ this->State->CurrentSourceDirectoryComponents[this->Position]);
+ this->ComputeRelativePathTopSource();
}
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@@ -521,6 +720,43 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
this->State->OutputLocations[this->Position] =
cmSystemTools::CollapseFullPath(
this->State->OutputLocations[this->Position]);
+
+ cmSystemTools::SplitPath(
+ this->State->OutputLocations[this->Position],
+ this->State->CurrentBinaryDirectoryComponents[this->Position]);
+ this->ComputeRelativePathTopBinary();
+}
+
+std::vector<std::string> const&
+cmState::Snapshot::GetCurrentSourceDirectoryComponents()
+{
+ return this->State->CurrentSourceDirectoryComponents[this->Position];
+}
+
+std::vector<std::string> const&
+cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
+{
+ return this->State->CurrentBinaryDirectoryComponents[this->Position];
+}
+
+const char* cmState::Snapshot::GetRelativePathTopSource() const
+{
+ return this->State->RelativePathTopSource[this->Position].c_str();
+}
+
+const char* cmState::Snapshot::GetRelativePathTopBinary() const
+{
+ return this->State->RelativePathTopBinary[this->Position].c_str();
+}
+
+void cmState::Snapshot::SetRelativePathTopSource(const char* dir)
+{
+ this->State->RelativePathTopSource[this->Position] = dir;
+}
+
+void cmState::Snapshot::SetRelativePathTopBinary(const char* dir)
+{
+ this->State->RelativePathTopBinary[this->Position] = dir;
}
bool cmState::Snapshot::IsValid() const
@@ -531,15 +767,12 @@ bool cmState::Snapshot::IsValid() const
cmState::Snapshot cmState::Snapshot::GetParent() const
{
Snapshot snapshot;
- if (!this->State)
+ if (!this->State || this->Position == 0)
{
return snapshot;
}
PositionType parentPos = this->State->ParentPositions[this->Position];
- if (parentPos > 0)
- {
- snapshot = Snapshot(this->State, parentPos);
- }
+ snapshot = Snapshot(this->State, parentPos);
return snapshot;
}
diff --git a/Source/cmState.h b/Source/cmState.h
index ed58c64..77a066f 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -36,10 +36,22 @@ public:
const char* GetCurrentBinaryDirectory() const;
void SetCurrentBinaryDirectory(std::string const& dir);
+ std::vector<std::string> const& GetCurrentSourceDirectoryComponents();
+ std::vector<std::string> const& GetCurrentBinaryDirectoryComponents();
+
+ const char* GetRelativePathTopSource() const;
+ const char* GetRelativePathTopBinary() const;
+ void SetRelativePathTopSource(const char* dir);
+ void SetRelativePathTopBinary(const char* dir);
+
bool IsValid() const;
Snapshot GetParent() const;
private:
+ void ComputeRelativePathTopSource();
+ void ComputeRelativePathTopBinary();
+
+ private:
friend class cmState;
cmState* State;
cmState::PositionType Position;
@@ -81,7 +93,7 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName);
- void Initialize();
+ void Reset();
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
@@ -123,6 +135,22 @@ public:
const char* GetBinaryDirectory() const;
void SetBinaryDirectory(std::string const& binaryDirectory);
+ std::vector<std::string> const& GetSourceDirectoryComponents() const;
+ std::vector<std::string> const& GetBinaryDirectoryComponents() const;
+
+ void SetWindowsShell(bool windowsShell);
+ bool UseWindowsShell() const;
+ void SetWindowsVSIDE(bool windowsVSIDE);
+ bool UseWindowsVSIDE() const;
+ void SetWatcomWMake(bool watcomWMake);
+ bool UseWatcomWMake() const;
+ void SetMinGWMake(bool minGWMake);
+ bool UseMinGWMake() const;
+ void SetNMake(bool nMake);
+ bool UseNMake() const;
+ void SetMSYSShell(bool mSYSShell);
+ bool UseMSYSShell() const;
+
private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
@@ -132,9 +160,28 @@ private:
std::vector<std::string> Locations;
std::vector<std::string> OutputLocations;
std::vector<PositionType> ParentPositions;
+
+ std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents;
+ std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents;
+ // The top-most directories for relative path conversion. Both the
+ // source and destination location of a relative path conversion
+ // must be underneath one of these directories (both under source or
+ // both under binary) in order for the relative path to be evaluated
+ // safely by the build tools.
+ std::vector<std::string> RelativePathTopSource;
+ std::vector<std::string> RelativePathTopBinary;
+
+ std::vector<std::string> SourceDirectoryComponents;
+ std::vector<std::string> BinaryDirectoryComponents;
std::string SourceDirectory;
std::string BinaryDirectory;
bool IsInTryCompile;
+ bool WindowsShell;
+ bool WindowsVSIDE;
+ bool WatcomWMake;
+ bool MinGWMake;
+ bool NMake;
+ bool MSYSShell;
};
#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 8a8c163..70005b4 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -333,9 +333,11 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("MACOSX_BUNDLE", 0);
this->SetPropertyDefault("MACOSX_RPATH", 0);
this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+ this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", 0);
this->SetPropertyDefault("C_STANDARD", 0);
this->SetPropertyDefault("C_STANDARD_REQUIRED", 0);
this->SetPropertyDefault("C_EXTENSIONS", 0);
+ this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", 0);
this->SetPropertyDefault("CXX_STANDARD", 0);
this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0);
this->SetPropertyDefault("CXX_EXTENSIONS", 0);
@@ -1239,8 +1241,11 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature)
ret = false;
}
}
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->TLLCommands.push_back(std::make_pair(signature, lfbt));
+ cmListFileContext lfc = this->Makefile->GetExecutionContext();
+ if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc)
+ {
+ this->TLLCommands.push_back(std::make_pair(signature, lfc));
+ }
return ret;
}
@@ -1248,39 +1253,19 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature)
void cmTarget::GetTllSignatureTraces(std::ostringstream &s,
TLLSignature sig) const
{
- std::vector<cmListFileBacktrace> sigs;
- typedef std::vector<std::pair<TLLSignature, cmListFileBacktrace> > Container;
+ const char *sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword"
+ : "plain");
+ s << "The uses of the " << sigString << " signature are here:\n";
+ typedef std::vector<std::pair<TLLSignature, cmListFileContext> > Container;
+ cmLocalGenerator* lg = this->GetMakefile()->GetLocalGenerator();
for(Container::const_iterator it = this->TLLCommands.begin();
it != this->TLLCommands.end(); ++it)
{
if (it->first == sig)
{
- sigs.push_back(it->second);
- }
- }
- if (!sigs.empty())
- {
- const char *sigString
- = (sig == cmTarget::KeywordTLLSignature ? "keyword"
- : "plain");
- s << "The uses of the " << sigString << " signature are here:\n";
- UNORDERED_SET<std::string> emitted;
- for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin();
- it != sigs.end(); ++it)
- {
- it->MakeRelative();
- cmListFileBacktrace::const_iterator i = it->begin();
- if(i != it->end())
- {
- cmListFileContext const& lfc = *i;
- std::ostringstream line;
- line << " * " << (lfc.Line? "": " in ") << lfc << std::endl;
- if (emitted.insert(line.str()).second)
- {
- s << line.str();
- }
- ++i;
- }
+ cmListFileContext lfc = it->second;
+ lfc.FilePath = lg->Convert(lfc.FilePath, cmLocalGenerator::HOME);
+ s << " * " << lfc << std::endl;
}
}
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a032414..2150b83 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -19,7 +19,11 @@
#include <cmsys/auto_ptr.hxx>
#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_map.hxx>
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+# include <unordered_map>
+# else
+# include <cmsys/hash_map.hxx>
+# endif
#endif
#define CM_FOR_EACH_TARGET_POLICY(F) \
@@ -35,7 +39,8 @@
F(CMP0042) \
F(CMP0046) \
F(CMP0052) \
- F(CMP0060)
+ F(CMP0060) \
+ F(CMP0063)
class cmake;
class cmMakefile;
@@ -641,7 +646,7 @@ private:
// directories.
std::set<std::string> SystemIncludeDirectories;
- std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;
+ std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands;
#if defined(_WIN32) && !defined(__CYGWIN__)
/**
@@ -849,7 +854,11 @@ private:
};
#ifdef CMAKE_BUILD_WITH_CMAKE
-typedef cmsys::hash_map<std::string,cmTarget> cmTargets;
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+typedef std::unordered_map<std::string, cmTarget> cmTargets;
+#else
+typedef cmsys::hash_map<std::string, cmTarget> cmTargets;
+#endif
#else
typedef std::map<std::string,cmTarget> cmTargets;
#endif
diff --git a/Source/cmTest.h b/Source/cmTest.h
index c6e7e42..ca88afe 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -40,11 +40,6 @@ public:
return this->Command;
}
- /**
- * Print the structure to std::cout.
- */
- void Print() const;
-
///! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop,
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 3cd92cb..b9ffe5e 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -375,7 +375,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
comment += "Run arguments : ";
comment += runArgs;
comment += "\n";
- comment += " Called from: " + this->Makefile->GetListFileStack();
+ comment += " Called from: " + this->Makefile->FormatListFileStack();
cmsys::SystemTools::ReplaceString(comment, "\n", "\n# ");
file << comment << "\n\n";
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 131a134..5dfdb14 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -47,13 +47,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
{
if(this->MSTools)
{
- cmLocalVisualStudioGenerator::VSVersion
+ cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
- if(v >= cmLocalVisualStudioGenerator::VS14)
+ if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14CLFlagTable; }
- else if(v >= cmLocalVisualStudioGenerator::VS12)
+ else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12CLFlagTable; }
- else if(v == cmLocalVisualStudioGenerator::VS11)
+ else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11CLFlagTable; }
else
{ return cmVS10CLFlagTable; }
@@ -65,13 +65,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const
{
if(this->MSTools)
{
- cmLocalVisualStudioGenerator::VSVersion
+ cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
- if(v >= cmLocalVisualStudioGenerator::VS14)
+ if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14RCFlagTable; }
- else if(v >= cmLocalVisualStudioGenerator::VS12)
+ else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12RCFlagTable; }
- else if(v == cmLocalVisualStudioGenerator::VS11)
+ else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11RCFlagTable; }
else
{ return cmVS10RCFlagTable; }
@@ -83,13 +83,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
{
if(this->MSTools)
{
- cmLocalVisualStudioGenerator::VSVersion
+ cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
- if(v >= cmLocalVisualStudioGenerator::VS14)
+ if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14LibFlagTable; }
- else if(v >= cmLocalVisualStudioGenerator::VS12)
+ else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12LibFlagTable; }
- else if(v == cmLocalVisualStudioGenerator::VS11)
+ else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11LibFlagTable; }
else
{ return cmVS10LibFlagTable; }
@@ -101,13 +101,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
{
if(this->MSTools)
{
- cmLocalVisualStudioGenerator::VSVersion
+ cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
- if(v >= cmLocalVisualStudioGenerator::VS14)
+ if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14LinkFlagTable; }
- else if(v >= cmLocalVisualStudioGenerator::VS12)
+ else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12LinkFlagTable; }
- else if(v == cmLocalVisualStudioGenerator::VS11)
+ else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11LinkFlagTable; }
else
{ return cmVS10LinkFlagTable; }
@@ -119,13 +119,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const
{
if(this->MSTools)
{
- cmLocalVisualStudioGenerator::VSVersion
+ cmGlobalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
- if(v >= cmLocalVisualStudioGenerator::VS14)
+ if(v >= cmGlobalVisualStudioGenerator::VS14)
{ return cmVS14MASMFlagTable; }
- else if(v >= cmLocalVisualStudioGenerator::VS12)
+ else if(v >= cmGlobalVisualStudioGenerator::VS12)
{ return cmVS12MASMFlagTable; }
- else if(v == cmLocalVisualStudioGenerator::VS11)
+ else if(v == cmGlobalVisualStudioGenerator::VS11)
{ return cmVS11MASMFlagTable; }
else
{ return cmVS10MASMFlagTable; }
@@ -173,6 +173,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
this->Target = target;
this->GeneratorTarget = gg->GetGeneratorTarget(target);
this->Makefile = target->GetMakefile();
+ this->Makefile->GetConfigurations(this->Configurations);
this->LocalGenerator =
(cmLocalVisualStudio7Generator*)
this->Makefile->GetLocalGenerator();
@@ -525,10 +526,9 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
(*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
- std::vector<std::string> const * configs =
- this->GlobalGenerator->GetConfigurations();
- for(std::vector<std::string>::const_iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
this->WritePlatformConfigTag("LogicalName", i->c_str(), 3);
if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE"))
@@ -629,11 +629,9 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
{
this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
this->WriteString("<ProjectConfiguration Include=\"", 2);
(*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n";
@@ -649,11 +647,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
this->WritePlatformConfigTag("PropertyGroup",
i->c_str(),
@@ -864,14 +860,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
}
}
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
this->WriteSource("CustomBuild", source, ">\n");
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
std::string comment = lg->ConstructComment(ccg);
@@ -911,7 +905,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
sep = ";";
}
(*this->BuildFileStream ) << "</Outputs>\n";
- if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
+ if(this->LocalGenerator->GetVersion()
+ > cmGlobalVisualStudioGenerator::VS10)
{
// VS >= 11 let us turn off linking of custom command outputs.
this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
@@ -1339,8 +1334,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
if(!deployContent.empty())
{
- std::vector<std::string> const* configs =
- this->GlobalGenerator->GetConfigurations();
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent);
@@ -1352,13 +1345,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
<< "\\%(FileName)%(Extension)";
this->WriteString("</Link>\n", 0);
}
- for(size_t i = 0; i != configs->size(); ++i)
+ for(size_t i = 0; i != this->Configurations.size(); ++i)
{
- if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1"))
+ if(0 == strcmp(cge->Evaluate(this->Makefile,
+ this->Configurations[i]), "1"))
{
this->WriteString("<DeploymentContent Condition=\""
"'$(Configuration)|$(Platform)'=='", 3);
- (*this->BuildFileStream) << (*configs)[i] << "|"
+ (*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">true";
this->WriteString("</DeploymentContent>\n", 0);
}
@@ -1366,7 +1360,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
{
this->WriteString("<ExcludedFromBuild Condition=\""
"'$(Configuration)|$(Platform)'=='", 3);
- (*this->BuildFileStream) << (*configs)[i] << "|"
+ (*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">true";
this->WriteString("</ExcludedFromBuild>\n", 0);
}
@@ -1416,7 +1410,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(
// conversion uses full paths when possible to allow deeper trees.
bool forceRelative = false;
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
- if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10
+ if(this->LocalGenerator->GetVersion() == cmGlobalVisualStudioGenerator::VS10
&& cmSystemTools::FileIsFullPath(sourceFile.c_str()))
{
// Normal path conversion resulted in a full path. VS 10 (but not 11)
@@ -1544,7 +1538,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
++si;
}
}
- if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
+ if(this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10)
{
// For VS >= 11 we use LinkObjects to avoid linking custom command
// outputs. Use Object for all external objects, generated or not.
@@ -1654,11 +1648,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
(*this->BuildFileStream )
<< "$(IntDir)/" << objectName << "</ObjectFileName>\n";
}
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
- for( std::vector<std::string>::iterator config = configs->begin();
- config != configs->end(); ++config)
+ for(std::vector<std::string>::const_iterator
+ config = this->Configurations.begin();
+ config != this->Configurations.end(); ++config)
{
std::string configUpper = cmSystemTools::UpperCase(*config);
std::string configDefines = defines;
@@ -1736,11 +1728,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
this->WriteString("<PropertyGroup>\n", 2);
this->WriteString("<_ProjectFileVersion>10.0.20506.1"
"</_ProjectFileVersion>\n", 3);
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
- for(std::vector<std::string>::iterator config = configs->begin();
- config != configs->end(); ++config)
+ for(std::vector<std::string>::const_iterator
+ config = this->Configurations.begin();
+ config != this->Configurations.end(); ++config)
{
if(ttype >= cmTarget::UTILITY)
{
@@ -1854,10 +1844,9 @@ OutputLinkIncremental(std::string const& configName)
//----------------------------------------------------------------------------
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{
- std::vector<std::string> const* configs =
- this->GlobalGenerator->GetConfigurations();
- for(std::vector<std::string>::const_iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
if(!this->ComputeClOptions(*i))
{
@@ -2025,10 +2014,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
//----------------------------------------------------------------------------
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
{
- std::vector<std::string> const* configs =
- this->GlobalGenerator->GetConfigurations();
- for(std::vector<std::string>::const_iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
if(!this->ComputeRcOptions(*i))
{
@@ -2091,10 +2079,9 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
{
return true;
}
- std::vector<std::string> const* configs =
- this->GlobalGenerator->GetConfigurations();
- for(std::vector<std::string>::const_iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
if(!this->ComputeMasmOptions(*i))
{
@@ -2238,10 +2225,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
this->Target->GetType() == cmTarget::MODULE_LIBRARY)
{
- std::vector<std::string> const* configs =
- this->GlobalGenerator->GetConfigurations();
- for(std::vector<std::string>::const_iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
if(!this->ComputeLinkOptions(*i))
{
@@ -2590,11 +2576,9 @@ WriteMidlOptions(std::string const& /*config*/,
void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
{
- std::vector<std::string> *configs =
- static_cast<cmGlobalVisualStudio7Generator *>
- (this->GlobalGenerator)->GetConfigurations();
- for(std::vector<std::string>::iterator i = configs->begin();
- i != configs->end(); ++i)
+ for(std::vector<std::string>::const_iterator
+ i = this->Configurations.begin();
+ i != this->Configurations.end(); ++i)
{
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes,
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index a2776de..451f8b2 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -137,6 +137,7 @@ private:
OptionsMap MasmOptions;
OptionsMap LinkOptions;
std::string PathToVcxproj;
+ std::vector<std::string> Configurations;
cmTarget* Target;
cmGeneratorTarget* GeneratorTarget;
cmMakefile* Makefile;
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 00386f6..6512fc2 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -96,14 +96,14 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
// remove the flag we need to override the IDE default of on.
switch (this->Version)
{
- case cmLocalVisualStudioGenerator::VS7:
- case cmLocalVisualStudioGenerator::VS71:
+ case cmGlobalVisualStudioGenerator::VS7:
+ case cmGlobalVisualStudioGenerator::VS71:
this->FlagMap["ExceptionHandling"] = "FALSE";
break;
- case cmLocalVisualStudioGenerator::VS10:
- case cmLocalVisualStudioGenerator::VS11:
- case cmLocalVisualStudioGenerator::VS12:
- case cmLocalVisualStudioGenerator::VS14:
+ case cmGlobalVisualStudioGenerator::VS10:
+ case cmGlobalVisualStudioGenerator::VS11:
+ case cmGlobalVisualStudioGenerator::VS12:
+ case cmGlobalVisualStudioGenerator::VS14:
// by default VS puts <ExceptionHandling></ExceptionHandling> empty
// for a project, to make our projects look the same put a new line
// and space over for the closing </ExceptionHandling> as the default
@@ -132,7 +132,7 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose)
this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end())
{
this->FlagMap["SuppressStartupBanner"] =
- this->Version < cmLocalVisualStudioGenerator::VS10 ? "FALSE" : "";
+ this->Version < cmGlobalVisualStudioGenerator::VS10 ? "FALSE" : "";
}
}
@@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions
{
return;
}
- if(this->Version >= cmLocalVisualStudioGenerator::VS10)
+ if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{
// if there are configuration specific flags, then
// use the configuration specific tag for PreprocessorDefinitions
@@ -298,7 +298,7 @@ cmVisualStudioGeneratorOptions
{
// Escape the definition for the compiler.
std::string define;
- if(this->Version < cmLocalVisualStudioGenerator::VS10)
+ if(this->Version < cmGlobalVisualStudioGenerator::VS10)
{
define =
this->LocalGenerator->EscapeForShell(di->c_str(), true);
@@ -308,7 +308,7 @@ cmVisualStudioGeneratorOptions
define = *di;
}
// Escape this flag for the IDE.
- if(this->Version >= cmLocalVisualStudioGenerator::VS10)
+ if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define);
@@ -325,7 +325,7 @@ cmVisualStudioGeneratorOptions
fout << sep << define;
sep = ";";
}
- if(this->Version >= cmLocalVisualStudioGenerator::VS10)
+ if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{
fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix;
}
@@ -340,7 +340,7 @@ void
cmVisualStudioGeneratorOptions
::OutputFlagMap(std::ostream& fout, const char* indent)
{
- if(this->Version >= cmLocalVisualStudioGenerator::VS10)
+ if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{
for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
@@ -395,7 +395,7 @@ cmVisualStudioGeneratorOptions
{
if(!this->FlagString.empty())
{
- if(this->Version >= cmLocalVisualStudioGenerator::VS10)
+ if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{
fout << prefix;
if(this->Configuration.size())
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 5490a43..0179134 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -73,7 +73,7 @@ public:
void SetConfiguration(const char* config);
private:
cmLocalVisualStudioGenerator* LocalGenerator;
- cmLocalVisualStudioGenerator::VSVersion Version;
+ cmGlobalVisualStudioGenerator::VSVersion Version;
std::string Configuration;
Tool CurrentTool;
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 5170ead..012c580 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -12,6 +12,17 @@
#include "cmWhileCommand.h"
#include "cmConditionEvaluator.h"
+cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf):
+ Makefile(mf), Depth(0)
+{
+ this->Makefile->PushLoopBlock();
+}
+
+cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
+{
+ this->Makefile->PopLoopBlock();
+}
+
bool cmWhileFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus)
@@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endwhile for this while loop then execute
if (!this->Depth)
{
- cmMakefile::LoopBlockPop loopBlockPop(&mf);
-
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -140,12 +149,10 @@ bool cmWhileCommand
}
// create a function blocker
- cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker();
+ cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile);
f->Args = args;
this->Makefile->AddFunctionBlocker(f);
- this->Makefile->PushLoopBlock();
-
return true;
}
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 9fafffc..85a0bd3 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -19,8 +19,8 @@
class cmWhileFunctionBlocker : public cmFunctionBlocker
{
public:
- cmWhileFunctionBlocker() {this->Depth=0;}
- virtual ~cmWhileFunctionBlocker() {}
+ cmWhileFunctionBlocker(cmMakefile* mf);
+ ~cmWhileFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf,
cmExecutionStatus &);
@@ -29,6 +29,7 @@ public:
std::vector<cmListFileArgument> Args;
std::vector<cmListFileFunction> Functions;
private:
+ cmMakefile* Makefile;
int Depth;
};
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
new file mode 100644
index 0000000..f9b3b49
--- /dev/null
+++ b/Source/cmXMLWriter.cxx
@@ -0,0 +1,134 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2015 Daniel Pfeifer <daniel@pfeifer-mail.de>
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmXMLWriter.h"
+#include "cmXMLSafe.h"
+
+#include <cassert>
+#include <fstream>
+
+cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
+: Output(output)
+, Level(level)
+, ElementOpen(false)
+, BreakAttrib(false)
+, IsContent(false)
+{
+}
+
+cmXMLWriter::~cmXMLWriter()
+{
+ assert(this->Elements.empty());
+}
+
+void cmXMLWriter::StartDocument(const char* encoding)
+{
+ this->Output << "<?xml version=\"1.0\" encoding=\"" << encoding << "\"?>";
+}
+
+void cmXMLWriter::EndDocument()
+{
+ assert(this->Elements.empty());
+ this->Output << '\n';
+}
+
+void cmXMLWriter::StartElement(std::string const& name)
+{
+ this->CloseStartElement();
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->Output << '<' << name;
+ this->Elements.push(name);
+ this->ElementOpen = true;
+ this->BreakAttrib = false;
+}
+
+void cmXMLWriter::EndElement()
+{
+ assert(!this->Elements.empty());
+ if (this->ElementOpen)
+ {
+ this->Output << "/>";
+ }
+ else
+ {
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size() - 1);
+ this->IsContent = false;
+ this->Output << "</" << this->Elements.top() << '>';
+ }
+ this->Elements.pop();
+ this->ElementOpen = false;
+}
+
+void cmXMLWriter::BreakAttributes()
+{
+ this->BreakAttrib = true;
+}
+
+void cmXMLWriter::Comment(const char* comment)
+{
+ this->CloseStartElement();
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->Output << "<!-- " << comment << " -->";
+}
+
+void cmXMLWriter::CData(std::string const& data)
+{
+ this->PreContent();
+ this->Output << "<![CDATA[" << data << "]]>";
+}
+
+void cmXMLWriter::ProcessingInstruction(const char* target, const char* data)
+{
+ this->CloseStartElement();
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->Output << "<?" << target << ' ' << data << "?>";
+}
+
+void cmXMLWriter::FragmentFile(const char* fname)
+{
+ this->CloseStartElement();
+ std::ifstream fin(fname, std::ios::in | std::ios::binary);
+ this->Output << fin.rdbuf();
+}
+
+void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
+{
+ if (condition)
+ {
+ this->Output << '\n' << std::string(indent + this->Level, '\t');
+ }
+}
+
+void cmXMLWriter::PreAttribute()
+{
+ assert(this->ElementOpen);
+ this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
+ if (!this->BreakAttrib)
+ {
+ this->Output << ' ';
+ }
+}
+
+void cmXMLWriter::PreContent()
+{
+ this->CloseStartElement();
+ this->IsContent = true;
+}
+
+void cmXMLWriter::CloseStartElement()
+{
+ if (this->ElementOpen)
+ {
+ this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
+ this->Output << '>';
+ this->ElementOpen = false;
+ }
+}
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
new file mode 100644
index 0000000..c38c0de
--- /dev/null
+++ b/Source/cmXMLWriter.h
@@ -0,0 +1,120 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2015 Daniel Pfeifer <daniel@pfeifer-mail.de>
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmXMLWiter_h
+#define cmXMLWiter_h
+
+#include "cmStandardIncludes.h"
+#include "cmXMLSafe.h"
+
+#include <ostream>
+#include <stack>
+#include <string>
+#include <vector>
+
+class cmXMLWriter
+{
+public:
+ cmXMLWriter(std::ostream& output, std::size_t level = 0);
+ ~cmXMLWriter();
+
+ void StartDocument(const char* encoding = "UTF-8");
+ void EndDocument();
+
+ void StartElement(std::string const& name);
+ void EndElement();
+
+ void BreakAttributes();
+
+ template <typename T>
+ void Attribute(const char* name, T const& value)
+ {
+ this->PreAttribute();
+ this->Output << name << "=\"" << SafeAttribute(value) << '"';
+ }
+
+ template <typename T>
+ void Element(std::string const& name, T const& value)
+ {
+ this->StartElement(name);
+ this->Content(value);
+ this->EndElement();
+ }
+
+ template <typename T>
+ void Content(T const& content)
+ {
+ this->PreContent();
+ this->Output << SafeContent(content);
+ }
+
+ void Comment(const char* comment);
+
+ void CData(std::string const& data);
+
+ void ProcessingInstruction(const char* target, const char* data);
+
+ void FragmentFile(const char* fname);
+
+private:
+ cmXMLWriter(const cmXMLWriter&);
+ cmXMLWriter& operator=(const cmXMLWriter&);
+
+ void ConditionalLineBreak(bool condition, std::size_t indent);
+
+ void PreAttribute();
+ void PreContent();
+
+ void CloseStartElement();
+
+private:
+ static cmXMLSafe SafeAttribute(const char* value)
+ {
+ return cmXMLSafe(value);
+ }
+
+ static cmXMLSafe SafeAttribute(std::string const& value)
+ {
+ return cmXMLSafe(value);
+ }
+
+ template <typename T>
+ static T SafeAttribute(T value)
+ {
+ return value;
+ }
+
+ static cmXMLSafe SafeContent(const char* value)
+ {
+ return cmXMLSafe(value).Quotes(false);
+ }
+
+ static cmXMLSafe SafeContent(std::string const& value)
+ {
+ return cmXMLSafe(value).Quotes(false);
+ }
+
+ template <typename T>
+ static T SafeContent(T value)
+ {
+ return value;
+ }
+
+private:
+ std::ostream& Output;
+ std::stack<std::string, std::vector<std::string> > Elements;
+ std::size_t Level;
+ bool ElementOpen;
+ bool BreakAttrib;
+ bool IsContent;
+};
+
+#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 5c5c428..23803ef 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -88,8 +88,6 @@
# include "cmGlobalKdevelopGenerator.h"
#endif
-#include "cmExtraQbsGenerator.h"
-
#ifdef CMAKE_USE_ECLIPSE
# include "cmExtraEclipseCDT4Generator.h"
#endif
@@ -136,6 +134,7 @@ cmake::cmake()
this->Policies = new cmPolicies();
this->State = new cmState(this);
+ this->CurrentSnapshot = this->State->CreateSnapshot(cmState::Snapshot());
#ifdef __APPLE__
struct rlimit rlp;
@@ -187,7 +186,7 @@ cmake::~cmake()
void cmake::CleanupCommandsAndMacros()
{
- this->State->Initialize();
+ this->State->Reset();
this->State->RemoveUserDefinedCommands();
}
@@ -364,8 +363,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
// if a generator was not specified use a generic one
if (!gg)
{
- gg = new cmGlobalGenerator;
- gg->SetCMakeInstance(this);
+ gg = new cmGlobalGenerator(this);
created = true;
}
@@ -376,7 +374,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
std::string homeOutputDir = this->GetHomeOutputDirectory();
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
- cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
lg->GetMakefile()->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetCurrentSourceDirectory
@@ -413,12 +411,11 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
(cmSystemTools::GetCurrentWorkingDirectory());
// if a generator was not yet created, temporarily create one
- cmGlobalGenerator *gg = new cmGlobalGenerator;
- gg->SetCMakeInstance(this);
+ cmGlobalGenerator *gg = new cmGlobalGenerator(this);
this->SetGlobalGenerator(gg);
// read in the list file to fill the cache
- cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile();
mf->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory());
@@ -456,8 +453,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::vector<std::string> includeDirs;
cmSystemTools::ExpandListArgument(includes, includeDirs);
- std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0,
- language, false);
+ std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, language);
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
@@ -903,8 +899,6 @@ void cmake::AddDefaultExtraGenerators()
&cmExtraSublimeTextGenerator::New);
this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(),
&cmExtraKateGenerator::New);
- this->AddExtraGenerator(cmExtraQbsGenerator::GetActualName(),
- &cmExtraQbsGenerator::New);
#ifdef CMAKE_USE_ECLIPSE
this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(),
@@ -956,7 +950,7 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
for (RegisteredGeneratorsVector::const_iterator i =
this->Generators.begin(); i != this->Generators.end(); ++i)
{
- generator = (*i)->CreateGlobalGenerator(name);
+ generator = (*i)->CreateGlobalGenerator(name, this);
if (generator)
{
break;
@@ -965,7 +959,6 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
if (generator)
{
- generator->SetCMakeInstance(this);
generator->SetExternalMakefileProjectGenerator(extraGenerator);
}
else
@@ -1050,8 +1043,6 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
{
this->CCEnvironment = "";
}
- // set the cmake instance just to be sure
- gg->SetCMakeInstance(this);
}
int cmake::DoPreConfigureChecks()
@@ -1304,12 +1295,12 @@ int cmake::ActualConfigure()
= this->CreateGlobalGenerator(installedCompiler.c_str());
if(!gen)
{
- gen = new cmGlobalNMakeMakefileGenerator;
+ gen = new cmGlobalNMakeMakefileGenerator(this);
}
this->SetGlobalGenerator(gen);
std::cout << "-- Building for: " << gen->GetName() << "\n";
#else
- this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3);
+ this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this));
#endif
}
if(!this->GlobalGenerator)
@@ -1625,11 +1616,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
std::string message = "Build files have been written to: ";
message += this->GetHomeOutputDirectory();
this->UpdateProgress(message.c_str(), -1);
- if(ret)
- {
- return ret;
- }
-
return ret;
}
@@ -1925,9 +1911,10 @@ int cmake::CheckBuildSystem()
// Read the rerun check file and use it to decide whether to do the
// global generate.
cmake cm;
- cmGlobalGenerator gg;
- gg.SetCMakeInstance(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cmGlobalGenerator gg(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile();
if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag())
@@ -1957,7 +1944,7 @@ int cmake::CheckBuildSystem()
ggd(this->CreateGlobalGenerator(genName));
if(ggd.get())
{
- cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
+ cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
lgd->ClearDependencies(mf, verbose);
}
}
@@ -2435,24 +2422,15 @@ static bool cmakeCheckStampList(const char* stampList)
return true;
}
-//----------------------------------------------------------------------------
-void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
- cmListFileBacktrace const& bt)
+bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg)
{
- cmListFileBacktrace backtrace = bt;
- backtrace.MakeRelative();
-
- std::ostringstream msg;
- bool isError = false;
// Construct the message header.
if(t == cmake::FATAL_ERROR)
{
- isError = true;
msg << "CMake Error";
}
else if(t == cmake::INTERNAL_ERROR)
{
- isError = true;
msg << "CMake Internal Error (please report a bug)";
}
else if(t == cmake::LOG)
@@ -2462,7 +2440,6 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
else if(t == cmake::DEPRECATION_ERROR)
{
msg << "CMake Deprecation Error";
- isError = true;
}
else if (t == cmake::DEPRECATION_WARNING)
{
@@ -2478,40 +2455,24 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
"CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
if(suppress && cmSystemTools::IsOn(suppress))
{
- return;
+ return false;
}
msg << " (dev)";
}
}
+ return true;
+}
- // Add the immediate context.
- cmListFileBacktrace::const_iterator i = backtrace.begin();
- if(i != backtrace.end())
- {
- cmListFileContext const& lfc = *i;
- msg << (lfc.Line? " at ": " in ") << lfc;
- ++i;
- }
-
- // Add the message text.
- {
- msg << ":\n";
- cmDocumentationFormatter formatter;
- formatter.SetIndent(" ");
- formatter.PrintFormatted(msg, text.c_str());
- }
+void printMessageText(std::ostream& msg, std::string const& text)
+{
+ msg << ":\n";
+ cmDocumentationFormatter formatter;
+ formatter.SetIndent(" ");
+ formatter.PrintFormatted(msg, text.c_str());
+}
- // Add the rest of the context.
- if(i != backtrace.end())
- {
- msg << "Call Stack (most recent call first):\n";
- while(i != backtrace.end())
- {
- cmListFileContext const& lfc = *i;
- msg << " " << lfc << "\n";
- ++i;
- }
- }
+void displayMessage(cmake::MessageType t, std::ostringstream& msg)
+{
// Add a note about warning suppression.
if(t == cmake::AUTHOR_WARNING)
@@ -2540,7 +2501,9 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
#endif
// Output the message.
- if(isError)
+ if(t == cmake::FATAL_ERROR
+ || t == cmake::INTERNAL_ERROR
+ || t == cmake::DEPRECATION_ERROR)
{
cmSystemTools::SetErrorOccured();
cmSystemTools::Message(msg.str().c_str(), "Error");
@@ -2552,6 +2515,48 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
}
//----------------------------------------------------------------------------
+void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
+ cmListFileBacktrace const& bt)
+{
+ cmListFileBacktrace backtrace = bt;
+ backtrace.MakeRelative();
+
+ std::ostringstream msg;
+ if (!this->PrintMessagePreamble(t, msg))
+ {
+ return;
+ }
+
+ // Add the immediate context.
+ backtrace.PrintTitle(msg);
+
+ printMessageText(msg, text);
+
+ // Add the rest of the context.
+ backtrace.PrintCallStack(msg);
+
+ displayMessage(t, msg);
+}
+
+//----------------------------------------------------------------------------
+void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
+ cmListFileContext const& lfc)
+{
+ std::ostringstream msg;
+ if (!this->PrintMessagePreamble(t, msg))
+ {
+ return;
+ }
+
+ // Add the immediate context.
+ msg << (lfc.Line ? " at " : " in ") << lfc;
+
+ printMessageText(msg, text);
+
+ displayMessage(t, msg);
+}
+
+//----------------------------------------------------------------------------
std::vector<std::string> cmake::GetDebugConfigs()
{
std::vector<std::string> configs;
@@ -2580,6 +2585,9 @@ int cmake::Build(const std::string& dir,
const std::vector<std::string>& nativeOptions,
bool clean)
{
+
+ this->SetHomeDirectory("");
+ this->SetHomeOutputDirectory("");
if(!cmSystemTools::FileIsDirectory(dir))
{
std::cerr << "Error: " << dir << " is not a directory\n";
diff --git a/Source/cmake.h b/Source/cmake.h
index 0d1977e..12b7e68 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -30,7 +30,6 @@ class cmDocumentationSection;
class cmPolicies;
class cmTarget;
class cmGeneratedFileStream;
-class cmState;
/** \brief Represents a cmake invocation.
*
@@ -303,6 +302,9 @@ class cmake
/** Display a message to the user. */
void IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL));
+ void IssueMessage(cmake::MessageType t, std::string const& text,
+ cmListFileContext const& lfc);
+
///! run the --build option
int Build(const std::string& dir,
const std::string& target,
@@ -314,6 +316,10 @@ class cmake
void WatchUnusedCli(const std::string& var);
cmState* GetState() const { return this->State; }
+ void SetCurrentSnapshot(cmState::Snapshot snapshot)
+ { this->CurrentSnapshot = snapshot; }
+ cmState::Snapshot GetCurrentSnapshot() const
+ { return this->CurrentSnapshot; }
protected:
void RunCheckForUnusedVariables();
@@ -394,16 +400,19 @@ private:
InstalledFilesMap InstalledFiles;
cmState* State;
+ cmState::Snapshot CurrentSnapshot;
void UpdateConversionPathTable();
// Print a list of valid generators to stderr.
void PrintGeneratorList();
+
+ bool PrintMessagePreamble(cmake::MessageType t, std::ostream& msg);
};
#define CMAKE_STANDARD_OPTIONS_TABLE \
{"-C <initial-cache>", "Pre-load a script to populate the cache."}, \
- {"-D <var>:<type>=<value>", "Create a cmake cache entry."}, \
+ {"-D <var>[:<type>]=<value>", "Create a cmake cache entry."}, \
{"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \
{"-G <generator-name>", "Specify a build system generator."},\
{"-T <toolset-name>", "Specify toolset name if supported by generator."}, \
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index d82087f..e5f4700 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -130,7 +130,7 @@ static std::string cmakemainGetStack(void *clientdata)
cmMakefile* mf=cmakemainGetMakefile(clientdata);
if (mf)
{
- msg = mf->GetListFileStack();
+ msg = mf->FormatListFileStack();
if (!msg.empty())
{
msg = "\n Called from: " + msg;
@@ -214,6 +214,8 @@ int do_cmake(int ac, char const* const* av)
{
// Construct and print requested documentation.
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
// the command line args are processed here so that you can do
@@ -317,10 +319,14 @@ int do_cmake(int ac, char const* const* av)
if (sysinfo)
{
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
int ret = cm.GetSystemInformation(args);
return ret;
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
cm.SetWorkingMode(workingMode);
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 12bb8ee..3ea2186 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -211,6 +211,88 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
+ // run include what you use command and then run the compile
+ // command. This is an internal undocumented option and should
+ // only be used by CMake itself when running iwyu.
+ else if (args[1] == "__run_iwyu")
+ {
+ if (args.size() < 3)
+ {
+ std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]"
+ " -- compile command\n";
+ return 1;
+ }
+ bool doing_options = true;
+ std::vector<std::string> orig_cmd;
+ std::string iwyu;
+ for (std::string::size_type cc = 2; cc < args.size(); cc ++)
+ {
+ std::string const& arg = args[cc];
+ if (arg == "--")
+ {
+ doing_options = false;
+ }
+ else if (doing_options && cmHasLiteralPrefix(arg, "--iwyu="))
+ {
+ iwyu = arg.substr(7);
+ }
+ else if (doing_options)
+ {
+ std::cerr << "__run_iwyu given unknown argument: " << arg << "\n";
+ return 1;
+ }
+ else
+ {
+ orig_cmd.push_back(arg);
+ }
+ }
+ if (iwyu.empty())
+ {
+ std::cerr << "__run_iwyu missing --iwyu=\n";
+ return 1;
+ }
+ if (orig_cmd.empty())
+ {
+ std::cerr << "__run_iwyu missing compile command after --\n";
+ return 1;
+ }
+
+ // Construct the iwyu command line by taking what was given
+ // and adding all the arguments we give to the compiler.
+ std::vector<std::string> iwyu_cmd;
+ cmSystemTools::ExpandListArgument(iwyu, iwyu_cmd, true);
+ iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin()+1, orig_cmd.end());
+
+ // Run the iwyu command line. Capture its stderr and hide its stdout.
+ int ret = 0;
+ std::string stdErr;
+ if(!cmSystemTools::RunSingleCommand(iwyu_cmd, 0, &stdErr, &ret,
+ 0, cmSystemTools::OUTPUT_NONE))
+ {
+ std::cerr << "Error running '" << iwyu_cmd[0] << "': "
+ << stdErr << "\n";
+ return 1;
+ }
+
+ // Warn if iwyu reported anything.
+ if(stdErr.find("should remove these lines:") != stdErr.npos
+ || stdErr.find("should add these lines:") != stdErr.npos)
+ {
+ std::cerr << "Warning: include-what-you-use reported diagnostics:\n"
+ << stdErr << "\n";
+ }
+
+ // Now run the real compiler command and return its result value.
+ if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, &stdErr, &ret, 0,
+ cmSystemTools::OUTPUT_PASSTHROUGH))
+ {
+ std::cerr << "Error running '" << orig_cmd[0] << "': "
+ << stdErr << "\n";
+ return 1;
+ }
+ return ret;
+ }
+
// Echo string
else if (args[1] == "echo" )
{
@@ -646,7 +728,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
{
cm.SetGlobalGenerator(ggd);
- cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
+ cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 0fc47b7..e784759 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -160,6 +160,8 @@ int main (int argc, char const* const* argv)
if(doc.CheckOptions(argc, argv))
{
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
// Construct and print requested documentation.
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 8069ee2..c88e888 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -88,6 +88,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
IF(POLICY CMP0025)
CMAKE_POLICY(SET CMP0025 NEW)
ENDIF()
+IF(POLICY CMP0056)
+ CMAKE_POLICY(SET CMP0056 NEW)
+ENDIF()
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 6c4a7a6..c834e34 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2674,27 +2674,43 @@ kwsys_stl::string SystemTools::GetLastSystemError()
bool SystemTools::RemoveFile(const kwsys_stl::string& source)
{
#ifdef _WIN32
+ kwsys_stl::wstring const& ws =
+ SystemTools::ConvertToWindowsExtendedPath(source);
+ if (DeleteFileW(ws.c_str()))
+ {
+ return true;
+ }
+ DWORD err = GetLastError();
+ if (err == ERROR_FILE_NOT_FOUND ||
+ err == ERROR_PATH_NOT_FOUND)
+ {
+ return true;
+ }
+ if (err != ERROR_ACCESS_DENIED)
+ {
+ return false;
+ }
+ /* The file may be read-only. Try adding write permission. */
mode_t mode;
- if ( !SystemTools::GetPermissions(source, mode) )
+ if (!SystemTools::GetPermissions(source, mode) ||
+ !SystemTools::SetPermissions(source, S_IWRITE))
{
+ SetLastError(err);
return false;
}
- /* Win32 unlink is stupid --- it fails if the file is read-only */
- SystemTools::SetPermissions(source, S_IWRITE);
-#endif
-#ifdef _WIN32
- bool res =
- _wunlink(SystemTools::ConvertToWindowsExtendedPath(source).c_str()) == 0;
-#else
- bool res = unlink(source.c_str()) != 0 ? false : true;
-#endif
-#ifdef _WIN32
- if ( !res )
+ if (DeleteFileW(ws.c_str()) ||
+ GetLastError() == ERROR_FILE_NOT_FOUND ||
+ GetLastError() == ERROR_PATH_NOT_FOUND)
{
- SystemTools::SetPermissions(source, mode);
+ return true;
}
+ /* Try to restore the original permissions. */
+ SystemTools::SetPermissions(source, mode);
+ SetLastError(err);
+ return false;
+#else
+ return unlink(source.c_str()) == 0 || errno == ENOENT;
#endif
- return res;
}
bool SystemTools::RemoveADirectory(const kwsys_stl::string& source)
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 42b6249..15d8eab 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -156,6 +156,24 @@ static bool CheckFileOperations()
res = false;
}
+ kwsys_stl::string const testFileMissing(testNewDir + "/testMissingFile.txt");
+ if (!kwsys::SystemTools::RemoveFile(testFileMissing))
+ {
+ std::string const& msg = kwsys::SystemTools::GetLastSystemError();
+ kwsys_ios::cerr <<
+ "RemoveFile(\"" << testFileMissing << "\") failed: " << msg << "\n";
+ res = false;
+ }
+
+ kwsys_stl::string const testFileMissingDir(testNewDir + "/missing/file.txt");
+ if (!kwsys::SystemTools::RemoveFile(testFileMissingDir))
+ {
+ std::string const& msg = kwsys::SystemTools::GetLastSystemError();
+ kwsys_ios::cerr <<
+ "RemoveFile(\"" << testFileMissingDir << "\") failed: " << msg << "\n";
+ res = false;
+ }
+
kwsys::SystemTools::Touch(testNewFile.c_str(), true);
if (!kwsys::SystemTools::RemoveADirectory(testNewDir))
{