summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt4
-rw-r--r--Source/CMakeVersion.cmake4
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx15
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.h5
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx89
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.h4
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx67
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.h4
-rw-r--r--Source/CPack/cmCPackGenerator.cxx3
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx20
-rw-r--r--Source/CTest/cmCTestRunTest.cxx22
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx25
-rw-r--r--Source/CTest/cmCTestTestHandler.h3
-rw-r--r--Source/CTest/cmProcess.cxx10
-rw-r--r--Source/CTest/cmProcess.h2
-rw-r--r--Source/cmCommonTargetGenerator.cxx32
-rw-r--r--Source/cmCommonTargetGenerator.h3
-rw-r--r--Source/cmComputeLinkDepends.cxx2
-rw-r--r--Source/cmCoreTryCompile.cxx73
-rw-r--r--Source/cmCoreTryCompile.h6
-rw-r--r--Source/cmCreateTestSourceList.cxx3
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx317
-rw-r--r--Source/cmExtraCodeBlocksGenerator.h11
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx242
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx699
-rw-r--r--Source/cmExtraEclipseCDT4Generator.h23
-rw-r--r--Source/cmFileCommand.cxx9
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx10
-rw-r--r--Source/cmGlobalGenerator.cxx23
-rw-r--r--Source/cmGlobalGenerator.h6
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx351
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx88
-rw-r--r--Source/cmGlobalNinjaGenerator.h3
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx451
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h113
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx22
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx227
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h26
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx37
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx32
-rw-r--r--Source/cmInstallCommand.cxx31
-rw-r--r--Source/cmInstallCommandArguments.cxx30
-rw-r--r--Source/cmInstallCommandArguments.h2
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx4
-rw-r--r--Source/cmInstallDirectoryGenerator.h1
-rw-r--r--Source/cmInstallExportGenerator.cxx4
-rw-r--r--Source/cmInstallExportGenerator.h1
-rw-r--r--Source/cmInstallFilesCommand.cxx4
-rw-r--r--Source/cmInstallFilesGenerator.cxx4
-rw-r--r--Source/cmInstallFilesGenerator.h1
-rw-r--r--Source/cmInstallGenerator.cxx18
-rw-r--r--Source/cmInstallGenerator.h7
-rw-r--r--Source/cmInstallProgramsCommand.cxx4
-rw-r--r--Source/cmInstallScriptGenerator.cxx7
-rw-r--r--Source/cmInstallScriptGenerator.h2
-rw-r--r--Source/cmInstallTargetGenerator.cxx4
-rw-r--r--Source/cmInstallTargetGenerator.h1
-rw-r--r--Source/cmLinkItem.h2
-rw-r--r--Source/cmListCommand.cxx109
-rw-r--r--Source/cmListCommand.h6
-rw-r--r--Source/cmListFileCache.h3
-rw-r--r--Source/cmLocalGenerator.cxx8
-rw-r--r--Source/cmLocalNinjaGenerator.cxx17
-rw-r--r--Source/cmLocalNinjaGenerator.h1
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx61
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx2002
-rw-r--r--Source/cmLocalVisualStudio6Generator.h105
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx33
-rw-r--r--Source/cmLocalVisualStudio7Generator.h3
-rw-r--r--Source/cmMakefile.cxx48
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx34
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h3
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx10
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx3
-rw-r--r--Source/cmSystemTools.cxx9
-rw-r--r--Source/cmTarget.cxx298
-rw-r--r--Source/cmTarget.h64
-rw-r--r--Source/cmTimestamp.cxx64
-rw-r--r--Source/cmTimestamp.h11
-rw-r--r--Source/cmTryCompileCommand.cxx2
-rw-r--r--Source/cmTryRunCommand.cxx2
-rw-r--r--Source/cmVS14CLFlagTable.h20
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx91
-rw-r--r--Source/cmXCodeObject.cxx126
-rw-r--r--Source/cmXCodeObject.h4
-rw-r--r--Source/cmXMLWriter.cxx14
-rw-r--r--Source/cmXMLWriter.h4
-rw-r--r--Source/cmake.cxx11
-rw-r--r--Source/cmakemain.cxx21
-rw-r--r--Source/kwsys/CommandLineArguments.cxx1
-rw-r--r--Source/kwsys/MD5.c8
-rw-r--r--Source/kwsys/Process.h.in7
-rw-r--r--Source/kwsys/ProcessUNIX.c13
-rw-r--r--Source/kwsys/ProcessWin32.c15
-rw-r--r--Source/kwsys/SystemInformation.cxx52
-rw-r--r--Source/kwsys/SystemTools.cxx112
-rw-r--r--Source/kwsys/testDynamicLoader.cxx2
-rw-r--r--Source/kwsys/testHashSTL.cxx1
-rw-r--r--Source/kwsys/testIOS.cxx6
102 files changed, 2172 insertions, 4453 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 4ef0e80..467b692 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -452,8 +452,6 @@ if (WIN32)
cmGlobalNMakeMakefileGenerator.h
cmGlobalJOMMakefileGenerator.cxx
cmGlobalJOMMakefileGenerator.h
- cmGlobalVisualStudio6Generator.cxx
- cmGlobalVisualStudio6Generator.h
cmGlobalVisualStudio71Generator.cxx
cmGlobalVisualStudio71Generator.h
cmGlobalVisualStudio7Generator.cxx
@@ -481,8 +479,6 @@ if (WIN32)
cmIDEFlagTable.h
cmIDEOptions.cxx
cmIDEOptions.h
- cmLocalVisualStudio6Generator.cxx
- cmLocalVisualStudio6Generator.h
cmLocalVisualStudio7Generator.cxx
cmLocalVisualStudio7Generator.h
cmLocalVisualStudioGenerator.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 129a882..37e2b54 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 5)
-set(CMake_VERSION_PATCH 0)
-#set(CMake_VERSION_RC 0)
+set(CMake_VERSION_PATCH 20160324)
+#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 4eb23c1..50ac971 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -27,7 +27,7 @@
#include <cmSystemTools.h>
#include <cmMakefile.h>
#include <cmGeneratedFileStream.h>
-#include <cmXMLSafe.h>
+#include <cmXMLWriter.h>
#include <cmVersionConfig.h>
#include <cmTimestamp.h>
@@ -611,18 +611,19 @@ cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
}
//----------------------------------------------------------------------------
-void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
- xout << "<!-- Generated by CPack " << CMake_VERSION << " IFW generator "
+ std::stringstream comment;
+ comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
<< "for QtIFW ";
if(IsVersionLess("2.0"))
{
- xout << "less 2.0";
+ comment << "less 2.0";
}
else
{
- xout << FrameworkVersion;
+ comment << FrameworkVersion;
}
- xout << " tools at " << cmTimestamp().CurrentTime("", true) << " -->"
- << std::endl;
+ comment << " tools at " << cmTimestamp().CurrentTime("", true);
+ xout.Comment(comment.str().c_str());
}
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h
index 3246861..5770451 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.h
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.h
@@ -13,12 +13,13 @@
#ifndef cmCPackIFWGenerator_h
#define cmCPackIFWGenerator_h
-#include <cmGeneratedFileStream.h>
#include <CPack/cmCPackGenerator.h>
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWInstaller.h"
+class cmXMLWriter;
+
/** \class cmCPackIFWGenerator
* \brief A generator for Qt Installer Framework tools
*
@@ -121,7 +122,7 @@ protected: // Methods
cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const;
cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const;
- void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+ void WriteGeneratedByToStrim(cmXMLWriter& xout);
protected: // Data
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 8c77a2c..224d606 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -17,7 +17,7 @@
#include <CPack/cmCPackLog.h>
#include <cmGeneratedFileStream.h>
-#include <cmXMLSafe.h>
+#include <cmXMLWriter.h>
#ifdef cmCPackLogger
# undef cmCPackLogger
@@ -334,30 +334,27 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
}
// Output stream
- cmGeneratedFileStream xout((Directory + "/config/config.xml").data());
+ cmGeneratedFileStream fout((Directory + "/config/config.xml").data());
+ cmXMLWriter xout(fout);
- xout << "<?xml version=\"1.0\"?>" << std::endl;
+ xout.StartDocument();
WriteGeneratedByToStrim(xout);
- xout << "<Installer>" << std::endl;
+ xout.StartElement("Installer");
- xout << " <Name>" << cmXMLSafe(Name).str() << "</Name>" << std::endl;
-
- xout << " <Version>" << Version << "</Version>" << std::endl;
-
- xout << " <Title>" << cmXMLSafe(Title).str() << "</Title>"
- << std::endl;
+ xout.Element("Name", Name);
+ xout.Element("Version", Version);
+ xout.Element("Title", Title);
if(!Publisher.empty())
{
- xout << " <Publisher>" << cmXMLSafe(Publisher).str()
- << "</Publisher>" << std::endl;
+ xout.Element("Publisher", Publisher);
}
if(!ProductUrl.empty())
{
- xout << " <ProductUrl>" << ProductUrl << "</ProductUrl>" << std::endl;
+ xout.Element("ProductUrl", ProductUrl);
}
// ApplicationIcon
@@ -369,8 +366,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
name = cmSystemTools::GetFilenameWithoutExtension(name);
cmsys::SystemTools::CopyFileIfDifferent(
InstallerApplicationIcon.data(), path.data());
- xout << " <InstallerApplicationIcon>" << name
- << "</InstallerApplicationIcon>" << std::endl;
+ xout.Element("InstallerApplicationIcon", name);
}
// WindowIcon
@@ -380,8 +376,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(
InstallerWindowIcon.data(), path.data());
- xout << " <InstallerWindowIcon>" << name
- << "</InstallerWindowIcon>" << std::endl;
+ xout.Element("InstallerWindowIcon", name);
}
// Logo
@@ -390,104 +385,91 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(Logo);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data());
- xout << " <Logo>" << name << "</Logo>" << std::endl;
+ xout.Element("Logo", name);
}
// Start menu
if(!IsVersionLess("2.0"))
{
- xout << " <StartMenuDir>" << StartMenuDir
- << "</StartMenuDir>" << std::endl;
+ xout.Element("StartMenuDir", StartMenuDir);
}
// Target dir
if(!TargetDir.empty())
{
- xout << " <TargetDir>" << TargetDir << "</TargetDir>" << std::endl;
+ xout.Element("TargetDir", TargetDir);
}
// Admin target dir
if(!AdminTargetDir.empty())
{
- xout << " <AdminTargetDir>" << AdminTargetDir
- << "</AdminTargetDir>" << std::endl;
+ xout.Element("AdminTargetDir", AdminTargetDir);
}
// Remote repositories
if (!Repositories.empty())
{
- xout << " <RemoteRepositories>" << std::endl;
+ xout.StartElement("RemoteRepositories");
for(std::vector<RepositoryStruct>::iterator
rit = Repositories.begin(); rit != Repositories.end(); ++rit)
{
- xout << " <Repository>" << std::endl;
+ xout.StartElement("Repository");
// Url
- xout << " <Url>" << rit->Url
- << "</Url>" << std::endl;
+ xout.Element("Url", rit->Url);
// Enabled
if(!rit->Enabled.empty())
{
- xout << " <Enabled>" << rit->Enabled
- << "</Enabled>" << std::endl;
+ xout.Element("Enabled", rit->Enabled);
}
// Username
if(!rit->Username.empty())
{
- xout << " <Username>" << rit->Username
- << "</Username>" << std::endl;
+ xout.Element("Username", rit->Username);
}
// Password
if(!rit->Password.empty())
{
- xout << " <Password>" << rit->Password
- << "</Password>" << std::endl;
+ xout.Element("Password", rit->Password);
}
// DisplayName
if(!rit->DisplayName.empty())
{
- xout << " <DisplayName>" << rit->DisplayName
- << "</DisplayName>" << std::endl;
+ xout.Element("DisplayName", rit->DisplayName);
}
- xout << " </Repository>" << std::endl;
+ xout.EndElement();
}
- xout << " </RemoteRepositories>" << std::endl;
+ xout.EndElement();
}
// Maintenance tool
if(!IsVersionLess("2.0") && !MaintenanceToolName.empty())
{
- xout << " <MaintenanceToolName>" << MaintenanceToolName
- << "</MaintenanceToolName>" << std::endl;
+ xout.Element("MaintenanceToolName", MaintenanceToolName);
}
// Maintenance tool ini file
if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty())
{
- xout << " <MaintenanceToolIniFile>" << MaintenanceToolIniFile
- << "</MaintenanceToolIniFile>" << std::endl;
+ xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile);
}
// Different allows
if(IsVersionLess("2.0"))
{
// CPack IFW default policy
- xout << " <!-- CPack IFW default policy for QtIFW less 2.0 -->"
- << std::endl;
- xout << " <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>"
- << std::endl;
- xout << " <AllowSpaceInPath>true</AllowSpaceInPath>" << std::endl;
+ xout.Comment("CPack IFW default policy for QtIFW less 2.0");
+ xout.Element("AllowNonAsciiCharacters", "true");
+ xout.Element("AllowSpaceInPath", "true");
}
else
{
if(!AllowNonAsciiCharacters.empty())
{
- xout << " <AllowNonAsciiCharacters>" << AllowNonAsciiCharacters
- << "</AllowNonAsciiCharacters>" << std::endl;
+ xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
}
if(!AllowSpaceInPath.empty())
{
- xout << " <AllowAllowSpaceInPath>" << AllowSpaceInPath
- << "</AllowSpaceInPath>" << std::endl;
+ xout.Element("AllowSpaceInPath", AllowSpaceInPath);
}
}
@@ -497,10 +479,11 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(ControlScript);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data());
- xout << " <ControlScript>" << name << "</ControlScript>" << std::endl;
+ xout.Element("ControlScript", name);
}
- xout << "</Installer>" << std::endl;
+ xout.EndElement();
+ xout.EndDocument();
}
//----------------------------------------------------------------------------
@@ -535,7 +518,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
}
}
-void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
if(Generator) Generator->WriteGeneratedByToStrim(xout);
}
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h
index 4cba5b2..04050c0 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.h
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.h
@@ -13,11 +13,11 @@
#ifndef cmCPackIFWInstaller_h
#define cmCPackIFWInstaller_h
-#include <cmGeneratedFileStream.h>
#include <cmStandardIncludes.h>
class cmCPackIFWPackage;
class cmCPackIFWGenerator;
+class cmXMLWriter;
/** \class cmCPackIFWInstaller
* \brief A binary installer to be created CPack IFW generator
@@ -115,7 +115,7 @@ public: // Internal implementation
std::string Directory;
protected:
- void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+ void WriteGeneratedByToStrim(cmXMLWriter& xout);
};
#endif // cmCPackIFWInstaller_h
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 5474ad1b..b71c7e3 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -18,6 +18,7 @@
#include <cmGeneratedFileStream.h>
#include <cmTimestamp.h>
+#include <cmXMLWriter.h>
//----------------------------------------------------------------- Logger ---
#ifdef cmCPackLogger
@@ -447,35 +448,28 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Output stream
- cmGeneratedFileStream xout((Directory + "/meta/package.xml").data());
+ cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
+ cmXMLWriter xout(fout);
- xout << "<?xml version=\"1.0\"?>" << std::endl;
+ xout.StartDocument();
WriteGeneratedByToStrim(xout);
- xout << "<Package>" << std::endl;
+ xout.StartElement("Package");
- xout << " <DisplayName>" << DisplayName
- << "</DisplayName>" << std::endl;
+ xout.Element("DisplayName", DisplayName);
+ xout.Element("Description", Description);
+ xout.Element("Name", Name);
+ xout.Element("Version", Version);
- xout << " <Description>" << Description
- << "</Description>" << std::endl;
-
- xout << " <Name>" << Name << "</Name>" << std::endl;
-
- xout << " <Version>" << Version
- << "</Version>" << std::endl;
-
- xout << " <ReleaseDate>";
- if(ReleaseDate.empty())
+ if (!ReleaseDate.empty())
{
- xout << cmTimestamp().CurrentTime("%Y-%m-%d", true);
+ xout.Element("ReleaseDate", ReleaseDate);
}
else
{
- xout << ReleaseDate;
+ xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
}
- xout << "</ReleaseDate>" << std::endl;
// Script (copy to meta dir)
if(!Script.empty())
@@ -483,7 +477,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
std::string name = cmSystemTools::GetFilenameName(Script);
std::string path = Directory + "/meta/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
- xout << " <Script>" << name << "</Script>" << std::endl;
+ xout.Element("Script", name);
}
// Dependencies
@@ -501,16 +495,16 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Write dependencies
if (!compDepSet.empty())
{
- xout << " <Dependencies>";
+ std::stringstream dependencies;
std::set<DependenceStruct>::iterator it = compDepSet.begin();
- xout << it->NameWithCompare();
+ dependencies << it->NameWithCompare();
++it;
while(it != compDepSet.end())
{
- xout << "," << it->NameWithCompare();
+ dependencies << "," << it->NameWithCompare();
++it;
}
- xout << "</Dependencies>" << std::endl;
+ xout.Element("Dependencies", dependencies.str());
}
// Licenses (copy to meta dir)
@@ -524,43 +518,42 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
if(!licenses.empty())
{
- xout << " <Licenses>" << std::endl;
+ xout.StartElement("Licenses");
for(size_t i = 0; i < licenses.size(); i += 2)
{
- xout << " <License "
- << "name=\"" << licenses[i] << "\" "
- << "file=\"" << licenses[i + 1] << "\" "
- << "/>" <<std::endl;
+ xout.StartElement("License");
+ xout.Attribute("name", licenses[i]);
+ xout.Attribute("file", licenses[i + 1]);
+ xout.EndElement();
}
- xout << " </Licenses>" << std::endl;
+ xout.EndElement();
}
if (!ForcedInstallation.empty())
{
- xout << " <ForcedInstallation>" << ForcedInstallation
- << "</ForcedInstallation>" << std::endl;
+ xout.Element("ForcedInstallation", ForcedInstallation);
}
if (!Virtual.empty())
{
- xout << " <Virtual>" << Virtual << "</Virtual>" << std::endl;
+ xout.Element("Virtual", Virtual);
}
else if (!Default.empty())
{
- xout << " <Default>" << Default << "</Default>" << std::endl;
+ xout.Element("Default", Default);
}
// Priority
if(!SortingPriority.empty())
{
- xout << " <SortingPriority>" << SortingPriority
- << "</SortingPriority>" << std::endl;
+ xout.Element("SortingPriority", SortingPriority);
}
- xout << "</Package>" << std::endl;
+ xout.EndElement();
+ xout.EndDocument();
}
-void cmCPackIFWPackage::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter &xout)
{
if(Generator) Generator->WriteGeneratedByToStrim(xout);
}
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index d2f7927..e647c16 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -14,12 +14,12 @@
#define cmCPackIFWPackage_h
#include <cmStandardIncludes.h>
-#include <cmGeneratedFileStream.h>
class cmCPackComponent;
class cmCPackComponentGroup;
class cmCPackIFWInstaller;
class cmCPackIFWGenerator;
+class cmXMLWriter;
/** \class cmCPackIFWPackage
* \brief A single component to be installed by CPack IFW generator
@@ -135,7 +135,7 @@ public: // Internal implementation
std::string Directory;
protected:
- void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+ void WriteGeneratedByToStrim(cmXMLWriter& xout);
};
#endif // cmCPackIFWPackage_h
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 22d4bf0..3eca280 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -723,10 +723,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(
new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- std::string realInstallDirectory = tempInstallDirectory;
if ( !installSubDirectory.empty() && installSubDirectory != "/" )
{
- realInstallDirectory += installSubDirectory;
+ tempInstallDirectory += installSubDirectory;
}
if (componentInstall)
{
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 2c2cd48..fd62696 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -983,7 +983,7 @@ int cmCTestCoverageHandler::HandleDelphiCoverage(
std::string BinDir
= this->CTest->GetBinaryDir();
- std::string coverageFile = BinDir+ "/*.html";
+ std::string coverageFile = BinDir+ "/*(*.pas).html";
g.FindFiles(coverageFile);
@@ -1017,9 +1017,25 @@ int cmCTestCoverageHandler::HandleBlanketJSCoverage(
std::string coverageFile = SourceDir+ "/*.json";
cmsys::Glob g;
std::vector<std::string> files;
+ std::vector<std::string> blanketFiles;
g.FindFiles(coverageFile);
files=g.GetFiles();
- if (!files.empty())
+ // Ensure that the JSON files found are the result of the
+ // Blanket.js output. Check for the "node-jscoverage"
+ // string on the second line
+ std::string line;
+ for(unsigned int fileEntry=0;fileEntry<files.size();fileEntry++)
+ {
+ cmsys::ifstream in(files[fileEntry].c_str());
+ cmSystemTools::GetLineFromStream(in, line);
+ cmSystemTools::GetLineFromStream(in, line);
+ if (line.find("node-jscoverage") != line.npos)
+ {
+ blanketFiles.push_back(files[fileEntry]);
+ }
+ }
+ // Take all files with the node-jscoverage string and parse those
+ if (!blanketFiles.empty())
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found BlanketJS output JSON, Performing Coverage" << std::endl,
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index d108592..7f3a077 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -64,6 +64,28 @@ bool cmCTestRunTest::CheckOutput()
this->GetIndex() << ": " << line << std::endl);
this->ProcessOutput += line;
this->ProcessOutput += "\n";
+
+ // Check for TIMEOUT_AFTER_MATCH property.
+ if (!this->TestProperties->TimeoutRegularExpressions.empty())
+ {
+ std::vector<std::pair<cmsys::RegularExpression,
+ std::string> >::iterator regIt;
+ for ( regIt = this->TestProperties->TimeoutRegularExpressions.begin();
+ regIt != this->TestProperties->TimeoutRegularExpressions.end();
+ ++ regIt )
+ {
+ if ( regIt->first.find(this->ProcessOutput.c_str()) )
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Test timeout changed to " <<
+ this->TestProperties->AlternateTimeout << std::endl);
+ this->TestProcess->ResetStartTime();
+ this->TestProcess->ChangeTimeout(
+ this->TestProperties->AlternateTimeout);
+ break;
+ }
+ }
+ }
}
else // if(p == cmsysProcess_Pipe_Timeout)
{
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index b6a4819..59ed98e 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -2254,6 +2254,31 @@ bool cmCTestTestHandler::SetTestsProperties(
{
rtit->Directory = val;
}
+ if ( key == "TIMEOUT_AFTER_MATCH" )
+ {
+ std::vector<std::string> propArgs;
+ cmSystemTools::ExpandListArgument(val, propArgs);
+ if (propArgs.size() != 2)
+ {
+ cmCTestLog(this->CTest, WARNING,
+ "TIMEOUT_AFTER_MATCH expects two arguments, found " <<
+ propArgs.size() << std::endl);
+ }
+ else
+ {
+ rtit->AlternateTimeout = atof(propArgs[0].c_str());
+ std::vector<std::string> lval;
+ cmSystemTools::ExpandListArgument(propArgs[1], lval);
+ std::vector<std::string>::iterator crit;
+ for ( crit = lval.begin(); crit != lval.end(); ++ crit )
+ {
+ rtit->TimeoutRegularExpressions.push_back(
+ std::pair<cmsys::RegularExpression, std::string>(
+ cmsys::RegularExpression(crit->c_str()),
+ std::string(*crit)));
+ }
+ }
+ }
}
}
}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index c635430..d12c2b6 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -104,6 +104,8 @@ public:
std::string> > ErrorRegularExpressions;
std::vector<std::pair<cmsys::RegularExpression,
std::string> > RequiredRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression,
+ std::string> > TimeoutRegularExpressions;
std::map<std::string, std::string> Measurements;
bool IsInBasedOnREOptions;
bool WillFail;
@@ -112,6 +114,7 @@ public:
bool RunSerial;
double Timeout;
bool ExplicitTimeout;
+ double AlternateTimeout;
int Index;
//Requested number of process slots
int Processors;
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 0c25f40..6441886 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -262,6 +262,16 @@ int cmProcess::ReportStatus()
}
+void cmProcess::ChangeTimeout(double t)
+{
+ this->Timeout = t;
+ cmsysProcess_SetTimeout(this->Process, this->Timeout);
+}
+
+void cmProcess::ResetStartTime()
+{
+ cmsysProcess_ResetStartTime(this->Process);
+}
int cmProcess::GetExitException()
{
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index eddeeab..c9fd859 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -32,6 +32,8 @@ public:
void SetCommandArguments(std::vector<std::string> const& arg);
void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir;}
void SetTimeout(double t) { this->Timeout = t;}
+ void ChangeTimeout(double t);
+ void ResetStartTime();
// Return true if the process starts
bool StartProcess();
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 76ed038..b5688a8 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -426,3 +426,35 @@ std::string cmCommonTargetGenerator::GetManifests()
return cmJoin(manifests, " ");
}
+
+void cmCommonTargetGenerator
+::AppendOSXVerFlag(std::string& flags, const std::string& lang,
+ const char* name, bool so)
+{
+ // Lookup the flag to specify the version.
+ std::string fvar = "CMAKE_";
+ fvar += lang;
+ fvar += "_OSX_";
+ fvar += name;
+ fvar += "_VERSION_FLAG";
+ const char* flag = this->Makefile->GetDefinition(fvar);
+
+ // Skip if no such flag.
+ if(!flag)
+ {
+ return;
+ }
+
+ // Lookup the target version information.
+ int major;
+ int minor;
+ int patch;
+ this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
+ if(major > 0 || minor > 0 || patch > 0)
+ {
+ // Append the flag since a non-zero version is specified.
+ std::ostringstream vflag;
+ vflag << flag << major << "." << minor << "." << patch;
+ this->LocalGenerator->AppendFlags(flags, vflag.str());
+ }
+}
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index 0c17500..bfb6b79 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -79,6 +79,9 @@ protected:
virtual void AddIncludeFlags(std::string& flags,
std::string const& lang) = 0;
+ void AppendOSXVerFlag(std::string& flags, const std::string& lang,
+ const char* name, bool so);
+
typedef std::map<std::string, std::string> ByLanguageMap;
std::string GetFlags(const std::string &l);
ByLanguageMap FlagsByLanguage;
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 13098ad..2796fdf 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -931,7 +931,7 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
//----------------------------------------------------------------------------
int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
- int count = 2;
+ unsigned int count = 2;
for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
if(cmGeneratorTarget const* target = this->EntryList[*ni].Target)
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 4a1f770..b639c15 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -19,13 +19,42 @@
#include <assert.h>
-int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
+int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
+ bool isTryRun)
{
this->BinaryDirectory = argv[1].c_str();
this->OutputFile = "";
// which signature were we called with ?
this->SrcFileSignature = true;
+ cmState::TargetType targetType = cmState::EXECUTABLE;
+ const char* tt =
+ this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE");
+ if (!isTryRun && tt && *tt)
+ {
+ if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0)
+ {
+ targetType = cmState::EXECUTABLE;
+ }
+ else if (strcmp(tt,
+ cmState::GetTargetTypeName(cmState::STATIC_LIBRARY)) == 0)
+ {
+ targetType = cmState::STATIC_LIBRARY;
+ }
+ else
+ {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ std::string("Invalid value '") + tt + "' for "
+ "CMAKE_TRY_COMPILE_TARGET_TYPE. Only "
+ "'" + cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and "
+ "'" + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) + "' "
+ "are allowed."
+ );
+ return -1;
+ }
+ }
+
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
std::string targetName;
@@ -486,11 +515,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee);
}
- /* Put the executable at a known location (for COPY_FILE). */
- fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
- this->BinaryDirectory.c_str());
- /* Create the actual executable. */
- fprintf(fout, "add_executable(%s", targetName.c_str());
+ if (targetType == cmState::EXECUTABLE)
+ {
+ /* Put the executable at a known location (for COPY_FILE). */
+ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
+ this->BinaryDirectory.c_str());
+ /* Create the actual executable. */
+ fprintf(fout, "add_executable(%s", targetName.c_str());
+ }
+ else // if (targetType == cmState::STATIC_LIBRARY)
+ {
+ /* Put the static library at a known location (for COPY_FILE). */
+ fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n",
+ this->BinaryDirectory.c_str());
+ /* Create the actual static library. */
+ fprintf(fout, "add_library(%s STATIC", targetName.c_str());
+ }
for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si)
{
@@ -549,7 +589,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (this->SrcFileSignature)
{
std::string copyFileErrorMessage;
- this->FindOutputFile(targetName);
+ this->FindOutputFile(targetName, targetType);
if ((res==0) && !copyFile.empty())
{
@@ -651,13 +691,26 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
}
-void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
+void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
+ cmState::TargetType targetType)
{
this->FindErrorMessage = "";
this->OutputFile = "";
std::string tmpOutputFile = "/";
- tmpOutputFile += targetName;
- tmpOutputFile +=this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
+ if (targetType == cmState::EXECUTABLE)
+ {
+ tmpOutputFile += targetName;
+ tmpOutputFile +=
+ this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
+ }
+ else // if (targetType == cmState::STATIC_LIBRARY)
+ {
+ tmpOutputFile +=
+ this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX");
+ tmpOutputFile += targetName;
+ tmpOutputFile +=
+ this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
+ }
// a list of directories where to search for the compilation result
// at first directly in the binary dir
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 3272462..c2beea8 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -30,7 +30,7 @@ public:
* commands, such as TryRun can access the same logic without
* duplication.
*/
- int TryCompileCode(std::vector<std::string> const& argv);
+ int TryCompileCode(std::vector<std::string> const& argv, bool isTryRun);
/**
* This deletes all the files created by TryCompileCode.
@@ -44,8 +44,8 @@ public:
TryCompileCode. The result is stored in OutputFile. If nothing is found,
the error message is stored in FindErrorMessage.
*/
- void FindOutputFile(const std::string& targetName);
-
+ void FindOutputFile(const std::string& targetName,
+ cmState::TargetType targetType);
cmTypeMacro(cmCoreTryCompile, cmCommand);
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 54c27d6..e670991 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -78,8 +78,7 @@ bool cmCreateTestSourceList
driver += *i;
++i;
- std::string configFile =
- this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
+ std::string configFile = cmSystemTools::GetCMakeRoot();
configFile += "/Templates/TestDriver.cxx.in";
// Create the test driver file
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 9348ef2..52512a8 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -18,7 +18,7 @@
#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/SystemTools.hxx>
@@ -101,11 +101,11 @@ struct Tree
void InsertPath(const std::vector<std::string>& splitted,
std::vector<std::string>::size_type start,
const std::string& fileName);
- void BuildVirtualFolder(std::string& virtualFolders) const;
+ void BuildVirtualFolder(cmXMLWriter& xml) const;
void BuildVirtualFolderImpl(std::string& virtualFolders,
const std::string& prefix) const;
- void BuildUnit(std::string& unitString, const std::string& fsPath) const;
- void BuildUnitImpl(std::string& unitString,
+ void BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const;
+ void BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const;
};
@@ -159,16 +159,18 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
}
-void Tree::BuildVirtualFolder(std::string& virtualFolders) const
+void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
{
- virtualFolders += "<Option virtualFolders=\"CMake Files\\;";
+ xml.StartElement("Option");
+ std::string virtualFolders = "CMake Files\\;";
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
it->BuildVirtualFolderImpl(virtualFolders, "");
}
- virtualFolders += "\" />";
+ xml.Attribute("virtualFolders", virtualFolders);
+ xml.EndElement();
}
@@ -185,26 +187,31 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
}
-void Tree::BuildUnit(std::string& unitString, const std::string& fsPath) const
+void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
{
for (std::vector<std::string>::const_iterator it = files.begin();
it != files.end();
++it)
{
- unitString += " <Unit filename=\"" + fsPath + *it + "\">\n";
- unitString += " <Option virtualFolder=\"CMake Files\\\" />\n";
- unitString += " </Unit>\n";
+ xml.StartElement("Unit");
+ xml.Attribute("filename", fsPath + *it);
+
+ xml.StartElement("Option");
+ xml.Attribute("virtualFolder", "CMake Files\\");
+ xml.EndElement();
+
+ xml.EndElement();
}
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
- it->BuildUnitImpl(unitString, "", fsPath);
+ it->BuildUnitImpl(xml, "", fsPath);
}
}
-void Tree::BuildUnitImpl(std::string& unitString,
+void Tree::BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const
{
@@ -212,16 +219,21 @@ void Tree::BuildUnitImpl(std::string& unitString,
it != files.end();
++it)
{
- unitString += " <Unit filename=\"" +fsPath+path+ "/" + *it + "\">\n";
- unitString += " <Option virtualFolder=\"CMake Files\\"
- + virtualFolderPath + path + "\\\" />\n";
- unitString += " </Unit>\n";
+ xml.StartElement("Unit");
+ xml.Attribute("filename", fsPath + path + "/" + *it);
+
+ xml.StartElement("Option");
+ xml.Attribute("virtualFolder",
+ "CMake Files\\" + virtualFolderPath + path + "\\");
+ xml.EndElement();
+
+ xml.EndElement();
}
for (std::vector<Tree>::const_iterator it = folders.begin();
it != folders.end();
++it)
{
- it->BuildUnitImpl(unitString,
+ it->BuildUnitImpl(xml,
virtualFolderPath + path + "\\", fsPath + path + "/");
}
}
@@ -259,13 +271,12 @@ void cmExtraCodeBlocksGenerator
}
// Convert
- const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
for (std::vector<std::string>::const_iterator jt = listFiles.begin();
jt != listFiles.end();
++jt)
{
// don't put cmake's own files into the project (#12110):
- if (jt->find(cmakeRoot) == 0)
+ if (jt->find(cmSystemTools::GetCMakeRoot()) == 0)
{
continue;
}
@@ -290,28 +301,42 @@ void cmExtraCodeBlocksGenerator
}
}
- // Now build a virtual tree string
- std::string virtualFolders;
- tree.BuildVirtualFolder(virtualFolders);
- // And one for <Unit>
- std::string unitFiles;
- tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/");
-
// figure out the compiler
std::string compiler = this->GetCBCompilerId(mf);
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string makeArgs = mf->GetSafeDefinition(
+ "CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
+
+ cmXMLWriter xml(fout);
+ xml.StartDocument();
+ xml.StartElement("CodeBlocks_project_file");
+
+ xml.StartElement("FileVersion");
+ xml.Attribute("major", 1);
+ xml.Attribute("minor", 6);
+ xml.EndElement();
+
+ xml.StartElement("Project");
- fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"
- "<CodeBlocks_project_file>\n"
- " <FileVersion major=\"1\" minor=\"6\" />\n"
- " <Project>\n"
- " <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n"
- " <Option makefile_is_custom=\"1\" />\n"
- " <Option compiler=\"" << compiler << "\" />\n"
- " "<<virtualFolders<<"\n"
- " <Build>\n";
+ xml.StartElement("Option");
+ xml.Attribute("title", lgs[0]->GetProjectName());
+ xml.EndElement();
- this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str());
+ xml.StartElement("Option");
+ xml.Attribute("makefile_is_custom", 1);
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("compiler", compiler);
+ xml.EndElement();
+
+ // Now build a virtual tree
+ tree.BuildVirtualFolder(xml);
+
+ xml.StartElement("Build");
+
+ this->AppendTarget(xml, "all", 0, make.c_str(), lgs[0], compiler.c_str(),
+ makeArgs);
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
@@ -332,8 +357,9 @@ void cmExtraCodeBlocksGenerator
if (strcmp((*lg)->GetCurrentBinaryDirectory(),
(*lg)->GetBinaryDirectory())==0)
{
- this->AppendTarget(fout, targetName, 0,
- make.c_str(), *lg, compiler.c_str());
+ this->AppendTarget(xml, targetName, 0,
+ make.c_str(), *lg, compiler.c_str(),
+ makeArgs);
}
}
break;
@@ -349,8 +375,8 @@ void cmExtraCodeBlocksGenerator
break;
}
- this->AppendTarget(fout, targetName, 0,
- make.c_str(), *lg, compiler.c_str());
+ this->AppendTarget(xml, targetName, 0,
+ make.c_str(), *lg, compiler.c_str(),makeArgs);
break;
case cmState::EXECUTABLE:
case cmState::STATIC_LIBRARY:
@@ -359,12 +385,12 @@ void cmExtraCodeBlocksGenerator
case cmState::OBJECT_LIBRARY:
{
cmGeneratorTarget* gt = *ti;
- this->AppendTarget(fout, targetName, gt,
- make.c_str(), *lg, compiler.c_str());
+ this->AppendTarget(xml, targetName, gt,
+ make.c_str(), *lg, compiler.c_str(), makeArgs);
std::string fastTarget = targetName;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget, gt,
- make.c_str(), *lg, compiler.c_str());
+ this->AppendTarget(xml, fastTarget, gt,
+ make.c_str(), *lg, compiler.c_str(), makeArgs);
}
break;
default:
@@ -373,8 +399,7 @@ void cmExtraCodeBlocksGenerator
}
}
- fout<<" </Build>\n";
-
+ xml.EndElement(); // Build
// Collect all used source files in the project.
// Keep a list of C/C++ source files which might have an acompanying header
@@ -502,24 +527,27 @@ void cmExtraCodeBlocksGenerator
std::string const& unitFilename = sit->first;
CbpUnit const& unit = sit->second;
- fout<<" <Unit filename=\""<< cmXMLSafe(unitFilename) <<"\">\n";
+ xml.StartElement("Unit");
+ xml.Attribute("filename", unitFilename);
for(std::vector<const cmGeneratorTarget*>::const_iterator ti =
unit.Targets.begin();
ti != unit.Targets.end(); ++ti)
{
- std::string const& targetName = (*ti)->GetName();
- fout<<" <Option target=\""<< cmXMLSafe(targetName) <<"\"/>\n";
+ xml.StartElement("Option");
+ xml.Attribute("target", (*ti)->GetName());
+ xml.EndElement();
}
- fout<<" </Unit>\n";
+ xml.EndElement();
}
// Add CMakeLists.txt
- fout<<unitFiles;
+ tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/");
- fout<<" </Project>\n"
- "</CodeBlocks_project_file>\n";
+ xml.EndElement(); // Project
+ xml.EndElement(); // CodeBlocks_project_file
+ xml.EndDocument();
}
@@ -550,18 +578,21 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
-void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
+void cmExtraCodeBlocksGenerator::AppendTarget(cmXMLWriter& xml,
const std::string& targetName,
cmGeneratorTarget* target,
const char* make,
const cmLocalGenerator* lg,
- const char* compiler)
+ const char* compiler,
+ const std::string& makeFlags)
{
cmMakefile const* makefile = lg->GetMakefile();
std::string makefileName = lg->GetCurrentBinaryDirectory();
makefileName += "/Makefile";
- fout<<" <Target title=\"" << targetName << "\">\n";
+ xml.StartElement("Target");
+ xml.Attribute("title", targetName);
+
if (target!=0)
{
int cbTargetType = this->GetCBTargetType(target);
@@ -599,13 +630,29 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
location = target->GetLocation(buildType);
}
- fout<<" <Option output=\"" << location
- << "\" prefix_auto=\"0\" extension_auto=\"0\" />\n"
- " <Option working_dir=\"" << workingDir << "\" />\n"
- " <Option object_output=\"./\" />\n"
- " <Option type=\"" << cbTargetType << "\" />\n"
- " <Option compiler=\"" << compiler << "\" />\n"
- " <Compiler>\n";
+ xml.StartElement("Option");
+ xml.Attribute("output", location);
+ xml.Attribute("prefix_auto", 0);
+ xml.Attribute("extension_auto", 0);
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("working_dir", workingDir);
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("object_output", "./");
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("type", cbTargetType);
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("compiler", compiler);
+ xml.EndElement();
+
+ xml.StartElement("Compiler");
// the compilerdefines for this target
std::vector<std::string> cdefs;
@@ -615,8 +662,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
for(std::vector<std::string>::const_iterator di = cdefs.begin();
di != cdefs.end(); ++di)
{
- cmXMLSafe safedef(di->c_str());
- fout <<" <Add option=\"-D" << safedef.str() << "\" />\n";
+ xml.StartElement("Add");
+ xml.Attribute("option", "-D" + *di);
+ xml.EndElement();
}
// the include directories for this target
@@ -649,34 +697,48 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
dirIt != uniqIncludeDirs.end();
++dirIt)
{
- fout <<" <Add directory=\"" << *dirIt << "\" />\n";
+ xml.StartElement("Add");
+ xml.Attribute("directory", *dirIt);
+ xml.EndElement();
}
- fout<<" </Compiler>\n";
+ xml.EndElement(); // Compiler
}
else // e.g. all and the GLOBAL and UTILITY targets
{
- fout<<" <Option working_dir=\""
- << lg->GetCurrentBinaryDirectory() << "\" />\n"
- <<" <Option type=\"" << 4 << "\" />\n";
- }
-
- fout<<" <MakeCommands>\n"
- " <Build command=\""
- << this->BuildMakeCommand(make, makefileName.c_str(), targetName)
- << "\" />\n"
- " <CompileFile command=\""
- << this->BuildMakeCommand(make, makefileName.c_str(),"&quot;$file&quot;")
- << "\" />\n"
- " <Clean command=\""
- << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
- << "\" />\n"
- " <DistClean command=\""
- << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
- << "\" />\n"
- " </MakeCommands>\n"
- " </Target>\n";
+ xml.StartElement("Option");
+ xml.Attribute("working_dir", lg->GetCurrentBinaryDirectory());
+ xml.EndElement();
+
+ xml.StartElement("Option");
+ xml.Attribute("type", 4);
+ xml.EndElement();
+ }
+
+ xml.StartElement("MakeCommands");
+
+ xml.StartElement("Build");
+ xml.Attribute("command",
+ this->BuildMakeCommand(make, makefileName.c_str(), targetName, makeFlags));
+ xml.EndElement();
+ xml.StartElement("CompileFile");
+ xml.Attribute("command",
+ this->BuildMakeCommand(make, makefileName.c_str(),"\"$file\"", makeFlags));
+ xml.EndElement();
+
+ xml.StartElement("Clean");
+ xml.Attribute("command",
+ this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
+ xml.EndElement();
+
+ xml.StartElement("DistClean");
+ xml.Attribute("command",
+ this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
+ xml.EndElement();
+
+ xml.EndElement(); //MakeCommands
+ xml.EndElement(); //Target
}
@@ -684,18 +746,38 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
{
// figure out which language to use
- // for now care only for C and C++
- std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
- if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false)
+ // for now care only for C, C++, and Fortran
+
+ // projects with C/C++ and Fortran are handled as C/C++ projects
+ bool pureFortran = false;
+ std::string compilerIdVar;
+ if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true)
+ {
+ compilerIdVar = "CMAKE_CXX_COMPILER_ID";
+ }
+ else if (this->GlobalGenerator->GetLanguageEnabled("C") == true)
{
compilerIdVar = "CMAKE_C_COMPILER_ID";
}
+ else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true)
+ {
+ compilerIdVar = "CMAKE_Fortran_COMPILER_ID";
+ pureFortran = true;
+ }
+
std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gcc"; // default to gcc
if (compilerId == "MSVC")
{
- compiler = "msvc8";
+ if( mf->IsDefinitionSet("MSVC10") == true )
+ {
+ compiler = "msvc10";
+ }
+ else
+ {
+ compiler = "msvc8";
+ }
}
else if (compilerId == "Borland")
{
@@ -707,15 +789,44 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
}
else if (compilerId == "Intel")
{
- compiler = "icc";
+ if (pureFortran && mf->IsDefinitionSet("WIN32"))
+ {
+ compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran)
+ }
+ else
+ {
+ compiler = "icc";
+ }
}
else if (compilerId == "Watcom" || compilerId == "OpenWatcom")
{
compiler = "ow";
}
+ else if (compilerId == "Clang")
+ {
+ compiler = "clang";
+ }
+ else if (compilerId == "PGI")
+ {
+ if (pureFortran)
+ {
+ compiler = "pgifortran";
+ }
+ else
+ {
+ compiler = "pgi"; // does not exist as default in CodeBlocks 16.01
+ }
+ }
else if (compilerId == "GNU")
{
- compiler = "gcc";
+ if (pureFortran)
+ {
+ compiler = "gfortran";
+ }
+ else
+ {
+ compiler = "gcc";
+ }
}
return compiler;
}
@@ -753,9 +864,15 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
// make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
const std::string& make, const char* makefile,
- const std::string& target)
+ const std::string& target, const std::string& makeFlags)
{
std::string command = make;
+ if (makeFlags.size() > 0)
+ {
+ command += " ";
+ command += makeFlags;
+ }
+
std::string generator = this->GlobalGenerator->GetName();
if (generator == "NMake Makefiles")
{
@@ -764,7 +881,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
// http://public.kitware.com/Bug/view.php?id=13952
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += " /NOLOGO /f ";
- command += cmXMLSafe(makefileName).str();
+ command += makefileName;
command += " VERBOSE=1 ";
command += target;
}
@@ -773,9 +890,9 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
std::string makefileName = makefile;
- command += " -f &quot;";
+ command += " -f \"";
command += makefileName;
- command += "&quot; ";
+ command += "\" ";
command += " VERBOSE=1 ";
command += target;
}
@@ -787,9 +904,9 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
else
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
- command += " -f &quot;";
+ command += " -f \"";
command += makefileName;
- command += "&quot; ";
+ command += "\" ";
command += " VERBOSE=1 ";
command += target;
}
diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h
index 0c3846d..e2f09de 100644
--- a/Source/cmExtraCodeBlocksGenerator.h
+++ b/Source/cmExtraCodeBlocksGenerator.h
@@ -18,7 +18,7 @@
class cmLocalGenerator;
class cmMakefile;
class cmGeneratorTarget;
-class cmGeneratedFileStream;
+class cmXMLWriter;
/** \class cmExtraCodeBlocksGenerator
* \brief Write CodeBlocks project files for Makefile based projects
@@ -54,13 +54,16 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmGeneratorTarget* target);
std::string BuildMakeCommand(const std::string& make, const char* makefile,
- const std::string& target);
- void AppendTarget(cmGeneratedFileStream& fout,
+ const std::string& target,
+ const std::string& makeFlags);
+ void AppendTarget(cmXMLWriter& xml,
const std::string& targetName,
cmGeneratorTarget* target,
const char* make,
const cmLocalGenerator* lg,
- const char* compiler);
+ const char* compiler,
+ const std::string& makeFlags
+ );
};
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 67aa157..9fc7b1e 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -24,7 +24,7 @@
#include <cmsys/SystemInformation.hxx>
#include <cmsys/Directory.hxx>
#include "cmStandardIncludes.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
//----------------------------------------------------------------------------
void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
@@ -54,16 +54,14 @@ void cmExtraCodeLiteGenerator::Generate()
std::string workspaceOutputDir;
std::string workspaceFileName;
std::string workspaceSourcePath;
- std::string lprjdebug;
- cmGeneratedFileStream fout;
+ const std::map<std::string, std::vector<cmLocalGenerator*> >& projectMap =
+ this->GlobalGenerator->GetProjectMap();
// loop projects and locate the root project.
// and extract the information for creating the worspace
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it!= this->GlobalGenerator->GetProjectMap().end();
- ++it)
+ it = projectMap.begin(); it!= projectMap.end(); ++it)
{
const cmMakefile* mf =it->second[0]->GetMakefile();
this->ConfigName = GetConfigurationName( mf );
@@ -77,18 +75,20 @@ void cmExtraCodeLiteGenerator::Generate()
workspaceFileName = workspaceOutputDir+"/";
workspaceFileName += workspaceProjectName + ".workspace";
this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();;
-
- fout.Open(workspaceFileName.c_str(), false, false);
- fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
- "<CodeLite_Workspace Name=\"" << workspaceProjectName << "\" >\n";
+ break;
}
}
+ cmGeneratedFileStream fout(workspaceFileName.c_str());
+ cmXMLWriter xml(fout);
+
+ xml.StartDocument("utf-8");
+ xml.StartElement("CodeLite_Workspace");
+ xml.Attribute("Name", workspaceProjectName);
+
// for each sub project in the workspace create a codelite project
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it!= this->GlobalGenerator->GetProjectMap().end();
- ++it)
+ it = projectMap.begin(); it!= projectMap.end(); ++it)
{
// retrive project information
std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
@@ -101,19 +101,33 @@ void cmExtraCodeLiteGenerator::Generate()
// create a project file
this->CreateProjectFile(it->second);
- fout << " <Project Name=\"" << projectName << "\" Path=\""
- << filename << "\" Active=\"No\"/>\n";
- lprjdebug += "<Project Name=\"" + projectName
- + "\" ConfigName=\"" + this->ConfigName + "\"/>\n";
+ xml.StartElement("Project");
+ xml.Attribute("Name", projectName);
+ xml.Attribute("Path", filename);
+ xml.Attribute("Active", "No");
+ xml.EndElement();
+ }
+
+ xml.StartElement("BuildMatrix");
+ xml.StartElement("WorkspaceConfiguration");
+ xml.Attribute("Name", this->ConfigName);
+ xml.Attribute("Selected", "yes");
+
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
+ it = projectMap.begin(); it!= projectMap.end(); ++it)
+ {
+ // retrive project information
+ std::string projectName = it->second[0]->GetProjectName();
+
+ xml.StartElement("Project");
+ xml.Attribute("Name", projectName);
+ xml.Attribute("ConfigName", this->ConfigName);
+ xml.EndElement();
}
- fout << " <BuildMatrix>\n"
- " <WorkspaceConfiguration Name=\""
- << this->ConfigName << "\" Selected=\"yes\">\n"
- " " << lprjdebug << ""
- " </WorkspaceConfiguration>\n"
- " </BuildMatrix>\n"
- "</CodeLite_Workspace>\n";
+ xml.EndElement(); // WorkspaceConfiguration
+ xml.EndElement(); // BuildMatrix
+ xml.EndElement(); // CodeLite_Workspace
}
/* create the project file */
@@ -138,11 +152,13 @@ void cmExtraCodeLiteGenerator
{
return;
}
+ cmXMLWriter xml(fout);
////////////////////////////////////
- fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
- "<CodeLite_Project Name=\"" << lgs[0]->GetProjectName()
- << "\" InternalType=\"\">\n";
+ xml.StartDocument("utf-8");
+ xml.StartElement("CodeLite_Project");
+ xml.Attribute("Name", lgs[0]->GetProjectName());
+ xml.Attribute("InternalType", "");
// Collect all used source files in the project
// Sort them into two containers, one for C/C++ implementation files
@@ -285,7 +301,8 @@ void cmExtraCodeLiteGenerator
// Create 2 virtual folders: src and include
// and place all the implementation files into the src
// folder, the rest goes to the include folder
- fout<< " <VirtualDirectory Name=\"src\">\n";
+ xml.StartElement("VirtualDirectory");
+ xml.Attribute("Name", "src");
// insert all source files in the codelite project
// first the C/C++ implementation files, then all others
@@ -294,22 +311,25 @@ void cmExtraCodeLiteGenerator
sit!=cFiles.end();
++sit)
{
- std::string relativePath =
- cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
- fout<< " <File Name=\"" << relativePath << "\"/>\n";
+ xml.StartElement("File");
+ xml.Attribute("Name",
+ cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()));
+ xml.EndElement();
}
- fout<< " </VirtualDirectory>\n";
- fout<< " <VirtualDirectory Name=\"include\">\n";
+ xml.EndElement(); // VirtualDirectory
+ xml.StartElement("VirtualDirectory");
+ xml.Attribute("Name", "include");
for (std::set<std::string>::const_iterator
sit=otherFiles.begin();
sit!=otherFiles.end();
++sit)
{
- std::string relativePath =
- cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str());
- fout << " <File Name=\"" << relativePath << "\"/>\n";
+ xml.StartElement("File");
+ xml.Attribute("Name",
+ cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()));
+ xml.EndElement();
}
- fout << " </VirtualDirectory>\n";
+ xml.EndElement(); // VirtualDirectory
// Get the number of CPUs. We use this information for the make -jN
// command
@@ -319,63 +339,99 @@ void cmExtraCodeLiteGenerator
this->CpuCount = info.GetNumberOfLogicalCPU() *
info.GetNumberOfPhysicalCPU();
- std::string cleanCommand = GetCleanCommand(mf);
- std::string buildCommand = GetBuildCommand(mf);
- std::string rebuildCommand = GetRebuildCommand(mf);
- std::string singleFileCommand = GetSingleFileBuildCommand(mf);
-
std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf);
- fout << "\n"
- " <Settings Type=\"" << projectType << "\">\n"
- " <Configuration Name=\"" << this->ConfigName << "\" CompilerType=\""
- << codeliteCompilerName << "\" DebuggerType=\"GNU gdb debugger\" "
- "Type=\""
- << projectType << "\" BuildCmpWithGlobalSettings=\"append\" "
- "BuildLnkWithGlobalSettings=\"append\" "
- "BuildResWithGlobalSettings=\"append\">\n"
- " <Compiler Options=\"-g\" "
- "Required=\"yes\" PreCompiledHeader=\"\">\n"
- " <IncludePath Value=\".\"/>\n"
- " </Compiler>\n"
- " <Linker Options=\"\" Required=\"yes\"/>\n"
- " <ResourceCompiler Options=\"\" Required=\"no\"/>\n"
- " <General OutputFile=\"$(IntermediateDirectory)/$(ProjectName)\" "
- "IntermediateDirectory=\"./\" Command=\"./$(ProjectName)\" "
- "CommandArguments=\"\" WorkingDirectory=\"$(IntermediateDirectory)\" "
- "PauseExecWhenProcTerminates=\"yes\"/>\n"
- " <Debugger IsRemote=\"no\" RemoteHostName=\"\" "
- "RemoteHostPort=\"\" DebuggerPath=\"\">\n"
- " <PostConnectCommands/>\n"
- " <StartupCommands/>\n"
- " </Debugger>\n"
- " <PreBuild/>\n"
- " <PostBuild/>\n"
- " <CustomBuild Enabled=\"yes\">\n"
- " <RebuildCommand>" << rebuildCommand << "</RebuildCommand>\n"
- " <CleanCommand>" << cleanCommand << "</CleanCommand>\n"
- " <BuildCommand>" << buildCommand << "</BuildCommand>\n"
- " <SingleFileCommand>" << singleFileCommand
- << "</SingleFileCommand>\n"
- " <PreprocessFileCommand/>\n"
- " <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>\n"
- " </CustomBuild>\n"
- " <AdditionalRules>\n"
- " <CustomPostBuild/>\n"
- " <CustomPreBuild/>\n"
- " </AdditionalRules>\n"
- " </Configuration>\n"
- " <GlobalSettings>\n"
- " <Compiler Options=\"\">\n"
- " <IncludePath Value=\".\"/>\n"
- " </Compiler>\n"
- " <Linker Options=\"\">\n"
- " <LibraryPath Value=\".\"/>\n"
- " </Linker>\n"
- " <ResourceCompiler Options=\"\"/>\n"
- " </GlobalSettings>\n"
- " </Settings>\n"
- "</CodeLite_Project>\n";
+ xml.StartElement("Settings");
+ xml.Attribute("Type", projectType);
+
+ xml.StartElement("Configuration");
+ xml.Attribute("Name", this->ConfigName);
+ xml.Attribute("CompilerType", this->GetCodeLiteCompilerName(mf));
+ xml.Attribute("DebuggerType", "GNU gdb debugger");
+ xml.Attribute("Type", projectType);
+ xml.Attribute("BuildCmpWithGlobalSettings", "append");
+ xml.Attribute("BuildLnkWithGlobalSettings", "append");
+ xml.Attribute("BuildResWithGlobalSettings", "append");
+
+ xml.StartElement("Compiler");
+ xml.Attribute("Options", "-g");
+ xml.Attribute("Required", "yes");
+ xml.Attribute("PreCompiledHeader", "");
+ xml.StartElement("IncludePath");
+ xml.Attribute("Value", ".");
+ xml.EndElement(); // IncludePath
+ xml.EndElement(); // Compiler
+
+ xml.StartElement("Linker");
+ xml.Attribute("Options", "");
+ xml.Attribute("Required", "yes");
+ xml.EndElement(); // Linker
+
+ xml.StartElement("ResourceCompiler");
+ xml.Attribute("Options", "");
+ xml.Attribute("Required", "no");
+ xml.EndElement(); // ResourceCompiler
+
+ xml.StartElement("General");
+ xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");
+ xml.Attribute("IntermediateDirectory", "./");
+ xml.Attribute("Command", "./$(ProjectName)");
+ xml.Attribute("CommandArguments", "");
+ xml.Attribute("WorkingDirectory", "$(IntermediateDirectory)");
+ xml.Attribute("PauseExecWhenProcTerminates", "yes");
+ xml.EndElement(); // General
+
+ xml.StartElement("Debugger");
+ xml.Attribute("IsRemote", "no");
+ xml.Attribute("RemoteHostName", "");
+ xml.Attribute("RemoteHostPort", "");
+ xml.Attribute("DebuggerPath", "");
+ xml.Element("PostConnectCommands");
+ xml.Element("StartupCommands");
+ xml.EndElement(); // Debugger
+
+ xml.Element("PreBuild");
+ xml.Element("PostBuild");
+
+ xml.StartElement("CustomBuild");
+ xml.Attribute("Enabled", "yes");
+ xml.Element("RebuildCommand", GetRebuildCommand(mf));
+ xml.Element("CleanCommand", GetCleanCommand(mf));
+ xml.Element("BuildCommand", GetBuildCommand(mf));
+ xml.Element("SingleFileCommand", GetSingleFileBuildCommand(mf));
+ xml.Element("PreprocessFileCommand");
+ xml.Element("WorkingDirectory", "$(WorkspacePath)");
+ xml.EndElement(); // CustomBuild
+
+ xml.StartElement("AdditionalRules");
+ xml.Element("CustomPostBuild");
+ xml.Element("CustomPreBuild");
+ xml.EndElement(); // AdditionalRules
+
+ xml.EndElement(); // Configuration
+ xml.StartElement("GlobalSettings");
+
+ xml.StartElement("Compiler");
+ xml.Attribute("Options", "");
+ xml.StartElement("IncludePath");
+ xml.Attribute("Value", ".");
+ xml.EndElement(); // IncludePath
+ xml.EndElement(); // Compiler
+
+ xml.StartElement("Linker");
+ xml.Attribute("Options", "");
+ xml.StartElement("LibraryPath");
+ xml.Attribute("Value", ".");
+ xml.EndElement(); // LibraryPath
+ xml.EndElement(); // Linker
+
+ xml.StartElement("ResourceCompiler");
+ xml.Attribute("Options", "");
+ xml.EndElement(); // ResourceCompiler
+
+ xml.EndElement(); // GlobalSettings
+ xml.EndElement(); // Settings
+ xml.EndElement(); // CodeLite_Project
}
std::string
@@ -454,7 +510,7 @@ cmExtraCodeLiteGenerator::GetCleanCommand(const cmMakefile* mf) const
std::string
cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const
{
- return GetCleanCommand(mf) + cmXMLSafe(" && ").str() + GetBuildCommand(mf);
+ return GetCleanCommand(mf) + " && " + GetBuildCommand(mf);
}
std::string
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index aedf6f4..f0227b0 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -19,11 +19,29 @@
#include "cmState.h"
#include "cmTarget.h"
#include "cmSourceFile.h"
+#include "cmXMLWriter.h"
#include "cmSystemTools.h"
#include <stdlib.h>
#include <assert.h>
+static void AppendAttribute(cmXMLWriter& xml, const char* keyval)
+{
+ xml.StartElement("attribute");
+ xml.Attribute("key", keyval);
+ xml.Attribute("value", keyval);
+ xml.EndElement();
+}
+
+template<typename T>
+void AppendDictionary(cmXMLWriter& xml, const char* key, T const& value)
+{
+ xml.StartElement("dictionary");
+ xml.Element("key", key);
+ xml.Element("value", value);
+ xml.EndElement();
+}
+
//----------------------------------------------------------------------------
cmExtraEclipseCDT4Generator
::cmExtraEclipseCDT4Generator() : cmExternalMakefileProjectGenerator()
@@ -42,6 +60,8 @@ cmExtraEclipseCDT4Generator
this->GenerateLinkedResources = true;
this->SupportsGmakeErrorParser = true;
this->SupportsMachO64Parser = true;
+ this->CEnabled = false;
+ this->CXXEnabled = false;
}
//----------------------------------------------------------------------------
@@ -64,10 +84,12 @@ void cmExtraEclipseCDT4Generator
{
this->Natures.insert("org.eclipse.cdt.core.ccnature");
this->Natures.insert("org.eclipse.cdt.core.cnature");
+ this->CXXEnabled = true;
}
else if (*lit == "C")
{
this->Natures.insert("org.eclipse.cdt.core.cnature");
+ this->CEnabled = true;
}
else if (*lit == "Java")
{
@@ -168,34 +190,30 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
return;
}
- fout <<
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<projectDescription>\n"
- "\t<name>" << this->EscapeForXML(name) << "</name>\n"
- "\t<comment></comment>\n"
- "\t<projects>\n"
- "\t</projects>\n"
- "\t<buildSpec>\n"
- "\t</buildSpec>\n"
- "\t<natures>\n"
- "\t</natures>\n"
- "\t<linkedResources>\n";
+ cmXMLWriter xml(fout);
+ xml.StartDocument("UTF-8");
+ xml.StartElement("projectDescription");
+ xml.Element("name", name);
+ xml.Element("comment", "");
+ xml.Element("projects", "");
+ xml.Element("buildSpec", "");
+ xml.Element("natures", "");
+ xml.StartElement("linkedResources");
if (this->SupportsVirtualFolders)
{
- this->CreateLinksToSubprojects(fout, this->HomeDirectory);
+ this->CreateLinksToSubprojects(xml, this->HomeDirectory);
this->SrcLinkedResources.clear();
}
- fout <<
- "\t</linkedResources>\n"
- "</projectDescription>\n"
- ;
+ xml.EndElement(); // linkedResources
+ xml.EndElement(); // projectDescription
+ xml.EndDocument();
}
//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
+void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
const char* envVar,
cmLocalGenerator* lg)
{
@@ -253,7 +271,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
if (!valueToUse.empty())
{
- fout << envVar << "=" << valueToUse << "|";
+ out << envVar << "=" << valueToUse << "|";
}
}
@@ -278,197 +296,125 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
}
- fout <<
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<projectDescription>\n"
- "\t<name>" <<
- this->GenerateProjectName(lg->GetProjectName(),
- mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
- this->GetPathBasename(this->HomeOutputDirectory))
- << "</name>\n"
- "\t<comment></comment>\n"
- "\t<projects>\n"
- "\t</projects>\n"
- "\t<buildSpec>\n"
- "\t\t<buildCommand>\n"
- "\t\t\t<name>org.eclipse.cdt.make.core.makeBuilder</name>\n"
- "\t\t\t<triggers>clean,full,incremental,</triggers>\n"
- "\t\t\t<arguments>\n"
- ;
+ cmXMLWriter xml(fout);
+
+ xml.StartDocument("UTF-8");
+ xml.StartElement("projectDescription");
+
+ xml.Element("name", this->GenerateProjectName(lg->GetProjectName(),
+ mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
+ this->GetPathBasename(this->HomeOutputDirectory)));
+
+ xml.Element("comment", "");
+ xml.Element("projects", "");
+
+ xml.StartElement("buildSpec");
+ xml.StartElement("buildCommand");
+ xml.Element("name", "org.eclipse.cdt.make.core.makeBuilder");
+ xml.Element("triggers", "clean,full,incremental,");
+ xml.StartElement("arguments");
// use clean target
- fout <<
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>\n"
- "\t\t\t\t\t<value>clean</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableCleanBuild</key>\n"
- "\t\t\t\t\t<value>true</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.append_environment</key>\n"
- "\t\t\t\t\t<value>true</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.stopOnError</key>\n"
- "\t\t\t\t\t<value>true</value>\n"
- "\t\t\t\t</dictionary>\n"
- ;
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.cleanBuildTarget", "clean");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.enableCleanBuild", "true");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.append_environment","true");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.stopOnError", "true");
// set the make command
- std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- const std::string makeArgs = mf->GetSafeDefinition(
- "CMAKE_ECLIPSE_MAKE_ARGUMENTS");
-
- fout <<
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>\n"
- "\t\t\t\t\t<value>true</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.command</key>\n"
- "\t\t\t\t\t<value>" << this->GetEclipsePath(make) << "</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.contents</key>\n"
- "\t\t\t\t\t<value>org.eclipse.cdt.make.core.activeConfigSettings</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.inc</key>\n"
- "\t\t\t\t\t<value>all</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.arguments</key>\n"
- "\t\t\t\t\t<value>" << makeArgs << "</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildLocation</key>\n"
- "\t\t\t\t\t<value>"
- << this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>\n"
- "\t\t\t\t\t<value>false</value>\n"
- "\t\t\t\t</dictionary>\n"
- ;
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.enabledIncrementalBuild",
+ "true");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.command",
+ this->GetEclipsePath(mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")));
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.contents",
+ "org.eclipse.cdt.make.core.activeConfigSettings");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.inc", "all");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.arguments",
+ mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS"));
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.buildLocation",
+ this->GetEclipsePath(this->HomeOutputDirectory));
+ AppendDictionary(xml,
+ "org.eclipse.cdt.make.core.useDefaultBuildCmd", "false");
// set project specific environment
- fout <<
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.environment</key>\n"
- "\t\t\t\t\t<value>VERBOSE=1|CMAKE_NO_VERBOSE=1|" //verbose Makefile output
- ;
+ std::stringstream environment;
+ environment << "VERBOSE=1|CMAKE_NO_VERBOSE=1|"; //verbose Makefile output
// set vsvars32.bat environment available at CMake time,
// but not necessarily when eclipse is open
if (compilerId == "MSVC")
{
- AddEnvVar(fout, "PATH", lg);
- AddEnvVar(fout, "INCLUDE", lg);
- AddEnvVar(fout, "LIB", lg);
- AddEnvVar(fout, "LIBPATH", lg);
+ AddEnvVar(environment, "PATH", lg);
+ AddEnvVar(environment, "INCLUDE", lg);
+ AddEnvVar(environment, "LIB", lg);
+ AddEnvVar(environment, "LIBPATH", lg);
}
else if (compilerId == "Intel")
{
// if the env.var is set, use this one and put it in the cache
// if the env.var is not set, but the value is in the cache,
// use it from the cache:
- AddEnvVar(fout, "INTEL_LICENSE_FILE", lg);
+ AddEnvVar(environment, "INTEL_LICENSE_FILE", lg);
}
- fout <<
- "</value>\n"
- "\t\t\t\t</dictionary>\n"
- ;
-
- fout <<
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableFullBuild</key>\n"
- "\t\t\t\t\t<value>true</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.auto</key>\n"
- "\t\t\t\t\t<value>all</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableAutoBuild</key>\n"
- "\t\t\t\t\t<value>false</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.clean</key>\n"
- "\t\t\t\t\t<value>clean</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.fullBuildTarget</key>\n"
- "\t\t\t\t\t<value>all</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildArguments</key>\n"
- "\t\t\t\t\t<value></value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.location</key>\n"
- "\t\t\t\t\t<value>"
- << this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
- "\t\t\t\t</dictionary>\n"
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.make.core.autoBuildTarget</key>\n"
- "\t\t\t\t\t<value>all</value>\n"
- "\t\t\t\t</dictionary>\n"
- ;
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.environment",
+ environment.str());
+
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.enableFullBuild", "true");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.auto", "all");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.enableAutoBuild", "false");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.clean",
+ "clean");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.fullBuildTarget", "all");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.buildArguments", "");
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.location",
+ this->GetEclipsePath(this->HomeOutputDirectory));
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all");
// set error parsers
- fout <<
- "\t\t\t\t<dictionary>\n"
- "\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n"
- "\t\t\t\t\t<value>"
- ;
+ std::stringstream errorOutputParser;
+
if (compilerId == "MSVC")
{
- fout << "org.eclipse.cdt.core.VCErrorParser;";
+ errorOutputParser << "org.eclipse.cdt.core.VCErrorParser;";
}
else if (compilerId == "Intel")
{
- fout << "org.eclipse.cdt.core.ICCErrorParser;";
+ errorOutputParser << "org.eclipse.cdt.core.ICCErrorParser;";
}
if (this->SupportsGmakeErrorParser)
{
- fout << "org.eclipse.cdt.core.GmakeErrorParser;";
+ errorOutputParser << "org.eclipse.cdt.core.GmakeErrorParser;";
}
else
{
- fout << "org.eclipse.cdt.core.MakeErrorParser;";
+ errorOutputParser << "org.eclipse.cdt.core.MakeErrorParser;";
}
- fout <<
+ errorOutputParser <<
"org.eclipse.cdt.core.GCCErrorParser;"
"org.eclipse.cdt.core.GASErrorParser;"
"org.eclipse.cdt.core.GLDErrorParser;"
- "</value>\n"
- "\t\t\t\t</dictionary>\n"
- ;
-
- fout <<
- "\t\t\t</arguments>\n"
- "\t\t</buildCommand>\n"
- "\t\t<buildCommand>\n"
- "\t\t\t<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>\n"
- "\t\t\t<arguments>\n"
- "\t\t\t</arguments>\n"
- "\t\t</buildCommand>\n"
- "\t</buildSpec>\n"
;
+ AppendDictionary(xml, "org.eclipse.cdt.core.errorOutputParser",
+ errorOutputParser.str());
+
+ xml.EndElement(); // arguments
+ xml.EndElement(); // buildCommand
+ xml.StartElement("buildCommand");
+ xml.Element("name", "org.eclipse.cdt.make.core.ScannerConfigBuilder");
+ xml.StartElement("arguments");
+ xml.EndElement(); // arguments
+ xml.EndElement(); // buildCommand
+ xml.EndElement(); // buildSpec
// set natures for c/c++ projects
- fout <<
- "\t<natures>\n"
- "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n"
- "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n";
+ xml.StartElement("natures");
+ xml.Element("nature", "org.eclipse.cdt.make.core.makeNature");
+ xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");;
for (std::set<std::string>::const_iterator nit=this->Natures.begin();
nit != this->Natures.end(); ++nit)
{
- fout << "\t\t<nature>" << *nit << "</nature>\n";
+ xml.Element("nature", *nit);
}
if (const char *extraNaturesProp = mf->GetState()
@@ -479,13 +425,13 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
nit != extraNatures.end(); ++nit)
{
- fout << "\t\t<nature>" << *nit << "</nature>\n";
+ xml.Element("nature", *nit);
}
}
- fout << "\t</natures>\n";
+ xml.EndElement(); // natures
- fout << "\t<linkedResources>\n";
+ xml.StartElement("linkedResources");
// create linked resources
if (this->IsOutOfSourceBuild)
{
@@ -502,7 +448,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
linkSourceDirectory))
{
- this->AppendLinkedResource(fout, sourceLinkedResourceName,
+ this->AppendLinkedResource(xml, sourceLinkedResourceName,
this->GetEclipsePath(linkSourceDirectory),
LinkToFolder);
this->SrcLinkedResources.push_back(sourceLinkedResourceName);
@@ -512,23 +458,21 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
if (this->SupportsVirtualFolders)
{
- this->CreateLinksToSubprojects(fout, this->HomeOutputDirectory);
+ this->CreateLinksToSubprojects(xml, this->HomeOutputDirectory);
- this->CreateLinksForTargets(fout);
+ this->CreateLinksForTargets(xml);
}
- fout << "\t</linkedResources>\n";
-
- fout << "</projectDescription>\n";
+ xml.EndElement(); // linkedResources
+ xml.EndElement(); // projectDescription
}
//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
- cmGeneratedFileStream& fout)
+void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
{
std::string linkName = "[Targets]";
- this->AppendLinkedResource(fout, linkName, "virtual:/virtual",VirtualFolder);
+ this->AppendLinkedResource(xml, linkName, "virtual:/virtual", VirtualFolder);
for (std::vector<cmLocalGenerator*>::const_iterator
lgIt = this->GlobalGenerator->GetLocalGenerators().begin();
@@ -556,7 +500,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
"[exe] " : "[lib] ");
linkName2 += prefix;
linkName2 += (*ti)->GetName();
- this->AppendLinkedResource(fout, linkName2, "virtual:/virtual",
+ this->AppendLinkedResource(xml, linkName2, "virtual:/virtual",
VirtualFolder);
if (!this->GenerateLinkedResources)
{
@@ -586,7 +530,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
std::string linkName3 = linkName2;
linkName3 += "/";
linkName3 += sgIt->GetFullName();
- this->AppendLinkedResource(fout, linkName3, "virtual:/virtual",
+ this->AppendLinkedResource(xml, linkName3, "virtual:/virtual",
VirtualFolder);
std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
@@ -601,7 +545,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
std::string linkName4 = linkName3;
linkName4 += "/";
linkName4 += cmSystemTools::GetFilenameName(fullPath);
- this->AppendLinkedResource(fout, linkName4,
+ this->AppendLinkedResource(xml, linkName4,
this->GetEclipsePath(fullPath),
LinkToFile);
}
@@ -620,7 +564,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
- cmGeneratedFileStream& fout, const std::string& baseDir)
+ cmXMLWriter& xml, const std::string& baseDir)
{
if (!this->GenerateLinkedResources)
{
@@ -629,7 +573,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
// for each sub project create a linked resource to the source dir
// - only if it is an out-of-source build
- this->AppendLinkedResource(fout, "[Subprojects]",
+ this->AppendLinkedResource(xml, "[Subprojects]",
"virtual:/virtual", VirtualFolder);
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
@@ -647,7 +591,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
{
std::string linkName = "[Subprojects]/";
linkName += it->first;
- this->AppendLinkedResource(fout, linkName,
+ this->AppendLinkedResource(xml, linkName,
this->GetEclipsePath(linkSourceDirectory),
LinkToFolder
);
@@ -660,7 +604,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
- cmGeneratedFileStream& fout,
+ cmXMLWriter& xml,
const std::vector<std::string>& includeDirs,
std::set<std::string>& emittedDirs)
{
@@ -684,10 +628,13 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
if(emittedDirs.find(dir) == emittedDirs.end())
{
emittedDirs.insert(dir);
- fout << "<pathentry include=\""
- << cmExtraEclipseCDT4Generator::EscapeForXML(
- cmExtraEclipseCDT4Generator::GetEclipsePath(dir))
- << "\" kind=\"inc\" path=\"\" system=\"true\"/>\n";
+ xml.StartElement("pathentry");
+ xml.Attribute("include",
+ cmExtraEclipseCDT4Generator::GetEclipsePath(dir));
+ xml.Attribute("kind", "inc");
+ xml.Attribute("path", "");
+ xml.Attribute("system", "true");
+ xml.EndElement();
}
}
}
@@ -709,95 +656,100 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
return;
}
+ cmXMLWriter xml(fout);
+
// add header
- fout <<
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
- "<?fileVersion 4.0.0?>\n\n"
- "<cproject>\n"
- "<storageModule moduleId=\"org.eclipse.cdt.core.settings\">\n"
- ;
+ xml.StartDocument("UTF-8");
+ xml.ProcessingInstruction("fileVersion", "4.0.0");
+ xml.StartElement("cproject");
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
- fout << "<cconfiguration id=\"org.eclipse.cdt.core.default.config.1\">\n";
+ xml.StartElement("cconfiguration");
+ xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
// Configuration settings...
- fout <<
- "<storageModule"
- " buildSystemId=\"org.eclipse.cdt.core.defaultConfigDataProvider\""
- " id=\"org.eclipse.cdt.core.default.config.1\""
- " moduleId=\"org.eclipse.cdt.core.settings\" name=\"Configuration\">\n"
- "<externalSettings/>\n"
- "<extensions>\n"
- ;
+ xml.StartElement("storageModule");
+ xml.Attribute("buildSystemId",
+ "org.eclipse.cdt.core.defaultConfigDataProvider");
+ xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
+ xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
+ xml.Attribute("name", "Configuration");
+ xml.Element("externalSettings");
+ xml.StartElement("extensions");
+
// TODO: refactor this out...
std::string executableFormat = mf->GetSafeDefinition(
"CMAKE_EXECUTABLE_FORMAT");
if (executableFormat == "ELF")
{
- fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
- " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
- ;
- fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\""
- " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
- "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
- "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
- "</extension>\n"
- ;
+ xml.StartElement("extension");
+ xml.Attribute("id", "org.eclipse.cdt.core.ELF");
+ xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+ xml.EndElement(); // extension
+
+ xml.StartElement("extension");
+ xml.Attribute("id", "org.eclipse.cdt.core.GNU_ELF");
+ xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+ AppendAttribute(xml, "addr2line");
+ AppendAttribute(xml, "c++filt");
+ xml.EndElement(); // extension
}
else
{
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (systemName == "CYGWIN")
{
- fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\""
- " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
- "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
- "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
- "<attribute key=\"cygpath\" value=\"cygpath\"/>\n"
- "<attribute key=\"nm\" value=\"nm\"/>\n"
- "</extension>\n"
- ;
+ xml.StartElement("extension");
+ xml.Attribute("id", "org.eclipse.cdt.core.Cygwin_PE");
+ xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+ AppendAttribute(xml, "addr2line");
+ AppendAttribute(xml, "c++filt");
+ AppendAttribute(xml, "cygpath");
+ AppendAttribute(xml, "nm");
+ xml.EndElement(); // extension
}
else if (systemName == "Windows")
{
- fout << "<extension id=\"org.eclipse.cdt.core.PE\""
- " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
- ;
+ xml.StartElement("extension");
+ xml.Attribute("id", "org.eclipse.cdt.core.PE");
+ xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+ xml.EndElement(); // extension
}
else if (systemName == "Darwin")
{
- fout << "<extension id=\"" <<
- (this->SupportsMachO64Parser ? "org.eclipse.cdt.core.MachO64"
- : "org.eclipse.cdt.core.MachO") << "\""
- " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
- "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
- "</extension>\n"
- ;
+ xml.StartElement("extension");
+ xml.Attribute("id", this->SupportsMachO64Parser ?
+ "org.eclipse.cdt.core.MachO64" : "org.eclipse.cdt.core.MachO");
+ xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+ AppendAttribute(xml, "c++filt");
+ xml.EndElement(); // extension
}
else
{
// *** Should never get here ***
- fout << "<error_toolchain_type/>\n";
+ xml.Element("error_toolchain_type");
}
}
- fout << "</extensions>\n"
- "</storageModule>\n"
- ;
+ xml.EndElement(); // extensions
+ xml.EndElement(); // storageModule
// ???
- fout <<
- "<storageModule moduleId=\"org.eclipse.cdt.core.language.mapping\">\n"
- "<project-mappings/>\n"
- "</storageModule>\n"
- ;
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "org.eclipse.cdt.core.language.mapping");
+ xml.Element("project-mappings");
+ xml.EndElement(); // storageModule
// ???
- fout<<"<storageModule moduleId=\"org.eclipse.cdt.core.externalSettings\"/>\n"
- ;
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "org.eclipse.cdt.core.externalSettings");
+ xml.EndElement(); // storageModule
// set the path entries (includes, libs, source dirs, etc.)
- fout << "<storageModule moduleId=\"org.eclipse.cdt.core.pathentry\">\n"
- ;
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "org.eclipse.cdt.core.pathentry");
+
// for each sub project with a linked resource to the source dir:
// - make it type 'src'
// - and exclude it from type 'out'
@@ -820,21 +772,27 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->SrcLinkedResources.end();
++it)
{
- fout << "<pathentry kind=\"src\" path=\"" << this->EscapeForXML(*it)
- << "\"/>\n";
+ xml.StartElement("pathentry");
+ xml.Attribute("kind", "src");
+ xml.Attribute("path", *it);
+ xml.EndElement();
// exlude source directory from output search path
// - only if not named the same as an output directory
if (!cmSystemTools::FileIsDirectory(
std::string(this->HomeOutputDirectory + "/" + *it)))
{
- excludeFromOut += this->EscapeForXML(*it) + "/|";
+ excludeFromOut += *it + "/|";
}
}
excludeFromOut += "**/CMakeFiles/";
- fout << "<pathentry excluding=\"" << excludeFromOut
- << "\" kind=\"out\" path=\"\"/>\n";
+
+ xml.StartElement("pathentry");
+ xml.Attribute("excluding", excludeFromOut);
+ xml.Attribute("kind", "out");
+ xml.Attribute("path", "");
+ xml.EndElement();
// add pre-processor definitions to allow eclipse to gray out sections
emmited.clear();
@@ -880,9 +838,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
if(emmited.find(def) == emmited.end())
{
emmited.insert(def);
- fout << "<pathentry kind=\"mac\" name=\"" << def
- << "\" path=\"\" value=\"" << this->EscapeForXML(val)
- << "\"/>\n";
+ xml.StartElement("pathentry");
+ xml.Attribute("kind", "mac");
+ xml.Attribute("name", def);
+ xml.Attribute("path", "");
+ xml.Attribute("value", val);
+ xml.EndElement();
}
}
}
@@ -890,7 +851,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add system defined c macros
const char* cDefs=mf->GetDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
- if(cDefs)
+ if(this->CEnabled && cDefs)
{
// Expand the list.
std::vector<std::string> defs;
@@ -915,9 +876,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
if(emmited.find(def) == emmited.end())
{
emmited.insert(def);
- fout << "<pathentry kind=\"mac\" name=\"" << def
- << "\" path=\"\" value=\"" << this->EscapeForXML(val)
- << "\"/>\n";
+ xml.StartElement("pathentry");
+ xml.Attribute("kind", "mac");
+ xml.Attribute("name", def);
+ xml.Attribute("path", "");
+ xml.Attribute("value", val);
+ xml.EndElement();
}
}
}
@@ -925,7 +889,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add system defined c++ macros
const char* cxxDefs = mf->GetDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
- if(cxxDefs)
+ if(this->CXXEnabled && cxxDefs)
{
// Expand the list.
std::vector<std::string> defs;
@@ -950,9 +914,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
if(emmited.find(def) == emmited.end())
{
emmited.insert(def);
- fout << "<pathentry kind=\"mac\" name=\"" << def
- << "\" path=\"\" value=\"" << this->EscapeForXML(val)
- << "\"/>\n";
+ xml.StartElement("pathentry");
+ xml.Attribute("kind", "mac");
+ xml.Attribute("name", def);
+ xml.Attribute("path", "");
+ xml.Attribute("value", val);
+ xml.EndElement();
}
}
}
@@ -972,38 +939,37 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::vector<std::string> includeDirs;
std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
(*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
- this->AppendIncludeDirectories(fout, includeDirs, emmited);
+ this->AppendIncludeDirectories(xml, includeDirs, emmited);
}
}
// now also the system include directories, in case we found them in
// CMakeSystemSpecificInformation.cmake. This makes Eclipse find the
// standard headers.
std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER");
- if (!compiler.empty())
+ if (this->CEnabled && !compiler.empty())
{
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
std::vector<std::string> dirs;
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- this->AppendIncludeDirectories(fout, dirs, emmited);
+ this->AppendIncludeDirectories(xml, dirs, emmited);
}
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
- if (!compiler.empty())
+ if (this->CXXEnabled && !compiler.empty())
{
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
std::vector<std::string> dirs;
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- this->AppendIncludeDirectories(fout, dirs, emmited);
+ this->AppendIncludeDirectories(xml, dirs, emmited);
}
- fout << "</storageModule>\n";
+ xml.EndElement(); // storageModule
// add build targets
- fout <<
- "<storageModule moduleId=\"org.eclipse.cdt.make.core.buildtargets\">\n"
- "<buildTargets>\n"
- ;
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets");
+ xml.StartElement("buildTargets");
emmited.clear();
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
@@ -1051,7 +1017,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// not from the subdirs
if (subdir.empty())
{
- this->AppendTarget(fout, targetName, make, makeArgs, subdir, ": ");
+ this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
}
}
break;
@@ -1066,7 +1032,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
break;
}
- this->AppendTarget(fout, targetName, make, makeArgs, subdir, ": ");
+ this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
break;
case cmState::EXECUTABLE:
case cmState::STATIC_LIBRARY:
@@ -1076,10 +1042,10 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
{
const char* prefix = ((*ti)->GetType()==cmState::EXECUTABLE ?
"[exe] " : "[lib] ");
- this->AppendTarget(fout, targetName, make, makeArgs, subdir, prefix);
+ this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix);
std::string fastTarget = targetName;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget, make, makeArgs, subdir, prefix);
+ this->AppendTarget(xml, fastTarget, make, makeArgs, subdir, prefix);
// Add Build and Clean targets in the virtual folder of targets:
if (this->SupportsVirtualFolders)
@@ -1091,7 +1057,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
buildArgs += (*it)->GetBinaryDirectory();
buildArgs += "\" ";
buildArgs += makeArgs;
- this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "",
+ this->AppendTarget(xml, "Build", make, buildArgs, virtDir, "",
targetName.c_str());
std::string cleanArgs = "-E chdir \"";
@@ -1102,7 +1068,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
cmGeneratorTarget* gt = *ti;
cleanArgs += (*it)->GetTargetDirectory(gt);
cleanArgs += "/cmake_clean.cmake\"";
- this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(),
+ this->AppendTarget(xml, "Clean", cmSystemTools::GetCMakeCommand(),
cleanArgs, virtDir, "", "");
}
}
@@ -1115,11 +1081,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// insert the all and clean targets in every subdir
if (!allTarget.empty())
{
- this->AppendTarget(fout, allTarget, make, makeArgs, subdir, ": ");
+ this->AppendTarget(xml, allTarget, make, makeArgs, subdir, ": ");
}
if (!cleanTarget.empty())
{
- this->AppendTarget(fout, cleanTarget, make, makeArgs, subdir, ": ");
+ this->AppendTarget(xml, cleanTarget, make, makeArgs, subdir, ": ");
}
//insert rules for compiling, preprocessing and assembling individual files
@@ -1138,25 +1104,29 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
{
prefix = "[pre] ";
}
- this->AppendTarget(fout, *fit, make, makeArgs, subdir, prefix);
+ this->AppendTarget(xml, *fit, make, makeArgs, subdir, prefix);
}
}
- fout << "</buildTargets>\n"
- "</storageModule>\n"
- ;
-
- this->AppendStorageScanners(fout, *mf);
-
- fout << "</cconfiguration>\n"
- "</storageModule>\n"
- "<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n"
- "<project id=\"" << this->EscapeForXML(lg->GetProjectName())
- << ".null.1\" name=\"" << this->EscapeForXML(lg->GetProjectName())
- << "\"/>\n"
- "</storageModule>\n"
- "</cproject>\n"
- ;
+ xml.EndElement(); // buildTargets
+ xml.EndElement(); // storageModule
+
+ this->AppendStorageScanners(xml, *mf);
+
+ xml.EndElement(); // cconfiguration
+ xml.EndElement(); // storageModule
+
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "cdtBuildSystem");
+ xml.Attribute("version", "4.0.0");
+
+ xml.StartElement("project");
+ xml.Attribute("id", std::string(lg->GetProjectName()) + ".null.1");
+ xml.Attribute("name", lg->GetProjectName());
+ xml.EndElement(); // project
+
+ xml.EndElement(); // storageModule
+ xml.EndElement(); // cproject
}
//----------------------------------------------------------------------------
@@ -1204,28 +1174,14 @@ cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name,
const std::string& type,
const std::string& path)
{
- return cmExtraEclipseCDT4Generator::EscapeForXML(name)
- +(type.empty() ? "" : "-") + type + "@" + path;
-}
-
-std::string cmExtraEclipseCDT4Generator::EscapeForXML(const std::string& value)
-{
- std::string str = value;
- cmSystemTools::ReplaceString(str, "&", "&amp;");
- cmSystemTools::ReplaceString(str, "<", "&lt;");
- cmSystemTools::ReplaceString(str, ">", "&gt;");
- cmSystemTools::ReplaceString(str, "\"", "&quot;");
- // NOTE: This one is not necessary, since as of Eclipse CDT4 it will
- // automatically change this to the original value (').
- //cmSystemTools::ReplaceString(str, "'", "&apos;");
- return str;
+ return name + (type.empty() ? "" : "-") + type + "@" + path;
}
//----------------------------------------------------------------------------
// Helper functions
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator
-::AppendStorageScanners(cmGeneratedFileStream& fout,
+::AppendStorageScanners(cmXMLWriter& xml,
const cmMakefile& makefile)
{
// we need the "make" and the C (or C++) compiler which are used, Alex
@@ -1251,24 +1207,28 @@ void cmExtraEclipseCDT4Generator
compilerArgs = arg1 + compilerArgs;
}
- fout <<
- "<storageModule moduleId=\"scannerConfiguration\">\n"
- "<autodiscovery enabled=\"true\" problemReportingEnabled=\"true\""
- " selectedProfileId="
- "\"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile\"/>\n"
- ;
- cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
+ xml.StartElement("storageModule");
+ xml.Attribute("moduleId", "scannerConfiguration");
+
+ xml.StartElement("autodiscovery");
+ xml.Attribute("enabled", "true");
+ xml.Attribute("problemReportingEnabled", "true");
+ xml.Attribute("selectedProfileId",
+ "org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile");
+ xml.EndElement(); // autodiscovery
+
+ cmExtraEclipseCDT4Generator::AppendScannerProfile(xml,
"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile",
true, "", true, "specsFile",
compilerArgs,
compiler, true, true);
- cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
+ cmExtraEclipseCDT4Generator::AppendScannerProfile(xml,
"org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile",
true, "", true, "makefileGenerator",
"-f ${project_name}_scd.mk",
make, true, true);
- fout << "</storageModule>\n";
+ xml.EndElement(); // storageModule
}
// The prefix is prepended before the actual name of the target. The purpose
@@ -1279,7 +1239,7 @@ void cmExtraEclipseCDT4Generator
// finally the assembly files "[to asm] ". Note the "to" in "to asm",
// without it, "asm" would be the first targets in the list, with the "to"
// they are the last targets, which makes more sense.
-void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
+void cmExtraEclipseCDT4Generator::AppendTarget(cmXMLWriter& xml,
const std::string& target,
const std::string& make,
const std::string& makeArgs,
@@ -1288,31 +1248,21 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
const char* makeTarget
)
{
- std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target);
- std::string makeTargetXml = targetXml;
- if (makeTarget != NULL)
- {
- makeTargetXml = cmExtraEclipseCDT4Generator::EscapeForXML(makeTarget);
- }
- cmExtraEclipseCDT4Generator::EscapeForXML(target);
- std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
- fout <<
- "<target name=\"" << prefix << targetXml << "\""
- " path=\"" << pathXml << "\""
- " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
- "<buildCommand>"
- << cmExtraEclipseCDT4Generator::GetEclipsePath(make)
- << "</buildCommand>\n"
- "<buildArguments>" << makeArgs << "</buildArguments>\n"
- "<buildTarget>" << makeTargetXml << "</buildTarget>\n"
- "<stopOnError>true</stopOnError>\n"
- "<useDefaultCommand>false</useDefaultCommand>\n"
- "</target>\n"
- ;
+ xml.StartElement("target");
+ xml.Attribute("name", prefix + target);
+ xml.Attribute("path", path);
+ xml.Attribute("targetID", "org.eclipse.cdt.make.MakeTargetBuilder");
+ xml.Element("buildCommand",
+ cmExtraEclipseCDT4Generator::GetEclipsePath(make));
+ xml.Element("buildArguments", makeArgs);
+ xml.Element("buildTarget", makeTarget ? makeTarget : target.c_str());
+ xml.Element("stopOnError", "true");
+ xml.Element("useDefaultCommand", "false");
+ xml.EndElement();
}
void cmExtraEclipseCDT4Generator
-::AppendScannerProfile(cmGeneratedFileStream& fout,
+::AppendScannerProfile(cmXMLWriter& xml,
const std::string& profileID,
bool openActionEnabled,
const std::string& openActionFilePath,
@@ -1323,49 +1273,54 @@ void cmExtraEclipseCDT4Generator
bool runActionUseDefault,
bool sipParserEnabled)
{
- fout <<
- "<profile id=\"" << profileID << "\">\n"
- "<buildOutputProvider>\n"
- "<openAction enabled=\"" << (openActionEnabled ? "true" : "false")
- << "\" filePath=\"" << openActionFilePath << "\"/>\n"
- "<parser enabled=\"" << (pParserEnabled ? "true" : "false") << "\"/>\n"
- "</buildOutputProvider>\n"
- "<scannerInfoProvider id=\"" << scannerInfoProviderID << "\">\n"
- "<runAction arguments=\"" << runActionArguments << "\""
- " command=\"" << runActionCommand
- << "\" useDefault=\"" << (runActionUseDefault ? "true":"false") << "\"/>\n"
- "<parser enabled=\"" << (sipParserEnabled ? "true" : "false") << "\"/>\n"
- "</scannerInfoProvider>\n"
- "</profile>\n"
- ;
+ xml.StartElement("profile");
+ xml.Attribute("id", profileID);
+
+ xml.StartElement("buildOutputProvider");
+ xml.StartElement("openAction");
+ xml.Attribute("enabled", openActionEnabled ? "true" : "false");
+ xml.Attribute("filePath", openActionFilePath);
+ xml.EndElement(); // openAction
+ xml.StartElement("parser");
+ xml.Attribute("enabled", pParserEnabled ? "true" : "false");
+ xml.EndElement(); // parser
+ xml.EndElement(); // buildOutputProvider
+
+ xml.StartElement("scannerInfoProvider");
+ xml.Attribute("id", scannerInfoProviderID);
+ xml.StartElement("runAction");
+ xml.Attribute("arguments", runActionArguments);
+ xml.Attribute("command", runActionCommand);
+ xml.Attribute("useDefault", runActionUseDefault ? "true" : "false");
+ xml.EndElement(); // runAction
+ xml.StartElement("parser");
+ xml.Attribute("enabled", sipParserEnabled ? "true" : "false");
+ xml.EndElement(); // parser
+ xml.EndElement(); // scannerInfoProvider
+
+ xml.EndElement(); // profile
}
void cmExtraEclipseCDT4Generator
-::AppendLinkedResource (cmGeneratedFileStream& fout,
+::AppendLinkedResource (cmXMLWriter& xml,
const std::string& name,
const std::string& path,
LinkType linkType)
{
const char* locationTag = "location";
- const char* typeTag = "2";
+ int typeTag = 2;
if (linkType == VirtualFolder) // ... and not a linked folder
{
locationTag = "locationURI";
}
if (linkType == LinkToFile)
{
- typeTag = "1";
+ typeTag = 1;
}
- fout <<
- "\t\t<link>\n"
- "\t\t\t<name>"
- << cmExtraEclipseCDT4Generator::EscapeForXML(name)
- << "</name>\n"
- "\t\t\t<type>" << typeTag << "</type>\n"
- "\t\t\t<" << locationTag << ">"
- << cmExtraEclipseCDT4Generator::EscapeForXML(path)
- << "</" << locationTag << ">\n"
- "\t\t</link>\n"
- ;
+ xml.StartElement("link");
+ xml.Element("name", name);
+ xml.Element("type", typeTag);
+ xml.Element(locationTag, path);
+ xml.EndElement();
}
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index 16675f2..4032a6c 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -17,7 +17,7 @@
#include "cmExternalMakefileProjectGenerator.h"
class cmMakefile;
-class cmGeneratedFileStream;
+class cmXMLWriter;
/** \class cmExtraEclipseCDT4Generator
* \brief Write Eclipse project files for Makefile based projects
@@ -67,19 +67,17 @@ private:
const std::string& type,
const std::string& path);
- static std::string EscapeForXML(const std::string& value);
-
// Helper functions
- static void AppendStorageScanners(cmGeneratedFileStream& fout,
+ static void AppendStorageScanners(cmXMLWriter& xml,
const cmMakefile& makefile);
- static void AppendTarget (cmGeneratedFileStream& fout,
+ static void AppendTarget (cmXMLWriter& xml,
const std::string& target,
const std::string& make,
const std::string& makeArguments,
const std::string& path,
const char* prefix = "",
const char* makeTarget = NULL);
- static void AppendScannerProfile (cmGeneratedFileStream& fout,
+ static void AppendScannerProfile (cmXMLWriter& xml,
const std::string& profileID,
bool openActionEnabled,
const std::string& openActionFilePath,
@@ -90,21 +88,20 @@ private:
bool runActionUseDefault,
bool sipParserEnabled);
- static void AppendLinkedResource (cmGeneratedFileStream& fout,
+ static void AppendLinkedResource (cmXMLWriter& xml,
const std::string& name,
const std::string& path,
LinkType linkType);
- static void AppendIncludeDirectories(cmGeneratedFileStream& fout,
+ static void AppendIncludeDirectories(cmXMLWriter& xml,
const std::vector<std::string>& includeDirs,
std::set<std::string>& emittedDirs);
- static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
+ static void AddEnvVar(std::ostream& out, const char* envVar,
cmLocalGenerator* lg);
- void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
- const std::string& baseDir);
- void CreateLinksForTargets(cmGeneratedFileStream& fout);
+ void CreateLinksToSubprojects(cmXMLWriter& xml, const std::string& baseDir);
+ void CreateLinksForTargets(cmXMLWriter& xml);
std::vector<std::string> SrcLinkedResources;
std::set<std::string> Natures;
@@ -116,6 +113,8 @@ private:
bool SupportsVirtualFolders;
bool SupportsGmakeErrorParser;
bool SupportsMachO64Parser;
+ bool CEnabled;
+ bool CXXEnabled;
};
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index b3557f9..1fa27eb 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -3300,6 +3300,15 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
<< " status: [" << (int)res << ";\""
<< ::curl_easy_strerror(res) << "\"]" << std::endl
;
+
+ if(!statusVar.empty() && res == 0)
+ {
+ std::string status = "1;HASH mismatch: "
+ "expected: " + expectedHash +
+ " actual: " + actualHash;
+ this->Makefile->AddDefinition(statusVar, status.c_str());
+ }
+
this->SetError(oss.str());
return false;
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ff12320..d7c2782 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3909,8 +3909,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
std::vector<std::string> props;
cmSystemTools::ExpandListArgument(prop, props);
- std::string pdir =
- dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT");
+ std::string pdir = cmSystemTools::GetCMakeRoot();
pdir += "/Help/prop_tgt/";
for(std::vector<std::string>::iterator pi = props.begin();
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index d96a32c..65c29f5 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -599,7 +599,7 @@ private:
{
ImportInfo(): NoSOName(false), Multiplicity(0) {}
bool NoSOName;
- int Multiplicity;
+ unsigned int Multiplicity;
std::string Location;
std::string SOName;
std::string ImportLibrary;
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 18e140e..c5813ba 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -217,8 +217,11 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config,
if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
{
+ std::string const static_library_suffix =
+ this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
*this->GetFolderBuildStreams() << " -o \""
- << outputDir << outputFilename << ".a\""
+ << outputDir << outputFilename
+ << static_library_suffix << "\""
<< std::endl;
}
else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
@@ -238,8 +241,11 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config,
}
else
{
+ std::string const executable_suffix =
+ this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
*this->GetFolderBuildStreams() << " -o \""
- << outputDir << outputFilename << ".as\""
+ << outputDir << outputFilename
+ << executable_suffix << "\""
<< std::endl;
}
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 848028f..1d0ade4 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -398,6 +398,21 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
return;
}
+ std::set<std::string> cur_languages(languages.begin(), languages.end());
+ for (std::set<std::string>::iterator li = cur_languages.begin();
+ li != cur_languages.end(); ++li)
+ {
+ if (!this->LanguagesInProgress.insert(*li).second)
+ {
+ std::ostringstream e;
+ e << "Language '" << *li << "' is currently being enabled. "
+ "Recursive call not allowed.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+ }
+
if(this->TryCompileOuterMakefile)
{
// In a try-compile we can only enable languages provided by caller.
@@ -805,7 +820,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// Now load files that can override any settings on the platform or for
// the project First load the project compatibility file if it is in
// cmake
- std::string projectCompatibility = mf->GetDefinition("CMAKE_ROOT");
+ std::string projectCompatibility = cmSystemTools::GetCMakeRoot();
projectCompatibility += "/Modules/";
projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME");
projectCompatibility += "Compatibility.cmake";
@@ -823,6 +838,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
cmSystemTools::SetFatalErrorOccured();
}
+
+ for (std::set<std::string>::iterator li = cur_languages.begin();
+ li != cur_languages.end(); ++li)
+ {
+ this->LanguagesInProgress.erase(*li);
+ }
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 48fa704..14c7d67 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -241,11 +241,6 @@ public:
*/
virtual void FindMakeProgram(cmMakefile*);
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /** Is this the Visual Studio 6 generator? */
- bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; }
-#endif
-
///! Find a target by name by searching the local generators.
cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const;
@@ -457,6 +452,7 @@ private:
// in EnableLanguagesFromGenerator
std::map<std::string, bool> IgnoreExtensions;
std::set<std::string> LanguagesReady; // Ready for try_compile
+ std::set<std::string> LanguagesInProgress;
std::map<std::string, std::string> OutputExtensions;
std::map<std::string, std::string> LanguageToOutputExtension;
std::map<std::string, std::string> ExtensionToLanguage;
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index 018ab24..b4f7670 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -18,6 +18,7 @@
#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
+#include "cmXMLWriter.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Directory.hxx>
@@ -397,6 +398,7 @@ void cmGlobalKdevelopGenerator
{
return;
}
+ cmXMLWriter xml(fout);
// check for a version control system
bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
@@ -411,182 +413,230 @@ void cmGlobalKdevelopGenerator
primaryLanguage="Fortran77";
}
- fout<<"<?xml version = '1.0'?>\n"
- "<kdevelop>\n"
- " <general>\n"
- " <author></author>\n"
- " <email></email>\n"
- " <version>$VERSION$</version>\n"
- " <projectmanagement>KDevCustomProject</projectmanagement>\n"
- " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
- " <ignoreparts/>\n"
- " <projectdirectory>" << projectDir <<
- "</projectdirectory>\n"; //this one is important
- fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
+ xml.StartDocument();
+ xml.StartElement("kdevelop");
+ xml.StartElement("general");
+
+ xml.Element("author", "");
+ xml.Element("email", "");
+ xml.Element("version", "$VERSION$");
+ xml.Element("projectmanagement", "KDevCustomProject");
+ xml.Element("primarylanguage", primaryLanguage);
+ xml.Element("ignoreparts");
+ xml.Element("projectdirectory", projectDir); // this one is important
+ xml.Element("absoluteprojectpath", "true"); // and this one
// setup additional languages
- fout<<" <secondaryLanguages>\n";
+ xml.StartElement("secondaryLanguages");
if (enableFortran && enableCxx)
{
- fout<<" <language>Fortran</language>\n";
+ xml.Element("language", "Fortran");
}
if (enableCxx)
{
- fout<<" <language>C</language>\n";
+ xml.Element("language", "C");
}
- fout<<" </secondaryLanguages>\n";
+ xml.EndElement();
if (hasSvn)
{
- fout << " <versioncontrol>kdevsubversion</versioncontrol>\n";
+ xml.Element("versioncontrol", "kdevsubversion");
}
else if (hasCvs)
{
- fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
+ xml.Element("versioncontrol", "kdevcvsservice");
}
- fout<<" </general>\n"
- " <kdevcustomproject>\n"
- " <filelistdirectory>" << outputDir <<
- "</filelistdirectory>\n"
- " <run>\n"
- " <mainprogram>" << executable << "</mainprogram>\n"
- " <directoryradio>custom</directoryradio>\n"
- " <customdirectory>"<<outputDir<<"</customdirectory>\n"
- " <programargs></programargs>\n"
- " <terminal>false</terminal>\n"
- " <autocompile>true</autocompile>\n"
- " <envvars/>\n"
- " </run>\n"
- " <build>\n"
- " <buildtool>make</buildtool>\n"; //this one is important
- fout<<" <builddir>"<<outputDir<<"</builddir>\n"; //and this one
- fout<<" </build>\n"
- " <make>\n"
- " <abortonerror>false</abortonerror>\n"
- " <numberofjobs>1</numberofjobs>\n"
- " <dontact>false</dontact>\n"
- " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
- GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")
- << " </makebin>\n"
- " <selectedenvironment>default</selectedenvironment>\n"
- " <environments>\n"
- " <default>\n"
- " <envvar value=\"1\" name=\"VERBOSE\" />\n"
- " <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
- " </default>\n"
- " </environments>\n"
- " </make>\n";
-
- fout<<" <blacklist>\n";
+ xml.EndElement(); // general
+ xml.StartElement("kdevcustomproject");
+
+ xml.Element("filelistdirectory", outputDir);
+
+ xml.StartElement("run");
+ xml.Element("mainprogram", executable);
+ xml.Element("directoryradio", "custom");
+ xml.Element("customdirectory", outputDir);
+ xml.Element("programargs", "");
+ xml.Element("terminal", "false");
+ xml.Element("autocompile", "true");
+ xml.Element("envvars");
+ xml.EndElement();
+
+ xml.StartElement("build");
+ xml.Element("buildtool", "make"); // this one is important
+ xml.Element("builddir", outputDir); // and this one
+ xml.EndElement();
+
+ xml.StartElement("make");
+ xml.Element("abortonerror", "false");
+ xml.Element("numberofjobs", 1);
+ xml.Element("dontact", "false");
+ xml.Element("makebin", this->GlobalGenerator->GetLocalGenerators()[0]->
+ GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"));
+ xml.Element("selectedenvironment", "default");
+
+ xml.StartElement("environments");
+ xml.StartElement("default");
+
+ xml.StartElement("envvar");
+ xml.Attribute("value", 1);
+ xml.Attribute("name", "VERBOSE");
+ xml.EndElement();
+
+ xml.StartElement("envvar");
+ xml.Attribute("value", 1);
+ xml.Attribute("name", "CMAKE_NO_VERBOSE");
+ xml.EndElement();
+
+ xml.EndElement(); // default
+ xml.EndElement(); // environments
+ xml.EndElement(); // make
+
+ xml.StartElement("blacklist");
for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
dirIt != this->Blacklist.end();
++dirIt)
{
- fout<<" <path>" << *dirIt << "</path>\n";
+ xml.Element("path", *dirIt);
}
- fout<<" </blacklist>\n";
-
- fout<<" </kdevcustomproject>\n"
- " <kdevfilecreate>\n"
- " <filetypes/>\n"
- " <useglobaltypes>\n"
- " <type ext=\"ui\" />\n"
- " <type ext=\"cpp\" />\n"
- " <type ext=\"h\" />\n"
- " </useglobaltypes>\n"
- " </kdevfilecreate>\n"
- " <kdevdoctreeview>\n"
- " <projectdoc>\n"
- " <userdocDir>html/</userdocDir>\n"
- " <apidocDir>html/</apidocDir>\n"
- " </projectdoc>\n"
- " <ignoreqt_xml/>\n"
- " <ignoredoxygen/>\n"
- " <ignorekdocs/>\n"
- " <ignoretocs/>\n"
- " <ignoredevhelp/>\n"
- " </kdevdoctreeview>\n";
+ xml.EndElement();
+
+ xml.EndElement(); // kdevcustomproject
+
+ xml.StartElement("kdevfilecreate");
+ xml.Element("filetypes");
+ xml.StartElement("useglobaltypes");
+
+ xml.StartElement("type");
+ xml.Attribute("ext", "ui");
+ xml.EndElement();
+
+ xml.StartElement("type");
+ xml.Attribute("ext", "cpp");
+ xml.EndElement();
+
+ xml.StartElement("type");
+ xml.Attribute("ext", "h");
+ xml.EndElement();
+
+ xml.EndElement(); // useglobaltypes
+ xml.EndElement(); // kdevfilecreate
+
+ xml.StartElement("kdevdoctreeview");
+ xml.StartElement("projectdoc");
+ xml.Element("userdocDir", "html/");
+ xml.Element("apidocDir", "html/");
+ xml.EndElement(); // projectdoc
+ xml.Element("ignoreqt_xml");
+ xml.Element("ignoredoxygen");
+ xml.Element("ignorekdocs");
+ xml.Element("ignoretocs");
+ xml.Element("ignoredevhelp");
+ xml.EndElement(); // kdevdoctreeview;
if (enableCxx)
{
- fout<<" <cppsupportpart>\n"
- " <filetemplates>\n"
- " <interfacesuffix>.h</interfacesuffix>\n"
- " <implementationsuffix>.cpp</implementationsuffix>\n"
- " </filetemplates>\n"
- " </cppsupportpart>\n"
- " <kdevcppsupport>\n"
- " <codecompletion>\n"
- " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
- " <includeTypes>true</includeTypes>\n"
- " <includeEnums>true</includeEnums>\n"
- " <includeTypedefs>false</includeTypedefs>\n"
- " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
- " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
- " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
- " <codeCompletionDelay>250</codeCompletionDelay>\n"
- " <argumentsHintDelay>400</argumentsHintDelay>\n"
- " <headerCompletionDelay>250</headerCompletionDelay>\n"
- " </codecompletion>\n"
- " <references/>\n"
- " </kdevcppsupport>\n";
+ xml.StartElement("cppsupportpart");
+ xml.StartElement("filetemplates");
+ xml.Element("interfacesuffix", ".h");
+ xml.Element("implementationsuffix", ".cpp");
+ xml.EndElement(); // filetemplates
+ xml.EndElement(); // cppsupportpart
+
+ xml.StartElement("kdevcppsupport");
+ xml.StartElement("codecompletion");
+ xml.Element("includeGlobalFunctions", "true");
+ xml.Element("includeTypes", "true");
+ xml.Element("includeEnums", "true");
+ xml.Element("includeTypedefs", "false");
+ xml.Element("automaticCodeCompletion", "true");
+ xml.Element("automaticArgumentsHint", "true");
+ xml.Element("automaticHeaderCompletion", "true");
+ xml.Element("codeCompletionDelay", 250);
+ xml.Element("argumentsHintDelay", 400);
+ xml.Element("headerCompletionDelay", 250);
+ xml.EndElement(); // codecompletion
+ xml.Element("references");
+ xml.EndElement(); // kdevcppsupport;
}
if (enableFortran)
{
- fout<<" <kdevfortransupport>\n"
- " <ftnchek>\n"
- " <division>false</division>\n"
- " <extern>false</extern>\n"
- " <declare>false</declare>\n"
- " <pure>false</pure>\n"
- " <argumentsall>false</argumentsall>\n"
- " <commonall>false</commonall>\n"
- " <truncationall>false</truncationall>\n"
- " <usageall>false</usageall>\n"
- " <f77all>false</f77all>\n"
- " <portabilityall>false</portabilityall>\n"
- " <argumentsonly/>\n"
- " <commononly/>\n"
- " <truncationonly/>\n"
- " <usageonly/>\n"
- " <f77only/>\n"
- " <portabilityonly/>\n"
- " </ftnchek>\n"
- " </kdevfortransupport>\n";
+ xml.StartElement("kdevfortransupport");
+ xml.StartElement("ftnchek");
+ xml.Element("division", "false");
+ xml.Element("extern", "false");
+ xml.Element("declare", "false");
+ xml.Element("pure", "false");
+ xml.Element("argumentsall", "false");
+ xml.Element("commonall", "false");
+ xml.Element("truncationall", "false");
+ xml.Element("usageall", "false");
+ xml.Element("f77all", "false");
+ xml.Element("portabilityall", "false");
+ xml.Element("argumentsonly");
+ xml.Element("commononly");
+ xml.Element("truncationonly");
+ xml.Element("usageonly");
+ xml.Element("f77only");
+ xml.Element("portabilityonly");
+ xml.EndElement(); // ftnchek
+ xml.EndElement(); // kdevfortransupport;
}
// set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
// command
- fout<<" <kdevfileview>\n"
- " <groups>\n"
- " <group pattern=\"" << cmakeFilePattern <<
- "\" name=\"CMake\" />\n";
+ xml.StartElement("kdevfileview");
+ xml.StartElement("groups");
+
+ xml.StartElement("group");
+ xml.Attribute("pattern", cmakeFilePattern);
+ xml.Attribute("name", "CMake");
+ xml.EndElement();
if (enableCxx)
{
- fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
- " <group pattern=\"*.c\" name=\"C Sources\" />\n"
- " <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
- "/>\n";
+ xml.StartElement("group");
+ xml.Attribute("pattern", "*.h;*.hxx;*.hpp");
+ xml.Attribute("name", "Header");
+ xml.EndElement();
+
+ xml.StartElement("group");
+ xml.Attribute("pattern", "*.c");
+ xml.Attribute("name", "C Sources");
+ xml.EndElement();
+
+ xml.StartElement("group");
+ xml.Attribute("pattern", "*.cpp;*.C;*.cxx;*.cc");
+ xml.Attribute("name", "C++ Sources");
+ xml.EndElement();
}
if (enableFortran)
{
- fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
- "*.F95\" name=\"Fortran Sources\" />\n";
+ xml.StartElement("group");
+ xml.Attribute("pattern",
+ "*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95");
+ xml.Attribute("name", "Fortran Sources");
+ xml.EndElement();
}
- fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
- " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
- " </groups>\n"
- " <tree>\n"
- " <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
- " <hidenonprojectfiles>true</hidenonprojectfiles>\n"
- " </tree>\n"
- " </kdevfileview>\n"
- "</kdevelop>\n";
+ xml.StartElement("group");
+ xml.Attribute("pattern", "*.ui");
+ xml.Attribute("name", "Qt Designer files");
+ xml.EndElement();
+
+ xml.Element("hidenonprojectfiles", "true");
+ xml.EndElement(); // groups
+
+ xml.StartElement("tree");
+ xml.Element("hidepatterns", "*.o,*.lo,CVS,*~,cmake*");
+ xml.Element("hidenonprojectfiles", "true");
+ xml.EndElement(); // tree
+
+ xml.EndElement(); // kdevfileview
+ xml.EndElement(); // kdevelop;
+ xml.EndDocument();
if (sessionFilename.empty())
{
@@ -600,15 +650,24 @@ void cmGlobalKdevelopGenerator
{
return;
}
- devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
- "<!DOCTYPE KDevPrjSession>\n"
- "<KDevPrjSession>\n"
- " <DocsAndViews NumberOfDocuments=\"1\" >\n"
- " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
- "\" >\n"
- " <View0 line=\"0\" Type=\"Source\" />\n"
- " </Doc0>\n"
- " </DocsAndViews>\n"
- "</KDevPrjSession>\n";
+ cmXMLWriter sesxml(devses);
+ sesxml.StartDocument("UTF-8");
+ sesxml.Doctype("KDevPrjSession");
+ sesxml.StartElement("KDevPrjSession");
+
+ sesxml.StartElement("DocsAndViews");
+ sesxml.Attribute("NumberOfDocuments", 1);
+
+ sesxml.StartElement("Doc0");
+ sesxml.Attribute("NumberOfViews", 1);
+ sesxml.Attribute("URL", "file://" + fileToOpen);
+
+ sesxml.StartElement("View0");
+ sesxml.Attribute("line", 0);
+ sesxml.Attribute("Type", "Source");
+ sesxml.EndElement(); // View0
+
+ sesxml.EndElement(); // Doc0
+ sesxml.EndElement(); // DocsAndViews
+ sesxml.EndElement(); // KDevPrjSession;
}
-
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 0f06e43..f12396f 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -577,6 +577,7 @@ void cmGlobalNinjaGenerator::Generate()
this->WriteAssumedSourceDependencies();
this->WriteTargetAliases(*this->BuildFileStream);
+ this->WriteFolderTargets(*this->BuildFileStream);
this->WriteUnknownExplicitDependencies(*this->BuildFileStream);
this->WriteBuiltinTargets(*this->BuildFileStream);
@@ -642,7 +643,6 @@ void cmGlobalNinjaGenerator
// cmGlobalUnixMakefileGenerator3
// cmGlobalGhsMultiGenerator
// cmGlobalVisualStudio10Generator
-// cmGlobalVisualStudio6Generator
// cmGlobalVisualStudio7Generator
// cmGlobalXCodeGenerator
// Called by:
@@ -849,6 +849,18 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
return convPath;
}
+std::string
+cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(const std::string& path)
+{
+ cmLocalNinjaGenerator *ng =
+ static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]);
+ std::string convPath = ng->Convert(path+"/all", cmOutputConverter::HOME);
+#ifdef _WIN32
+ cmSystemTools::ReplaceString(convPath, "/", "\\");
+#endif
+ return convPath;
+}
+
void cmGlobalNinjaGenerator::AddCXXCompileCommand(
const std::string &commandLine,
const std::string &sourceFile)
@@ -991,6 +1003,7 @@ cmGlobalNinjaGenerator
std::set<std::string> const& utils = target->GetUtilities();
std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
} else {
+ cmNinjaDeps outs;
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
for (cmTargetDependSet::const_iterator i = targetDeps.begin();
i != targetDeps.end(); ++i)
@@ -999,8 +1012,10 @@ cmGlobalNinjaGenerator
{
continue;
}
- this->AppendTargetOutputs(*i, outputs);
+ this->AppendTargetOutputs(*i, outs);
}
+ std::sort(outs.begin(), outs.end());
+ outputs.insert(outputs.end(), outs.begin(), outs.end());
}
}
@@ -1042,6 +1057,75 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
}
}
+void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
+{
+ cmGlobalNinjaGenerator::WriteDivider(os);
+ os << "# Folder targets.\n\n";
+
+ std::map<std::string, cmNinjaDeps> targetsPerFolder;
+ for (std::vector<cmLocalGenerator *>::const_iterator
+ lgi = this->LocalGenerators.begin();
+ lgi != this->LocalGenerators.end(); ++lgi)
+ {
+ cmLocalGenerator const* lg = *lgi;
+ const std::string currentSourceFolder(
+ lg->GetStateSnapshot().GetDirectory().GetCurrentSource());
+ // The directory-level rule should depend on the target-level rules
+ // for all targets in the directory.
+ targetsPerFolder[currentSourceFolder] = cmNinjaDeps();
+ for (std::vector<cmGeneratorTarget*>::const_iterator
+ ti = lg->GetGeneratorTargets().begin();
+ ti != lg->GetGeneratorTargets().end(); ++ti)
+ {
+ cmGeneratorTarget const* gt = *ti;
+ cmState::TargetType const type = gt->GetType();
+ if((type == cmState::EXECUTABLE ||
+ type == cmState::STATIC_LIBRARY ||
+ type == cmState::SHARED_LIBRARY ||
+ type == cmState::MODULE_LIBRARY ||
+ type == cmState::OBJECT_LIBRARY ||
+ type == cmState::UTILITY) &&
+ !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+ {
+ targetsPerFolder[currentSourceFolder].push_back(gt->GetName());
+ }
+ }
+
+ // The directory-level rule should depend on the directory-level
+ // rules of the subdirectories.
+ std::vector<cmState::Snapshot> const& children =
+ lg->GetStateSnapshot().GetChildren();
+ for(std::vector<cmState::Snapshot>::const_iterator
+ stateIt = children.begin(); stateIt != children.end(); ++stateIt)
+ {
+ targetsPerFolder[currentSourceFolder].push_back(
+ this->ConvertToNinjaFolderRule(
+ stateIt->GetDirectory().GetCurrentSource()));
+ }
+ }
+
+ std::string const rootSourceDir =
+ this->LocalGenerators[0]->GetSourceDirectory();
+ for (std::map<std::string, cmNinjaDeps >::const_iterator it =
+ targetsPerFolder.begin(); it != targetsPerFolder.end(); ++it)
+ {
+ cmGlobalNinjaGenerator::WriteDivider( os );
+ std::string const& currentSourceDir = it->first;
+
+ // Do not generate a rule for the root source dir.
+ if (rootSourceDir.length() >= currentSourceDir.length())
+ {
+ continue;
+ }
+
+ std::string const comment = "Folder: " + currentSourceDir;
+ cmNinjaDeps output(1);
+ output.push_back(this->ConvertToNinjaFolderRule(currentSourceDir));
+
+ this->WritePhonyBuild(os, comment, output, it->second);
+ }
+}
+
void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
{
if (!this->ComputingUnknownDependencies)
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 8656590..3023a95 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -228,6 +228,8 @@ public:
return this->RulesFileStream; }
std::string ConvertToNinjaPath(const std::string& path);
+ std::string ConvertToNinjaFolderRule(const std::string& path);
+
struct MapToNinjaPathImpl {
cmGlobalNinjaGenerator* GG;
@@ -342,6 +344,7 @@ private:
void WriteAssumedSourceDependencies();
void WriteTargetAliases(std::ostream& os);
+ void WriteFolderTargets(std::ostream& os);
void WriteUnknownExplicitDependencies(std::ostream& os);
void WriteBuiltinTargets(std::ostream& os);
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
deleted file mode 100644
index 5866c0e..0000000
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ /dev/null
@@ -1,451 +0,0 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- 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 "cmGlobalVisualStudio6Generator.h"
-#include "cmLocalVisualStudio6Generator.h"
-#include "cmMakefile.h"
-#include "cmake.h"
-#include "cmGeneratedFileStream.h"
-#include <cmsys/FStream.hxx>
-
-// Utility function to make a valid VS6 *.dsp filename out
-// of a CMake target name:
-//
-std::string GetVS6TargetName(const std::string& targetName)
-{
- std::string name(targetName);
-
- // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
- // Replace them with underscores.
- //
- cmSystemTools::ReplaceString(name, "-", "_");
-
- return name;
-}
-
-cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator(cmake* cm)
- : cmGlobalVisualStudioGenerator(cm)
-{
- this->MSDevCommandInitialized = false;
- this->Version = VS6;
-}
-
-void cmGlobalVisualStudio6Generator
-::EnableLanguage(std::vector<std::string>const& lang,
- cmMakefile *mf,
- bool optional)
-{
- mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
- mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
- this->GenerateConfigurations(mf);
- this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
-}
-
-void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
-{
- std::string fname= mf->GetRequiredDefinition("CMAKE_ROOT");
- const char* def= mf->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
- if(def)
- {
- fname = def;
- }
- else
- {
- fname += "/Templates";
- }
- fname += "/CMakeVisualStudio6Configurations.cmake";
- if(!mf->ReadDependentFile(fname.c_str()))
- {
- cmSystemTools::Error("Cannot open ", fname.c_str(),
- ". Please copy this file from the main "
- "CMake/Templates directory and edit it for "
- "your build configurations.");
- }
- else if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
- {
- cmSystemTools::Error("CMAKE_CONFIGURATION_TYPES not set by ",
- fname.c_str(),
- ". Please copy this file from the main "
- "CMake/Templates directory and edit it for "
- "your build configurations.");
- }
-}
-
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf)
-{
- this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf);
- mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND",
- this->GetMSDevCommand().c_str());
-}
-
-//----------------------------------------------------------------------------
-std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand()
-{
- if(!this->MSDevCommandInitialized)
- {
- this->MSDevCommandInitialized = true;
- this->MSDevCommand = this->FindMSDevCommand();
- }
- return this->MSDevCommand;
-}
-
-//----------------------------------------------------------------------------
-std::string cmGlobalVisualStudio6Generator::FindMSDevCommand()
-{
- std::string vscmd;
- std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir";
- if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
- cmSystemTools::KeyWOW64_32))
- {
- cmSystemTools::ConvertToUnixSlashes(vscmd);
- vscmd += "/MSDev98/Bin/";
- }
- vscmd += "msdev.exe";
- return vscmd;
-}
-
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio6Generator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand,
- const std::string& makeProgram,
- const std::string& projectName,
- const std::string& /*projectDir*/,
- const std::string& targetName,
- const std::string& config,
- bool /*fast*/, bool /*verbose*/,
- std::vector<std::string> const& makeOptions
- )
-{
- // now build the test
- makeCommand.push_back(
- this->SelectMakeProgram(makeProgram, this->GetMSDevCommand())
- );
-
- makeCommand.push_back(std::string(projectName)+".dsw");
- makeCommand.push_back("/MAKE");
- std::string targetArg;
- bool clean = false;
- std::string realTarget = targetName;
- if ( realTarget == "clean" )
- {
- clean = true;
- realTarget = "ALL_BUILD";
- }
- if (!realTarget.empty())
- {
- targetArg += realTarget;
- }
- else
- {
- targetArg += "ALL_BUILD";
- }
- targetArg += " - ";
- if(!config.empty())
- {
- targetArg += config;
- }
- else
- {
- targetArg += "Debug";
- }
- makeCommand.push_back(targetArg);
- if(clean)
- {
- makeCommand.push_back("/CLEAN");
- }
- else
- {
- makeCommand.push_back("/BUILD");
- }
- makeCommand.insert(makeCommand.end(),
- makeOptions.begin(), makeOptions.end());
-}
-
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf)
-{
- return new cmLocalVisualStudio6Generator(this, mf);
-}
-
-
-void cmGlobalVisualStudio6Generator::Generate()
-{
- // first do the superclass method
- this->cmGlobalVisualStudioGenerator::Generate();
-
- // Now write out the DSW
- this->OutputDSWFile();
-
- if (!this->CMakeInstance->GetIsInTryCompile())
- {
- const char* cmakeWarnVS6 =
- this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS6");
- if (!cmakeWarnVS6 || !cmSystemTools::IsOff(cmakeWarnVS6))
- {
- this->CMakeInstance->IssueMessage(
- cmake::WARNING,
- "The \"Visual Studio 6\" generator is deprecated "
- "and will be removed in a future version of CMake."
- "\n"
- "Add CMAKE_WARN_VS6=OFF to the cache to disable this warning."
- );
- }
- }
-}
-
-// Write a DSW file to the stream
-void cmGlobalVisualStudio6Generator
-::WriteDSWFile(std::ostream& fout,cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators)
-{
- // Write out the header for a DSW file
- this->WriteDSWHeader(fout);
-
- // Collect all targets under this root generator and the transitive
- // closure of their dependencies.
- TargetDependSet projectTargets;
- TargetDependSet originalTargets;
- this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
-
- for(OrderedTargetDependSet::const_iterator
- tt = orderedProjectTargets.begin();
- tt != orderedProjectTargets.end(); ++tt)
- {
- cmGeneratorTarget const* target = *tt;
- if(target->GetType() == cmState::INTERFACE_LIBRARY)
- {
- continue;
- }
- // Write the project into the DSW file
- const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
- if(expath)
- {
- std::string project = target->GetName();
- std::string location = expath;
- this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), target->GetUtilities());
- }
- else
- {
- std::string dspname = GetVS6TargetName(target->GetName());
- std::string dir =
- target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT);
- this->WriteProject(fout, dspname.c_str(), dir.c_str(), target);
- }
- }
-
- // Write the footer for the DSW file
- this->WriteDSWFooter(fout);
-}
-
-void cmGlobalVisualStudio6Generator
-::OutputDSWFile(cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators)
-{
- if(generators.empty())
- {
- return;
- }
- std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory();
- fname += "/";
- fname += root->GetProjectName();
- fname += ".dsw";
- cmsys::ofstream fout(fname.c_str());
- if(!fout)
- {
- cmSystemTools::Error("Error can not open DSW file for write: ",
- fname.c_str());
- cmSystemTools::ReportLastSystemError("");
- return;
- }
- this->WriteDSWFile(fout, root, generators);
-}
-
-// output the DSW file
-void cmGlobalVisualStudio6Generator::OutputDSWFile()
-{
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
- for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
- {
- this->OutputDSWFile(it->second[0], it->second);
- }
-}
-
-// Write a dsp file into the DSW file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
- const std::string& dspname,
- const char* dir,
- const cmGeneratorTarget *target)
-{
- fout << "#########################################################"
- "######################\n\n";
- fout << "Project: \"" << dspname << "\"="
- << dir << "\\" << dspname << ".dsp - Package Owner=<4>\n\n";
- fout << "Package=<5>\n{{{\n}}}\n\n";
- fout << "Package=<4>\n";
- fout << "{{{\n";
- VSDependSet const& depends = this->VSTargetDepends[target];
- for(VSDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di)
- {
- const char* name = di->c_str();
- fout << "Begin Project Dependency\n";
- fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n";
- fout << "End Project Dependency\n";
- }
- fout << "}}}\n\n";
-
- UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
- if(ui != this->UtilityDepends.end())
- {
- const char* uname = ui->second.c_str();
- fout << "Project: \"" << uname << "\"="
- << dir << "\\" << uname << ".dsp - Package Owner=<4>\n\n";
- fout <<
- "Package=<5>\n{{{\n}}}\n\n"
- "Package=<4>\n"
- "{{{\n"
- "Begin Project Dependency\n"
- "Project_Dep_Name " << dspname << "\n"
- "End Project Dependency\n"
- "}}}\n\n";
- ;
- }
-}
-
-
-// Write a dsp file into the DSW file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
- const std::string& name,
- const char* location,
- const std::set<std::string>& dependencies)
-{
- fout << "#########################################################"
- "######################\n\n";
- fout << "Project: \"" << name << "\"="
- << location << " - Package Owner=<4>\n\n";
- fout << "Package=<5>\n{{{\n}}}\n\n";
- fout << "Package=<4>\n";
- fout << "{{{\n";
-
-
- std::set<std::string>::const_iterator i, end;
- // write dependencies.
- i = dependencies.begin();
- end = dependencies.end();
- for(;i!= end; ++i)
- {
- fout << "Begin Project Dependency\n";
- fout << "Project_Dep_Name " << GetVS6TargetName(*i) << "\n";
- fout << "End Project Dependency\n";
- }
- fout << "}}}\n\n";
-}
-
-
-
-// Standard end of dsw file
-void cmGlobalVisualStudio6Generator::WriteDSWFooter(std::ostream& fout)
-{
- fout << "######################################################"
- "#########################\n\n";
- fout << "Global:\n\n";
- fout << "Package=<5>\n{{{\n}}}\n\n";
- fout << "Package=<3>\n{{{\n}}}\n\n";
- fout << "#####################################################"
- "##########################\n\n";
-}
-
-
-// ouput standard header for dsw file
-void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
-{
- fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n";
- fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n";
-}
-
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudio6Generator::WriteUtilityDepend(
- const cmGeneratorTarget *target)
-{
- std::string pname = target->GetName();
- pname += "_UTILITY";
- pname = GetVS6TargetName(pname.c_str());
- std::string fname =
- target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fname += "/";
- fname += pname;
- fname += ".dsp";
- cmGeneratedFileStream fout(fname.c_str());
- fout.SetCopyIfDifferent(true);
- fout <<
- "# Microsoft Developer Studio Project File - Name=\""
- << pname << "\" - Package Owner=<4>\n"
- "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n"
- "# ** DO NOT EDIT **\n"
- "\n"
- "# TARGTYPE \"Win32 (x86) Generic Project\" 0x010a\n"
- "\n"
- "CFG=" << pname << " - Win32 Debug\n"
- "!MESSAGE \"" << pname << " - Win32 Debug\""
- " (based on \"Win32 (x86) Generic Project\")\n"
- "!MESSAGE \"" << pname << " - Win32 Release\" "
- "(based on \"Win32 (x86) Generic Project\")\n"
- "!MESSAGE \"" << pname << " - Win32 MinSizeRel\" "
- "(based on \"Win32 (x86) Generic Project\")\n"
- "!MESSAGE \"" << pname << " - Win32 RelWithDebInfo\" "
- "(based on \"Win32 (x86) Generic Project\")\n"
- "\n"
- "# Begin Project\n"
- "# Begin Target\n"
- "# Name \"" << pname << " - Win32 Debug\"\n"
- "# Name \"" << pname << " - Win32 Release\"\n"
- "# Name \"" << pname << " - Win32 MinSizeRel\"\n"
- "# Name \"" << pname << " - Win32 RelWithDebInfo\"\n"
- "# End Target\n"
- "# End Project\n"
- ;
- return pname;
-}
-
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio6Generator
-::GetDocumentation(cmDocumentationEntry& entry)
-{
- entry.Name = cmGlobalVisualStudio6Generator::GetActualName();
- entry.Brief = "Deprecated. Generates Visual Studio 6 project files.";
-}
-
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio6Generator
-::AppendDirectoryForConfig(const std::string& prefix,
- const std::string& config,
- const std::string& suffix,
- std::string& dir)
-{
- if(!config.empty())
- {
- dir += prefix;
- dir += config;
- dir += suffix;
- }
-}
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
deleted file mode 100644
index ae2988e..0000000
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- 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 cmGlobalVisualStudio6Generator_h
-#define cmGlobalVisualStudio6Generator_h
-
-#include "cmGlobalVisualStudioGenerator.h"
-#include "cmGlobalGeneratorFactory.h"
-
-/** \class cmGlobalVisualStudio6Generator
- * \brief Write a Unix makefiles.
- *
- * cmGlobalVisualStudio6Generator manages UNIX build process for a tree
- */
-class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator
-{
-public:
- cmGlobalVisualStudio6Generator(cmake* cm);
- static cmGlobalGeneratorFactory* NewFactory() {
- return new cmGlobalGeneratorSimpleFactory
- <cmGlobalVisualStudio6Generator>(); }
-
- ///! Get the name for the generator.
- virtual std::string GetName() const {
- return cmGlobalVisualStudio6Generator::GetActualName();}
- static std::string GetActualName() {return "Visual Studio 6";}
-
- /** Get the documentation entry for this generator. */
- static void GetDocumentation(cmDocumentationEntry& entry);
-
- /**
- * Utilized by the generator factory to determine if this generator
- * supports toolsets.
- */
- static bool SupportsToolset() { return false; }
-
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
-
- /**
- * Try to determine system information such as shared library
- * extension, pthreads, byte order etc.
- */
- virtual void EnableLanguage(std::vector<std::string>const& languages,
- cmMakefile *, bool optional);
-
- /**
- * Try running cmake and building a file. This is used for dynalically
- * loaded commands, not as part of the usual build process.
- */
- virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand,
- const std::string& makeProgram,
- const std::string& projectName,
- const std::string& projectDir,
- const std::string& targetName,
- const std::string& config,
- bool fast, bool verbose,
- std::vector<std::string> const& makeOptions = std::vector<std::string>()
- );
-
- /**
- * Generate the DSW workspace file.
- */
- virtual void OutputDSWFile();
- virtual void OutputDSWFile(cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators);
- virtual void WriteDSWFile(std::ostream& fout,
- cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators);
-
- /** Append the subdirectory for the given configuration. */
- virtual void AppendDirectoryForConfig(const std::string& prefix,
- const std::string& config,
- const std::string& suffix,
- std::string& dir);
-
- ///! What is the configurations directory variable called?
- virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; }
-
- virtual void FindMakeProgram(cmMakefile*);
-
-protected:
- virtual void Generate();
- virtual const char* GetIDEVersion() { return "6.0"; }
-private:
- virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); }
- void GenerateConfigurations(cmMakefile* mf);
- void WriteDSWFile(std::ostream& fout);
- void WriteDSWHeader(std::ostream& fout);
- void WriteProject(std::ostream& fout,
- const std::string& name, const char* path,
- cmGeneratorTarget const* t);
- void WriteExternalProject(std::ostream& fout,
- const std::string& name, const char* path,
- const std::set<std::string>& dependencies);
- void WriteDSWFooter(std::ostream& fout);
- virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target);
- std::string MSDevCommand;
- bool MSDevCommandInitialized;
- std::string const& GetMSDevCommand();
- std::string FindMSDevCommand();
-};
-
-#endif
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 8227b82..7b51fdf 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -94,16 +94,34 @@ void cmGlobalVisualStudio71Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
+ OrderedTargetDependSet orderedProjectTargets(
+ projectTargets, this->GetStartupProjectName(root));
- this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
+ // Generate the targets specification to a string. We will put this in
+ // the actual .sln file later. As a side effect, this method also
+ // populates the set of folders.
+ std::ostringstream targetsSlnString;
+ this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets);
+ // VS 7 does not support folders specified first.
+ if (this->GetVersion() <= VS71)
+ {
+ fout << targetsSlnString.str();
+ }
+
+ // Generate folder specification.
bool useFolderProperty = this->UseFolderProperty();
if (useFolderProperty)
{
this->WriteFolders(fout);
}
+ // Now write the actual target specification content.
+ if (this->GetVersion() > VS71)
+ {
+ fout << targetsSlnString.str();
+ }
+
// Write out the configurations information for the solution
fout << "Global\n";
// Write out the configurations for the solution
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index f5848ab..c1c8c77 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -335,23 +335,6 @@ void cmGlobalVisualStudio7Generator::Generate()
{
this->CallVisualStudioMacro(MacroReload);
}
-
- if (!this->CMakeInstance->GetIsInTryCompile() &&
- this->GetName() == "Visual Studio 7")
- {
- const char* cmakeWarnVS70 =
- this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS70");
- if (!cmakeWarnVS70 || !cmSystemTools::IsOff(cmakeWarnVS70))
- {
- this->CMakeInstance->IssueMessage(
- cmake::WARNING,
- "The \"Visual Studio 7\" generator is deprecated "
- "and will be removed in a future version of CMake."
- "\n"
- "Add CMAKE_WARN_VS70=OFF to the cache to disable this warning."
- );
- }
- }
}
void cmGlobalVisualStudio7Generator
@@ -551,71 +534,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
}
//----------------------------------------------------------------------------
-// Write a SLN file to the stream
-void cmGlobalVisualStudio7Generator
-::WriteSLNFile(std::ostream& fout,
- 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);
-
- // Collect all targets under this root generator and the transitive
- // closure of their dependencies.
- TargetDependSet projectTargets;
- TargetDependSet originalTargets;
- this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
-
- this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
-
- bool useFolderProperty = this->UseFolderProperty();
- if (useFolderProperty)
- {
- this->WriteFolders(fout);
- }
-
- // Write out the configurations information for the solution
- fout << "Global\n"
- << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
-
- int c = 0;
- for(std::vector<std::string>::iterator i = configs.begin();
- i != configs.end(); ++i)
- {
- fout << "\t\tConfigName." << c << " = " << *i << "\n";
- c++;
- }
- fout << "\tEndGlobalSection\n";
- // Write out project(target) depends
- fout << "\tGlobalSection(ProjectDependencies) = postSolution\n";
- this->WriteTargetDepends(fout, orderedProjectTargets);
- fout << "\tEndGlobalSection\n";
-
- if (useFolderProperty)
- {
- // Write out project folders
- fout << "\tGlobalSection(NestedProjects) = preSolution\n";
- this->WriteFoldersContent(fout);
- fout << "\tEndGlobalSection\n";
- }
-
- // Write out the configurations for all the targets in the project
- fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
- this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
- fout << "\tEndGlobalSection\n";
-
- // Write out global sections
- this->WriteSLNGlobalSections(fout, root);
-
- // Write the footer for the SLN file
- this->WriteSLNFooter(fout);
-}
-
-//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
{
const char *prefix = "CMAKE_FOLDER_GUID_";
@@ -680,134 +598,6 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
return d;
}
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
- const std::string& dspname,
- const char* dir,
- cmGeneratorTarget const* target)
-{
- // check to see if this is a fortran build
- const char* ext = ".vcproj";
- const char* project =
- "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"";
- if(this->TargetIsFortranOnly(target))
- {
- ext = ".vfproj";
- project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
- }
-
- fout << project
- << dspname << "\", \""
- << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
- << dspname << ext << "\", \"{"
- << this->GetGUID(dspname) << "}\"\nEndProject\n";
-
- UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
- if(ui != this->UtilityDepends.end())
- {
- const char* uname = ui->second.c_str();
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
- << uname << "\", \""
- << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
- << uname << ".vcproj" << "\", \"{"
- << this->GetGUID(uname) << "}\"\n"
- << "EndProject\n";
- }
-}
-
-
-
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void
-cmGlobalVisualStudio7Generator
-::WriteProjectDepends(std::ostream& fout,
- const std::string& dspname,
- const char*, cmGeneratorTarget const* target)
-{
- int depcount = 0;
- std::string dspguid = this->GetGUID(dspname);
- VSDependSet const& depends = this->VSTargetDepends[target];
- for(VSDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di)
- {
- const char* name = di->c_str();
- std::string guid = this->GetGUID(name);
- if(guid.empty())
- {
- std::string m = "Target: ";
- m += target->GetName();
- m += " depends on unknown target: ";
- m += name;
- cmSystemTools::Error(m.c_str());
- }
- fout << "\t\t{" << dspguid << "}." << depcount << " = {" << guid << "}\n";
- depcount++;
- }
-
- UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
- if(ui != this->UtilityDepends.end())
- {
- const char* uname = ui->second.c_str();
- fout << "\t\t{" << this->GetGUID(uname) << "}.0 = {" << dspguid << "}\n";
- }
-}
-
-
-// Write a dsp file into the SLN file, Note, that dependencies from
-// executables to the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator
-::WriteProjectConfigurations(
- std::ostream& fout, const std::string& name, cmState::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>::const_iterator i = configs.begin();
- i != configs.end(); ++i)
- {
- fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|" << platformName << "\n";
- std::set<std::string>::const_iterator
- ci = configsPartOfDefaultBuild.find(*i);
- if(!(ci == configsPartOfDefaultBuild.end()))
- {
- fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|" << platformName << "\n";
- }
- }
-}
-
-
-
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
- const std::string& name,
- const char* location,
- const char* typeGuid,
- const std::set<std::string>&)
-{
- fout << "Project("
- << "\"{"
- << (typeGuid ? typeGuid : this->ExternalProjectType(location))
- << "}\") = \""
- << name << "\", \""
- << this->ConvertToSolutionPath(location) << "\", \"{"
- << this->GetGUID(name)
- << "}\"\n";
- fout << "EndProject\n";
-}
-
-
-
void cmGlobalVisualStudio7Generator
::WriteSLNGlobalSections(std::ostream& fout,
cmLocalGenerator* root)
@@ -871,21 +661,12 @@ void cmGlobalVisualStudio7Generator
<< "\tEndGlobalSection\n";
}
-
-
// Standard end of dsw file
void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
{
fout << "EndGlobal\n";
}
-
-// ouput standard header for dsw file
-void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
-}
-
//----------------------------------------------------------------------------
std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(
@@ -970,14 +751,6 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
}
//----------------------------------------------------------------------------
-void cmGlobalVisualStudio7Generator
-::GetDocumentation(cmDocumentationEntry& entry)
-{
- entry.Name = cmGlobalVisualStudio7Generator::GetActualName();
- entry.Brief = "Deprecated. Generates Visual Studio .NET 2002 project files.";
-}
-
-//----------------------------------------------------------------------------
void
cmGlobalVisualStudio7Generator
::AppendDirectoryForConfig(const std::string& prefix,
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index de2d35e..02f9809 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -30,15 +30,6 @@ public:
const std::string& platformName = "");
~cmGlobalVisualStudio7Generator();
- static cmGlobalGeneratorFactory* NewFactory() {
- return new cmGlobalGeneratorSimpleFactory
- <cmGlobalVisualStudio7Generator>(); }
-
- ///! Get the name for the generator.
- virtual std::string GetName() const {
- return cmGlobalVisualStudio7Generator::GetActualName();}
- static std::string GetActualName() {return "Visual Studio 7";}
-
///! Get the name for the platform.
std::string const& GetPlatformName() const;
@@ -49,9 +40,6 @@ public:
virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
- /** Get the documentation entry for this generator. */
- static void GetDocumentation(cmDocumentationEntry& entry);
-
/**
* Utilized by the generator factory to determine if this generator
* supports toolsets.
@@ -117,7 +105,7 @@ public:
protected:
virtual void Generate();
- virtual const char* GetIDEVersion() { return "7.0"; }
+ virtual const char* GetIDEVersion() = 0;
std::string const& GetDevEnvCommand();
virtual std::string FindDevEnvCommand();
@@ -127,22 +115,22 @@ protected:
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators);
+ std::vector<cmLocalGenerator*>& generators) = 0;
virtual void WriteProject(std::ostream& fout,
const std::string& name, const char* path,
- const cmGeneratorTarget *t);
+ const cmGeneratorTarget *t) = 0;
virtual void WriteProjectDepends(std::ostream& fout,
const std::string& name, const char* path,
- cmGeneratorTarget const* t);
+ cmGeneratorTarget const* t) = 0;
virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmState::TargetType type,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
- const std::string& platformMapping = "");
+ const std::string& platformMapping = "") = 0;
virtual void WriteSLNGlobalSections(std::ostream& fout,
cmLocalGenerator* root);
virtual void WriteSLNFooter(std::ostream& fout);
- virtual void WriteSLNHeader(std::ostream& fout);
+ virtual void WriteSLNHeader(std::ostream& fout) = 0;
virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target);
virtual void WriteTargetsToSolution(
@@ -162,7 +150,7 @@ protected:
const char* path,
const char* typeGuid,
const std::set<std::string>&
- dependencies);
+ dependencies) = 0;
std::string ConvertToSolutionPath(const char* path);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 6a1aa29..04146fb 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -89,19 +89,13 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(gt);
-#if 0
- // Can't activate this code because we want ALL_BUILD
- // selected as the default "startup project" when first
- // opened in Visual Studio... And if it's nested in a
- // folder, then that doesn't happen.
//
// Organize in the "predefined targets" folder:
//
- if (this->UseFolderProperty())
+ if (this->UseFolderProperty() && this->GetVersion() > VS71)
{
allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
}
-#endif
// Now make all targets depend on the ALL_BUILD target
for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
@@ -184,12 +178,11 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
{
- cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
std::string dir = this->GetUserMacrosDirectory();
if (dir != "")
{
- std::string src = mf->GetRequiredDefinition("CMAKE_ROOT");
+ std::string src = cmSystemTools::GetCMakeRoot();
src += "/Templates/" CMAKE_VSMACROS_FILENAME;
std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
@@ -520,6 +513,32 @@ cmGlobalVisualStudioGenerator::GetUtilityDepend(
}
//----------------------------------------------------------------------------
+std::string
+cmGlobalVisualStudioGenerator::GetStartupProjectName(
+ cmLocalGenerator const* root) const
+{
+ const char* n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT");
+ if (n && *n)
+ {
+ std::string startup = n;
+ if (this->FindTarget(startup))
+ {
+ return startup;
+ }
+ else
+ {
+ root->GetMakefile()->IssueMessage(
+ cmake::AUTHOR_WARNING,
+ "Directory property VS_STARTUP_PROJECT specifies target "
+ "'" + startup + "' that does not exist. Ignoring.");
+ }
+ }
+
+ // default, if not specified
+ return this->GetAllTargetName();
+}
+
+//----------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index f827f26..723a75f 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -26,7 +26,6 @@ public:
/** Known versions of Visual Studio. */
enum VSVersion
{
- VS6 = 60,
VS7 = 70,
VS71 = 71,
VS8 = 80,
@@ -107,6 +106,8 @@ public:
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+ std::string GetStartupProjectName(cmLocalGenerator const* root) const;
+
void AddSymbolExportCommand(
cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
std::string const& configName);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 526e32f..7c85281 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -593,19 +593,28 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
cmGeneratedFileStream makefileStream
(this->CurrentReRunCMakeMakefile.c_str());
makefileStream.SetCopyIfDifferent(true);
- makefileStream << "# Generated by CMake, DO NOT EDIT\n";
- std::string checkCache = root->GetBinaryDirectory();
- checkCache += "/";
- checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
- checkCache += "cmake.check_cache";
- makefileStream << this->ConvertToRelativeForMake(checkCache.c_str())
- << ": ";
+ makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
+
+ makefileStream << "empty:= \n";
+ makefileStream << "space:= $(empty) $(empty)\n";
+ makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
+
for(std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i)
{
- makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
+ makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
+ << this->ConvertToRelativeForMake(i->c_str())
+ << "))\n";
}
- makefileStream << "\n\t" <<
+
+ std::string checkCache = root->GetBinaryDirectory();
+ checkCache += "/";
+ checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
+ checkCache += "cmake.check_cache";
+
+ makefileStream << "\n" << this->ConvertToRelativeForMake(checkCache.c_str())
+ << ": $(TARGETS)\n";
+ makefileStream << "\t" <<
this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
<< " -H" << this->ConvertToRelativeForMake(
root->GetSourceDirectory())
@@ -2805,7 +2814,10 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt,
fullName = gtgt->GetFullName(defConfig.c_str());
}
fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
- fileRef->AddAttribute("refType", this->CreateString("0"));
+ if(this->XcodeVersion == 15)
+ {
+ fileRef->AddAttribute("refType", this->CreateString("0"));
+ }
fileRef->AddAttribute("sourceTree",
this->CreateString("BUILT_PRODUCTS_DIR"));
fileRef->SetComment(gtgt->GetName().c_str());
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 2d78a41..26a1485 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -33,6 +33,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
impLib, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(),
message,
+ args.GetExcludeFromAll(),
args.GetOptional() || forceOpt);
}
@@ -48,7 +49,8 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator(
programs, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(),
message,
- args.GetRename().c_str(), args.GetOptional());
+ args.GetExcludeFromAll(), args.GetRename().c_str(),
+ args.GetOptional());
}
@@ -117,6 +119,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
int componentCount = 0;
bool doing_script = false;
bool doing_code = false;
+ bool exclude_from_all = false;
// Scan the args once for COMPONENT. Only allow one.
//
@@ -128,6 +131,10 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
++i;
component = args[i];
}
+ if(args[i] == "EXCLUDE_FROM_ALL")
+ {
+ exclude_from_all = true;
+ }
}
if(componentCount>1)
@@ -175,7 +182,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
}
this->Makefile->AddInstallGenerator(
new cmInstallScriptGenerator(script.c_str(), false,
- component.c_str()));
+ component.c_str(), exclude_from_all));
}
else if(doing_code)
{
@@ -183,7 +190,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
std::string code = args[i];
this->Makefile->AddInstallGenerator(
new cmInstallScriptGenerator(code.c_str(), true,
- component.c_str()));
+ component.c_str(), exclude_from_all));
}
}
@@ -949,6 +956,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
Doing doing = DoingDirs;
bool in_match_mode = false;
bool optional = false;
+ bool exclude_from_all = false;
bool message_never = false;
std::vector<std::string> dirs;
const char* destination = 0;
@@ -1130,6 +1138,19 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Switch to setting the component property.
doing = DoingComponent;
}
+ else if(args[i] == "EXCLUDE_FROM_ALL")
+ {
+ if(in_match_mode)
+ {
+ std::ostringstream e;
+ e << args[0] << " does not allow \""
+ << args[i] << "\" after PATTERN or REGEX.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ exclude_from_all = true;
+ doing = DoingNone;
+ }
else if(doing == DoingDirs)
{
// Convert this directory to a full path.
@@ -1273,6 +1294,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
configurations,
component.c_str(),
message,
+ exclude_from_all,
literal_args.c_str(),
optional));
@@ -1403,7 +1425,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
exportSet,
ica.GetDestination().c_str(),
ica.GetPermissions().c_str(), ica.GetConfigurations(),
- ica.GetComponent().c_str(), message, fname.c_str(),
+ ica.GetComponent().c_str(), message,
+ ica.GetExcludeFromAll(), fname.c_str(),
name_space.GetCString(), exportOld.IsEnabled());
this->Makefile->AddInstallGenerator(exportGenerator);
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 236ca1f..6ded365 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -27,14 +27,15 @@ cmInstallCommandArguments::cmInstallCommandArguments(
const std::string& defaultComponent)
:Parser()
,ArgumentGroup()
-,Destination (&Parser, "DESTINATION" , &ArgumentGroup)
-,Component (&Parser, "COMPONENT" , &ArgumentGroup)
-,Rename (&Parser, "RENAME" , &ArgumentGroup)
-,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup)
-,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
-,Optional (&Parser, "OPTIONAL" , &ArgumentGroup)
-,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
-,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
+,Destination (&Parser, "DESTINATION" , &ArgumentGroup)
+,Component (&Parser, "COMPONENT" , &ArgumentGroup)
+,ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup)
+,Rename (&Parser, "RENAME" , &ArgumentGroup)
+,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup)
+,Configurations(&Parser, "CONFIGURATIONS" , &ArgumentGroup)
+,Optional (&Parser, "OPTIONAL" , &ArgumentGroup)
+,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
+,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
,GenericArguments(0)
,DefaultComponentName(defaultComponent)
{
@@ -110,6 +111,19 @@ bool cmInstallCommandArguments::GetOptional() const
return false;
}
+bool cmInstallCommandArguments::GetExcludeFromAll() const
+{
+ if (this->ExcludeFromAll.IsEnabled())
+ {
+ return true;
+ }
+ if (this->GenericArguments!=0)
+ {
+ return this->GenericArguments->GetExcludeFromAll();
+ }
+ return false;
+}
+
bool cmInstallCommandArguments::GetNamelinkOnly() const
{
if (this->NamelinkOnly.IsEnabled())
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index 90347e6..694f1ed 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -30,6 +30,7 @@ class cmInstallCommandArguments
const std::string& GetDestination() const;
const std::string& GetComponent() const;
+ bool GetExcludeFromAll() const;
const std::string& GetRename() const;
const std::string& GetPermissions() const;
const std::vector<std::string>& GetConfigurations() const;
@@ -48,6 +49,7 @@ class cmInstallCommandArguments
cmInstallCommandArguments(); // disabled
cmCAString Destination;
cmCAString Component;
+ cmCAEnabler ExcludeFromAll;
cmCAString Rename;
cmCAStringVector Permissions;
cmCAStringVector Configurations;
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index f2e8609..6ad6c75 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -23,9 +23,11 @@ cmInstallDirectoryGenerator
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* literal_args,
bool optional):
- cmInstallGenerator(dest, configurations, component, message),
+ cmInstallGenerator(dest, configurations, component, message,
+ exclude_from_all),
LocalGenerator(0),
Directories(dirs),
FilePermissions(file_permissions), DirPermissions(dir_permissions),
diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h
index 9b732d3..b137f44 100644
--- a/Source/cmInstallDirectoryGenerator.h
+++ b/Source/cmInstallDirectoryGenerator.h
@@ -27,6 +27,7 @@ public:
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* literal_args,
bool optional = false);
virtual ~cmInstallDirectoryGenerator();
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 9570ba3..80fc054 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -33,9 +33,11 @@ cmInstallExportGenerator::cmInstallExportGenerator(
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* filename, const char* name_space,
bool exportOld)
- :cmInstallGenerator(destination, configurations, component, message)
+ :cmInstallGenerator(destination, configurations, component, message,
+ exclude_from_all)
,ExportSet(exportSet)
,FilePermissions(file_permissions)
,FileName(filename)
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index 885ed05..1b1c046 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -31,6 +31,7 @@ public:
const std::vector<std::string>& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* filename, const char* name_space,
bool exportOld);
~cmInstallExportGenerator();
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 68557bd..d3d258e 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -122,6 +122,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
// Use a file install generator.
const char* no_permissions = "";
const char* no_rename = "";
+ bool no_exclude_from_all = false;
std::string no_component = this->Makefile->GetSafeDefinition(
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
@@ -131,7 +132,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
new cmInstallFilesGenerator(this->Files,
destination.c_str(), false,
no_permissions, no_configurations,
- no_component.c_str(), message, no_rename));
+ no_component.c_str(), message,
+ no_exclude_from_all, no_rename));
}
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 383031b..3dd5528 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -24,9 +24,11 @@ cmInstallFilesGenerator
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* rename,
bool optional):
- cmInstallGenerator(dest, configurations, component, message),
+ cmInstallGenerator(dest, configurations, component, message,
+ exclude_from_all),
LocalGenerator(0),
Files(files),
FilePermissions(file_permissions),
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index bfe4039..efaf62b 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -26,6 +26,7 @@ public:
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
const char* rename,
bool optional = false);
virtual ~cmInstallFilesGenerator();
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 2e1c5f0..660e44f 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -19,11 +19,13 @@ cmInstallGenerator
::cmInstallGenerator(const char* destination,
std::vector<std::string> const& configurations,
const char* component,
- MessageLevel message):
+ MessageLevel message,
+ bool exclude_from_all):
cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations),
Destination(destination? destination:""),
Component(component? component:""),
- Message(message)
+ Message(message),
+ ExcludeFromAll(exclude_from_all)
{
}
@@ -146,12 +148,16 @@ void cmInstallGenerator
//----------------------------------------------------------------------------
std::string
-cmInstallGenerator::CreateComponentTest(const char* component)
+cmInstallGenerator::CreateComponentTest(const char* component,
+ bool exclude_from_all)
{
- std::string result = "NOT CMAKE_INSTALL_COMPONENT OR "
- "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \"";
+ std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \"";
result += component;
result += "\"";
+ if(!exclude_from_all)
+ {
+ result += " OR NOT CMAKE_INSTALL_COMPONENT";
+ }
return result;
}
@@ -163,7 +169,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
// Begin this block of installation.
std::string component_test =
- this->CreateComponentTest(this->Component.c_str());
+ this->CreateComponentTest(this->Component.c_str(),this->ExcludeFromAll);
os << indent << "if(" << component_test << ")\n";
// Generate the script possibly with per-configuration code.
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index b8e5b53..db895908 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -36,7 +36,8 @@ public:
cmInstallGenerator(const char* destination,
std::vector<std::string> const& configurations,
const char* component,
- MessageLevel message);
+ MessageLevel message,
+ bool exclude_from_all);
virtual ~cmInstallGenerator();
void AddInstallRule(
@@ -67,12 +68,14 @@ public:
protected:
virtual void GenerateScript(std::ostream& os);
- std::string CreateComponentTest(const char* component);
+ std::string CreateComponentTest(const char* component,
+ bool exclude_from_all);
// Information shared by most generator types.
std::string Destination;
std::string Component;
MessageLevel Message;
+ bool ExcludeFromAll;
};
#endif
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index e6fbe88..b6d0c45 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -85,6 +85,7 @@ void cmInstallProgramsCommand::FinalPass()
// Use a file install generator.
const char* no_permissions = "";
const char* no_rename = "";
+ bool no_exclude_from_all = false;
std::string no_component = this->Makefile->GetSafeDefinition(
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
@@ -94,7 +95,8 @@ void cmInstallProgramsCommand::FinalPass()
new cmInstallFilesGenerator(this->Files,
destination.c_str(), true,
no_permissions, no_configurations,
- no_component.c_str(), message, no_rename));
+ no_component.c_str(), message,
+ no_exclude_from_all, no_rename));
}
/**
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index 933aa07..d58d039 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -14,8 +14,9 @@
//----------------------------------------------------------------------------
cmInstallScriptGenerator
::cmInstallScriptGenerator(const char* script, bool code,
- const char* component) :
- cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault),
+ const char* component, bool exclude_from_all) :
+ cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault,
+ exclude_from_all),
Script(script), Code(code)
{
}
@@ -31,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
{
Indent indent;
std::string component_test =
- this->CreateComponentTest(this->Component.c_str());
+ this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
os << indent << "if(" << component_test << ")\n";
if(this->Code)
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 54a7b21..7e7c0c8 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -21,7 +21,7 @@ class cmInstallScriptGenerator: public cmInstallGenerator
{
public:
cmInstallScriptGenerator(const char* script, bool code,
- const char* component);
+ const char* component, bool exclude_from_all);
virtual ~cmInstallScriptGenerator();
protected:
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 5e88fa2..3d44fe2 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -30,8 +30,10 @@ cmInstallTargetGenerator
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
bool optional):
- cmInstallGenerator(dest, configurations, component, message),
+ cmInstallGenerator(dest, configurations, component, message,
+ exclude_from_all),
TargetName(targetName),
Target(0),
FilePermissions(file_permissions),
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 18b3130..46b4532 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -28,6 +28,7 @@ public:
std::vector<std::string> const& configurations,
const char* component,
MessageLevel message,
+ bool exclude_from_all,
bool optional
);
virtual ~cmInstallTargetGenerator();
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index b603bcc..561293e 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -73,7 +73,7 @@ struct cmLinkInterface: public cmLinkInterfaceLibraries
// Number of repetitions of a strongly connected component of two
// or more static libraries.
- int Multiplicity;
+ unsigned int Multiplicity;
// Libraries listed for other configurations.
// Needed only for OLD behavior of CMP0003.
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 6041fb7..15a1af5 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -14,6 +14,7 @@
#include <cmsys/SystemTools.hxx>
#include "cmAlgorithms.h"
+#include <algorithm>
#include <stdlib.h> // required for atoi
#include <ctype.h>
#include <assert.h>
@@ -68,6 +69,10 @@ bool cmListCommand
{
return this->HandleReverseCommand(args);
}
+ if(subCommand == "FILTER")
+ {
+ return this->HandleFilterCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
this->SetError(e);
@@ -517,3 +522,107 @@ bool cmListCommand::HandleRemoveAtCommand(
return true;
}
+//----------------------------------------------------------------------------
+bool cmListCommand::HandleFilterCommand(
+ std::vector<std::string> const& args)
+{
+ if(args.size() < 2)
+ {
+ this->SetError("sub-command FILTER requires a list to be specified.");
+ return false;
+ }
+
+ if(args.size() < 3)
+ {
+ this->SetError("sub-command FILTER requires an operator to be specified.");
+ return false;
+ }
+
+ if(args.size() < 4)
+ {
+ this->SetError("sub-command FILTER requires a mode to be specified.");
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if ( !this->GetList(varArgsExpanded, listName) )
+ {
+ this->SetError("sub-command FILTER requires list to be present.");
+ return false;
+ }
+
+ const std::string& op = args[2];
+ bool includeMatches;
+ if(op == "INCLUDE")
+ {
+ includeMatches = true;
+ }
+ else if(op == "EXCLUDE")
+ {
+ includeMatches = false;
+ }
+ else
+ {
+ this->SetError("sub-command FILTER does not recognize operator " + op);
+ return false;
+ }
+
+ const std::string& mode = args[3];
+ if(mode == "REGEX")
+ {
+ if(args.size() != 5)
+ {
+ this->SetError("sub-command FILTER, mode REGEX "
+ "requires five arguments.");
+ return false;
+ }
+ return this->FilterRegex(args, includeMatches, listName, varArgsExpanded);
+ }
+
+ this->SetError("sub-command FILTER does not recognize mode " + mode);
+ return false;
+}
+
+//----------------------------------------------------------------------------
+class MatchesRegex {
+public:
+ MatchesRegex(cmsys::RegularExpression& in_regex, bool in_includeMatches)
+ : regex(in_regex), includeMatches(in_includeMatches) {}
+
+ bool operator()(const std::string& target) {
+ return regex.find(target) ^ includeMatches;
+ }
+
+private:
+ cmsys::RegularExpression& regex;
+ const bool includeMatches;
+};
+
+bool cmListCommand::FilterRegex(std::vector<std::string> const& args,
+ bool includeMatches,
+ std::string const& listName,
+ std::vector<std::string>& varArgsExpanded)
+{
+ const std::string& pattern = args[4];
+ cmsys::RegularExpression regex(pattern);
+ if(!regex.is_valid())
+ {
+ std::string error = "sub-command FILTER, mode REGEX ";
+ error += "failed to compile regex \"";
+ error += pattern;
+ error += "\".";
+ this->SetError(error);
+ return false;
+ }
+
+ std::vector<std::string>::iterator argsBegin = varArgsExpanded.begin();
+ std::vector<std::string>::iterator argsEnd = varArgsExpanded.end();
+ std::vector<std::string>::iterator newArgsEnd =
+ std::remove_if(argsBegin, argsEnd, MatchesRegex(regex, includeMatches));
+
+ std::string value = cmJoin(cmMakeRange(argsBegin, newArgsEnd), ";");
+ this->Makefile->AddDefinition(listName, value.c_str());
+ return true;
+}
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 5ea1d9f..25edee8 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -58,6 +58,12 @@ protected:
bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args);
bool HandleSortCommand(std::vector<std::string> const& args);
bool HandleReverseCommand(std::vector<std::string> const& args);
+ bool HandleFilterCommand(std::vector<std::string> const& args);
+ bool FilterRegex(std::vector<std::string> const& args,
+ bool includeMatches,
+ std::string const& listName,
+ std::vector<std::string>& varArgsExpanded
+ );
bool GetList(std::vector<std::string>& list, const std::string& var);
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 03e0abe..4d3055f 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -58,8 +58,9 @@ struct cmListFileArgument
long Line;
};
-struct cmListFileContext
+class cmListFileContext
{
+public:
std::string Name;
std::string FilePath;
long Line;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 912be0c..1be39a9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2455,7 +2455,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
else
{
// Make the definition appear properly on the command line. Use
- // -DNAME="value" instead of -D"NAME=value" to help VS6 parser.
+ // -DNAME="value" instead of -D"NAME=value" for historical reasons.
std::string::size_type eq = defineIt->find("=");
def += defineIt->substr(0, eq);
if(eq != defineIt->npos)
@@ -2559,7 +2559,7 @@ public:
cmInstallTargetGenerator(
t, dest, implib, "", std::vector<std::string>(), "Unspecified",
cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()),
- false)
+ false, false)
{
this->Compute(lg);
}
@@ -2586,7 +2586,7 @@ cmLocalGenerator
// Include the user-specified pre-install script for this target.
if(const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT"))
{
- cmInstallScriptGenerator g(preinstall, false, 0);
+ cmInstallScriptGenerator g(preinstall, false, 0, false);
g.Generate(os, config, configurationTypes);
}
@@ -2647,7 +2647,7 @@ cmLocalGenerator
// Include the user-specified post-install script for this target.
if(const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT"))
{
- cmInstallScriptGenerator g(postinstall, false, 0);
+ cmInstallScriptGenerator g(postinstall, false, 0, false);
g.Generate(os, config, configurationTypes);
}
}
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index b2927a9..8a68af6 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -454,13 +454,24 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
cmGeneratorTarget* target)
{
- this->CustomCommandTargets[cc].insert(target);
+ CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>());
+ std::pair<CustomCommandTargetMap::iterator, bool>
+ ins = this->CustomCommandTargets.insert(v);
+ if (ins.second)
+ {
+ this->CustomCommands.push_back(cc);
+ }
+ ins.first->second.insert(target);
}
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
{
- for (CustomCommandTargetMap::iterator i = this->CustomCommandTargets.begin();
- i != this->CustomCommandTargets.end(); ++i) {
+ for (std::vector<cmCustomCommand const*>::iterator vi =
+ this->CustomCommands.begin(); vi != this->CustomCommands.end(); ++vi)
+ {
+ CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi);
+ assert(i != this->CustomCommandTargets.end());
+
// A custom command may appear on multiple targets. However, some build
// systems exist where the target dependencies on some of the targets are
// overspecified, leading to a dependency cycle. If we assume all target
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index b6987ef..5e1d6f2 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -106,6 +106,7 @@ private:
typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> >
CustomCommandTargetMap;
CustomCommandTargetMap CustomCommandTargets;
+ std::vector<cmCustomCommand const*> CustomCommands;
};
#endif // ! cmLocalNinjaGenerator_h
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 62fea3d..afdff33 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -34,6 +34,7 @@
#include <cmsys/Terminal.h>
#include <queue>
+#include <algorithm>
//----------------------------------------------------------------------------
// Escape special characters in Makefile dependency lines
@@ -1971,6 +1972,57 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
}
+namespace
+{
+ // Helper predicate for removing absolute paths that don't point to the
+ // source or binary directory. It is used when CMAKE_DEPENDS_IN_PROJECT_ONLY
+ // is set ON, to only consider in-project dependencies during the build.
+ class NotInProjectDir
+ {
+ public:
+ // Constructor with the source and binary directory's path
+ NotInProjectDir(const std::string& sourceDir,
+ const std::string& binaryDir)
+ : SourceDir(sourceDir), BinaryDir(binaryDir) {}
+
+ // Operator evaluating the predicate
+ bool operator()(const std::string& path) const
+ {
+ // Keep all relative paths:
+ if(!cmSystemTools::FileIsFullPath(path))
+ {
+ return false;
+ }
+ // If it's an absolute path, check if it starts with the source
+ // direcotory:
+ return (!(IsInDirectory(SourceDir, path)||
+ IsInDirectory(BinaryDir, path)));
+ }
+
+ private:
+ // Helper function used by the predicate
+ static bool IsInDirectory(const std::string& baseDir,
+ const std::string& testDir)
+ {
+ // First check if the test directory "starts with" the base directory:
+ if (testDir.find(baseDir) != 0)
+ {
+ return false;
+ }
+ // If it does, then check that it's either the same string, or that the
+ // next character is a slash:
+ return ((testDir.size() == baseDir.size())||
+ (testDir[baseDir.size()] == '/'));
+ }
+
+ // The path to the source directory
+ std::string SourceDir;
+ // The path to the binary directory
+ std::string BinaryDir;
+ };
+}
+
+
void cmLocalUnixMakefileGenerator3
::WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget* target)
@@ -2058,6 +2110,15 @@ void cmLocalUnixMakefileGenerator3
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GetIncludeDirectories(includes, target,
l->first, config);
+ if(this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY"))
+ {
+ const char* sourceDir = this->GetState()->GetSourceDirectory();
+ const char* binaryDir = this->GetState()->GetBinaryDirectory();
+ std::vector<std::string>::iterator itr =
+ std::remove_if(includes.begin(), includes.end(),
+ ::NotInProjectDir(sourceDir, binaryDir));
+ includes.erase(itr, includes.end());
+ }
for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i)
{
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
deleted file mode 100644
index cdacb9e..0000000
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ /dev/null
@@ -1,2002 +0,0 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- 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 "cmGlobalGenerator.h"
-#include "cmLocalVisualStudio6Generator.h"
-#include "cmMakefile.h"
-#include "cmSystemTools.h"
-#include "cmSourceFile.h"
-#include "cmGeneratorTarget.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmake.h"
-
-#include "cmComputeLinkInformation.h"
-
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/FStream.hxx>
-
-cmLocalVisualStudio6Generator
-::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf):
- cmLocalVisualStudioGenerator(gg, mf)
-{
-}
-
-cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator()
-{
-}
-
-//----------------------------------------------------------------------------
-// Helper class to write build events.
-class cmLocalVisualStudio6Generator::EventWriter
-{
-public:
- EventWriter(cmLocalVisualStudio6Generator* lg,
- const std::string& config, std::string& code):
- LG(lg), Config(config), Code(code), First(true) {}
- void Start(const char* event)
- {
- this->First = true;
- this->Event = event;
- }
- void Finish()
- {
- this->Code += (this->First? "" : "\n");
- }
- void Write(std::vector<cmCustomCommand> const& ccs)
- {
- for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
- ci != ccs.end(); ++ci)
- {
- this->Write(*ci);
- }
- }
- void Write(cmCustomCommand const& cc)
- {
- cmCustomCommandGenerator ccg(cc, this->Config, this->LG);
- if(this->First)
- {
- this->Code += this->Event + "_Cmds=";
- this->First = false;
- }
- else
- {
- this->Code += "\\\n\t";
- }
- this->Code += this->LG->ConstructScript(ccg, "\\\n\t");
- }
-private:
- cmLocalVisualStudio6Generator* LG;
- std::string Config;
- std::string& Code;
- bool First;
- std::string Event;
-};
-
-void cmLocalVisualStudio6Generator::AddCMakeListsRules()
-{
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l)
- {
- if ((*l)->GetType() == cmState::INTERFACE_LIBRARY
- || (*l)->GetType() == cmState::GLOBAL_TARGET)
- {
- continue;
- }
-
- // Add a rule to regenerate the build system when the target
- // specification source changes.
- const char* suppRegenRule =
- this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
- if (!cmSystemTools::IsOn(suppRegenRule))
- {
- this->AddDSPBuildRule(*l);
- }
- }
-}
-
-void cmLocalVisualStudio6Generator::Generate()
-{
- this->OutputDSPFile();
-}
-
-void cmLocalVisualStudio6Generator::OutputDSPFile()
-{
- // If not an in source build, then create the output directory
- if(strcmp(this->GetCurrentBinaryDirectory(),
- this->GetSourceDirectory()) != 0)
- {
- if(!cmSystemTools::MakeDirectory
- (this->GetCurrentBinaryDirectory()))
- {
- cmSystemTools::Error("Error creating directory ",
- this->GetCurrentBinaryDirectory());
- }
- }
-
- // Create the DSP or set of DSP's for libraries and executables
-
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l)
- {
- switch((*l)->GetType())
- {
- case cmState::STATIC_LIBRARY:
- case cmState::OBJECT_LIBRARY:
- this->SetBuildType(STATIC_LIBRARY,
- (*l)->GetName().c_str(), *l);
- break;
- case cmState::SHARED_LIBRARY:
- case cmState::MODULE_LIBRARY:
- this->SetBuildType(DLL,
- (*l)->GetName().c_str(), *l);
- break;
- case cmState::EXECUTABLE:
- this->SetBuildType(EXECUTABLE,
- (*l)->GetName().c_str(), *l);
- break;
- case cmState::UTILITY:
- case cmState::GLOBAL_TARGET:
- this->SetBuildType(UTILITY,
- (*l)->GetName().c_str(), *l);
- break;
- case cmState::INTERFACE_LIBRARY:
- continue;
- default:
- cmSystemTools::Error("Bad target type: ", (*l)->GetName().c_str());
- break;
- }
- // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
- // so don't build a projectfile for it
- const char* path =
- (*l)->GetProperty("EXTERNAL_MSPROJECT");
- if(!path)
- {
- // check to see if the dsp is going into a sub-directory
- std::string::size_type pos = (*l)->GetName().rfind('/');
- if(pos != std::string::npos)
- {
- std::string dir = this->GetCurrentBinaryDirectory();
- dir += "/";
- dir += (*l)->GetName().substr(0, pos);
- if(!cmSystemTools::MakeDirectory(dir.c_str()))
- {
- cmSystemTools::Error("Error creating directory: ", dir.c_str());
- }
- }
- this->CreateSingleDSP((*l)->GetName().c_str(), *l);
- }
- }
-}
-
-// Utility function to make a valid VS6 *.dsp filename out
-// of a CMake target name:
-//
-extern std::string GetVS6TargetName(const std::string& targetName);
-
-void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
- cmGeneratorTarget* target)
-{
- // add to the list of projects
- std::string pname = GetVS6TargetName(lname);
-
- // create the dsp.cmake file
- std::string fname;
- fname = this->GetCurrentBinaryDirectory();
- fname += "/";
- fname += pname;
- fname += ".dsp";
- // save the name of the real dsp file
- std::string realDSP = fname;
- fname += ".cmake";
- cmsys::ofstream fout(fname.c_str());
- if(!fout)
- {
- cmSystemTools::Error("Error Writing ", fname.c_str());
- cmSystemTools::ReportLastSystemError("");
- }
- this->WriteDSPFile(fout,pname.c_str(),target);
- fout.close();
- // if the dsp file has changed, then write it.
- cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
-}
-
-
-void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmGeneratorTarget *tgt)
-{
- std::string dspname = GetVS6TargetName(tgt->GetName());
- dspname += ".dsp.cmake";
- cmCustomCommandLine commandLine;
- commandLine.push_back(cmSystemTools::GetCMakeCommand());
- std::string makefileIn = this->GetCurrentSourceDirectory();
- makefileIn += "/";
- makefileIn += "CMakeLists.txt";
- if(!cmSystemTools::FileExists(makefileIn.c_str()))
- {
- return;
- }
- std::string comment = "Building Custom Rule ";
- comment += makefileIn;
- std::string args;
- args = "-H";
- args += this->GetSourceDirectory();
- commandLine.push_back(args);
- args = "-B";
- args += this->GetBinaryDirectory();
- commandLine.push_back(args);
-
- std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
-
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
- const char* no_working_directory = 0;
- this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles,
- makefileIn.c_str(), commandLines,
- comment.c_str(),
- no_working_directory, true);
- if(this->Makefile->GetSource(makefileIn.c_str()))
- {
- tgt->AddSource(makefileIn);
- }
- else
- {
- cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
- }
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
- const std::string& libName,
- cmGeneratorTarget *target)
-{
- // For utility targets need custom command since pre- and post-
- // build does not do anything in Visual Studio 6. In order for the
- // rules to run in the correct order as custom commands, we need
- // special care for dependencies. The first rule must depend on all
- // the dependencies of all the rules. The later rules must each
- // depend only on the previous rule.
- if ((target->GetType() == cmState::UTILITY ||
- target->GetType() == cmState::GLOBAL_TARGET) &&
- (!target->GetPreBuildCommands().empty() ||
- !target->GetPostBuildCommands().empty()))
- {
- // Accumulate the dependencies of all the commands.
- std::vector<std::string> depends;
- for (std::vector<cmCustomCommand>::const_iterator cr =
- target->GetPreBuildCommands().begin();
- cr != target->GetPreBuildCommands().end(); ++cr)
- {
- depends.insert(depends.end(),
- cr->GetDepends().begin(), cr->GetDepends().end());
- }
- for (std::vector<cmCustomCommand>::const_iterator cr =
- target->GetPostBuildCommands().begin();
- cr != target->GetPostBuildCommands().end(); ++cr)
- {
- depends.insert(depends.end(),
- cr->GetDepends().begin(), cr->GetDepends().end());
- }
-
- // Add the pre- and post-build commands in order.
- int count = 1;
- for (std::vector<cmCustomCommand>::const_iterator cr =
- target->GetPreBuildCommands().begin();
- cr != target->GetPreBuildCommands().end(); ++cr)
- {
- this->AddUtilityCommandHack(target, count++, depends, *cr);
- }
- for (std::vector<cmCustomCommand>::const_iterator cr =
- target->GetPostBuildCommands().begin();
- cr != target->GetPostBuildCommands().end(); ++cr)
- {
- this->AddUtilityCommandHack(target, count++, depends, *cr);
- }
- }
-
- // We may be modifying the source groups temporarily, so make a copy.
- std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
-
- // get the classes from the source lists then add them to the groups
- std::vector<cmSourceFile*> classes;
- if (!target->GetConfigCommonSourceFiles(classes))
- {
- return;
- }
-
- // now all of the source files have been properly assigned to the target
- // now stick them into source groups using the reg expressions
- for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
- i != classes.end(); i++)
- {
- if (!(*i)->GetObjectLibrary().empty())
- {
- continue;
- }
-
- // Add the file to the list of sources.
- std::string source = (*i)->GetFullPath();
- cmSourceGroup* sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
- sourceGroup->AssignSource(*i);
- // while we are at it, if it is a .rule file then for visual studio 6 we
- // must generate it
- if ((*i)->GetPropertyAsBool("__CMAKE_RULE"))
- {
- if(!cmSystemTools::FileExists(source.c_str()))
- {
- cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
- // Make sure the path exists for the file
- std::string path = cmSystemTools::GetFilenamePath(source);
- cmSystemTools::MakeDirectory(path.c_str());
-#if defined(_WIN32) || defined(__CYGWIN__)
- cmsys::ofstream sourceFout(source.c_str(),
- std::ios::binary | std::ios::out
- | std::ios::trunc);
-#else
- cmsys::ofstream sourceFout(source.c_str(),
- std::ios::out | std::ios::trunc);
-#endif
- if(sourceFout)
- {
- sourceFout.write("# generated from CMake",22);
- sourceFout.flush();
- sourceFout.close();
- }
- }
- }
- }
-
- // Write the DSP file's header.
- this->WriteDSPHeader(fout, libName, target, sourceGroups);
-
-
- // Loop through every source group.
- for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
- sg != sourceGroups.end(); ++sg)
- {
- this->WriteGroup(&(*sg), target, fout, libName);
- }
-
- // Write the DSP file's footer.
- this->WriteDSPFooter(fout);
-}
-
-void cmLocalVisualStudio6Generator
-::WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target,
- std::ostream &fout, const std::string& libName)
-{
- const std::vector<const cmSourceFile *> &sourceFiles =
- sg->GetSourceFiles();
- // If the group is empty, don't write it at all.
-
- if(sourceFiles.empty() && sg->GetGroupChildren().empty())
- {
- return;
- }
-
- // If the group has a name, write the header.
- std::string name = sg->GetName();
- if(name != "")
- {
- this->WriteDSPBeginGroup(fout, name.c_str(), "");
- }
-
- // Loop through each source in the source group.
- for(std::vector<const cmSourceFile *>::const_iterator sf =
- sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
- {
- if (!(*sf)->GetObjectLibrary().empty())
- {
- continue;
- }
-
- std::string source = (*sf)->GetFullPath();
- const cmCustomCommand *command =
- (*sf)->GetCustomCommand();
- std::string compileFlags;
- std::vector<std::string> depends;
- std::string objectNameDir;
- if(target->HasExplicitObjectName(*sf))
- {
- objectNameDir =
- cmSystemTools::GetFilenamePath(target->GetObjectName(*sf));
- }
-
- // Add per-source file flags.
- if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"))
- {
- compileFlags += cflags;
- }
-
- const std::string& lang = this->GetSourceFileLanguage(*(*sf));
- if(lang == "CXX")
- {
- // force a C++ file type
- compileFlags += " /TP ";
- }
- else if(lang == "C")
- {
- // force to c file type
- compileFlags += " /TC ";
- }
-
- // Add per-source and per-configuration preprocessor definitions.
- std::map<std::string, std::string> cdmap;
-
- {
- std::set<std::string> targetCompileDefinitions;
-
- this->AppendDefines(targetCompileDefinitions,
- (*sf)->GetProperty("COMPILE_DEFINITIONS"));
- this->JoinDefines(targetCompileDefinitions, compileFlags, lang);
- }
-
- if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
- {
- std::set<std::string> debugCompileDefinitions;
- this->AppendDefines(debugCompileDefinitions, cdefs);
- this->JoinDefines(debugCompileDefinitions, cdmap["DEBUG"], lang);
- }
- if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE"))
- {
- std::set<std::string> releaseCompileDefinitions;
- this->AppendDefines(releaseCompileDefinitions, cdefs);
- this->JoinDefines(releaseCompileDefinitions, cdmap["RELEASE"], lang);
- }
- if(const char* cdefs =
- (*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"))
- {
- std::set<std::string> minsizerelCompileDefinitions;
- this->AppendDefines(minsizerelCompileDefinitions, cdefs);
- this->JoinDefines(minsizerelCompileDefinitions, cdmap["MINSIZEREL"],
- lang);
- }
- if(const char* cdefs =
- (*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"))
- {
- std::set<std::string> relwithdebinfoCompileDefinitions;
- this->AppendDefines(relwithdebinfoCompileDefinitions, cdefs);
- this->JoinDefines(relwithdebinfoCompileDefinitions,
- cdmap["RELWITHDEBINFO"], lang);
- }
-
- bool excludedFromBuild =
- (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
-
- // Check for extra object-file dependencies.
- const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
- if(dependsValue)
- {
- cmSystemTools::ExpandListArgument(dependsValue, depends);
- }
- if (GetVS6TargetName(source) != libName ||
- target->GetType() == cmState::UTILITY ||
- target->GetType() == cmState::GLOBAL_TARGET)
- {
- fout << "# Begin Source File\n\n";
-
- // Tell MS-Dev what the source is. If the compiler knows how to
- // build it, then it will.
- fout << "SOURCE=" <<
- this->ConvertToOutputFormat(source.c_str(), SHELL) << "\n\n";
- if(!depends.empty())
- {
- // Write out the dependencies for the rule.
- fout << "USERDEP__HACK=";
- for(std::vector<std::string>::const_iterator d = depends.begin();
- d != depends.end(); ++d)
- {
- fout << "\\\n\t" <<
- this->ConvertToOutputFormat(d->c_str(), SHELL);
- }
- fout << "\n";
- }
- if (command)
- {
- const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
- this->WriteCustomRule(fout, source.c_str(), *command, flags);
- }
- else if(!compileFlags.empty() || !objectNameDir.empty() ||
- excludedFromBuild || !cdmap.empty())
- {
- for(std::vector<std::string>::iterator i
- = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
- {
- // Strip the subdirectory name out of the configuration name.
- std::string config = this->GetConfigName(*i);
- if (i == this->Configurations.begin())
- {
- fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
- }
- else
- {
- fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
- }
- if(excludedFromBuild)
- {
- fout << "# PROP Exclude_From_Build 1\n";
- }
- if(!compileFlags.empty())
- {
- fout << "\n# ADD CPP " << compileFlags << "\n\n";
- }
- std::map<std::string, std::string>::iterator cdi =
- cdmap.find(cmSystemTools::UpperCase(config));
- if(cdi != cdmap.end() && !cdi->second.empty())
- {
- fout << "\n# ADD CPP " << cdi->second << "\n\n";
- }
- if(!objectNameDir.empty())
- {
- // Setup an alternate object file directory.
- fout << "\n# PROP Intermediate_Dir \""
- << config << "/" << objectNameDir << "\"\n\n";
- }
- }
- fout << "!ENDIF\n\n";
- }
- fout << "# End Source File\n";
- }
- }
-
- std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
-
- for(unsigned int i=0;i<children.size();++i)
- {
- this->WriteGroup(&children[i], target, fout, libName);
- }
-
-
-
-
- // If the group has a name, write the footer.
- if(name != "")
- {
- this->WriteDSPEndGroup(fout);
- }
-
-}
-
-
-void
-cmLocalVisualStudio6Generator
-::AddUtilityCommandHack(cmGeneratorTarget *target, int count,
- std::vector<std::string>& depends,
- const cmCustomCommand& origCommand)
-{
- // Create a fake output that forces the rule to run.
- char* output = new char[(strlen(this->GetCurrentBinaryDirectory())
- + target->GetName().size() + 30)];
- sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(),
- target->GetName().c_str(), count);
- const char* comment = origCommand.GetComment();
- if(!comment && origCommand.GetOutputs().empty())
- {
- comment = "<hack>";
- }
-
- // Add the rule with the given dependencies and commands.
- std::string no_main_dependency = "";
- if(cmSourceFile* outsf =
- this->Makefile->AddCustomCommandToOutput(
- output, depends, no_main_dependency,
- origCommand.GetCommandLines(), comment,
- origCommand.GetWorkingDirectory().c_str()))
- {
- target->AddSource(outsf->GetFullPath());
- }
-
- // Replace the dependencies with the output of this rule so that the
- // next rule added will run after this one.
- depends.clear();
- depends.push_back(output);
-
- // Free the fake output name.
- delete [] output;
-}
-
-void
-cmLocalVisualStudio6Generator
-::WriteCustomRule(std::ostream& fout,
- const char* source,
- const cmCustomCommand& command,
- const char* flags)
-{
- // Write the rule for each configuration.
- std::vector<std::string>::iterator i;
- for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
- {
- std::string config = this->GetConfigName(*i);
- cmCustomCommandGenerator ccg(command, config, this);
- std::string comment =
- this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
- if(comment == "<hack>")
- {
- comment = "";
- }
-
- std::string script =
- this->ConstructScript(ccg, "\\\n\t");
-
- if (i == this->Configurations.begin())
- {
- fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
- }
- else
- {
- fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
- }
- if(flags)
- {
- fout << "\n# ADD CPP " << flags << "\n\n";
- }
- // Write out the dependencies for the rule.
- fout << "USERDEP__HACK=";
- for(std::vector<std::string>::const_iterator d =
- ccg.GetDepends().begin();
- d != ccg.GetDepends().end();
- ++d)
- {
- // Lookup the real name of the dependency in case it is a CMake target.
- std::string dep;
- if(this->GetRealDependency(d->c_str(), config.c_str(), dep))
- {
- fout << "\\\n\t" <<
- this->ConvertToOutputFormat(dep.c_str(), SHELL);
- }
- }
- fout << "\n";
-
- fout << "# PROP Ignore_Default_Tool 1\n";
- fout << "# Begin Custom Build -";
- if(!comment.empty())
- {
- fout << " " << comment.c_str();
- }
- fout << "\n\n";
- if(ccg.GetOutputs().empty())
- {
- fout << source
- << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
- fout << script.c_str() << "\n\n";
- }
- else
- {
- for(std::vector<std::string>::const_iterator o =
- ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end();
- ++o)
- {
- // Write a rule for every output generated by this command.
- fout << this->ConvertToOutputFormat(o->c_str(), SHELL)
- << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
- fout << script.c_str() << "\n\n";
- }
- }
- fout << "# End Custom Build\n\n";
- }
-
- fout << "!ENDIF\n\n";
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout,
- const char* group,
- const char* filter)
-{
- fout << "# Begin Group \"" << group << "\"\n"
- "# PROP Default_Filter \"" << filter << "\"\n";
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
-{
- fout << "# End Group\n";
-}
-
-
-
-
-void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
- const std::string& libName,
- cmGeneratorTarget *target)
-{
- std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
- const char *def=
- this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
-
- if( def)
- {
- root = def;
- }
- else
- {
- root += "/Templates";
- }
-
- switch(b)
- {
- case WIN32_EXECUTABLE:
- break;
- case STATIC_LIBRARY:
- this->DSPHeaderTemplate = root;
- this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate";
- this->DSPFooterTemplate = root;
- this->DSPFooterTemplate += "/staticLibFooter.dsptemplate";
- break;
- case DLL:
- this->DSPHeaderTemplate = root;
- this->DSPHeaderTemplate += "/DLLHeader.dsptemplate";
- this->DSPFooterTemplate = root;
- this->DSPFooterTemplate += "/DLLFooter.dsptemplate";
- break;
- case EXECUTABLE:
- if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
- {
- this->DSPHeaderTemplate = root;
- this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate";
- this->DSPFooterTemplate = root;
- this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
- }
- else
- {
- this->DSPHeaderTemplate = root;
- this->DSPHeaderTemplate += "/EXEHeader.dsptemplate";
- this->DSPFooterTemplate = root;
- this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
- }
- break;
- case UTILITY:
- this->DSPHeaderTemplate = root;
- this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate";
- this->DSPFooterTemplate = root;
- this->DSPFooterTemplate += "/UtilityFooter.dsptemplate";
- break;
- }
-
- // once the build type is set, determine what configurations are
- // possible
- cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
-
- cmsys::RegularExpression reg("# Name ");
- if(!fin)
- {
- cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
- }
-
- // reset this->Configurations
- this->Configurations.erase(this->Configurations.begin(),
- this->Configurations.end());
-
- // now add all the configurations possible
- std::string vs6name = GetVS6TargetName(libName);
- std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
- if (reg.find(line))
- {
- this->Configurations.push_back(line.substr(reg.end()));
- }
- }
-}
-
-//----------------------------------------------------------------------------
-cmsys::auto_ptr<cmCustomCommand>
-cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmGeneratorTarget* target,
- const std::string& config)
-{
- cmsys::auto_ptr<cmCustomCommand> pcc;
-
- // VS6 forgets to create the output directory for archives if it
- // differs from the intermediate directory.
- if(target->GetType() != cmState::STATIC_LIBRARY) { return pcc; }
-
- std::string outDir = target->GetDirectory(config, false);
-
- // Add a pre-link event to create the directory.
- cmCustomCommandLine command;
- command.push_back(cmSystemTools::GetCMakeCommand());
- command.push_back("-E");
- command.push_back("make_directory");
- command.push_back(outDir);
- std::vector<std::string> no_output;
- std::vector<std::string> no_byproducts;
- std::vector<std::string> no_depends;
- cmCustomCommandLines commands;
- commands.push_back(command);
- pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
- no_depends, commands, 0, 0));
- pcc->SetEscapeOldStyle(false);
- pcc->SetEscapeAllowMakeVars(true);
- return pcc;
-}
-
-// look for custom rules on a target and collect them together
-std::string
-cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
- const std::string& configName,
- const std::string& /* libName */)
-{
- if (target->GetType() >= cmState::UTILITY )
- {
- return "";
- }
-
- std::string customRuleCode = "# Begin Special Build Tool\n";
- EventWriter event(this, configName, customRuleCode);
-
- // Write the pre-build and pre-link together (VS6 does not support both).
- event.Start("PreLink");
- event.Write(target->GetPreBuildCommands());
- event.Write(target->GetPreLinkCommands());
- cmsys::auto_ptr<cmCustomCommand> pcc(
- this->MaybeCreateImplibDir(target, configName, false));
- if(pcc.get())
- {
- event.Write(*pcc);
- }
- pcc = this->MaybeCreateOutputDir(target, configName);
- if(pcc.get())
- {
- event.Write(*pcc);
- }
- event.Finish();
-
- // Write the post-build rules.
- event.Start("PostBuild");
- event.Write(target->GetPostBuildCommands());
- event.Finish();
-
- customRuleCode += "# End Special Build Tool\n";
- return customRuleCode;
-}
-
-
-inline std::string removeQuotes(const std::string& s)
-{
- if(s[0] == '\"' && s[s.size()-1] == '\"')
- {
- return s.substr(1, s.size()-2);
- }
- return s;
-}
-
-
-std::string
-cmLocalVisualStudio6Generator::GetTargetIncludeOptions(
- cmGeneratorTarget *target,
- const std::string& config)
-{
- std::string includeOptions;
-
- // Setup /I and /LIBPATH options for the resulting DSP file. VS 6
- // truncates long include paths so make it as short as possible if
- // the length threatens this problem.
- unsigned int maxIncludeLength = 3000;
- bool useShortPath = false;
-
- for(int j=0; j < 2; ++j)
- {
- std::vector<std::string> includes;
- this->GetIncludeDirectories(includes, target, "C", config);
-
- std::vector<std::string>::iterator i;
- for(i = includes.begin(); i != includes.end(); ++i)
- {
- std::string tmp =
- this->ConvertToOutputFormat(i->c_str(), SHELL);
- if(useShortPath)
- {
- cmSystemTools::GetShortPath(tmp.c_str(), tmp);
- }
- includeOptions += " /I ";
-
- // quote if not already quoted
- if (tmp[0] != '"')
- {
- includeOptions += "\"";
- includeOptions += tmp;
- includeOptions += "\"";
- }
- else
- {
- includeOptions += tmp;
- }
- }
-
- if(j == 0 && includeOptions.size() > maxIncludeLength)
- {
- includeOptions = "";
- useShortPath = true;
- }
- else
- {
- break;
- }
- }
-
- return includeOptions;
-}
-
-
-// Code in blocks surrounded by a test for this definition is needed
-// only for compatibility with user project's replacement DSP
-// templates. The CMake templates no longer use them.
-#define CM_USE_OLD_VS6
-
-void cmLocalVisualStudio6Generator
-::WriteDSPHeader(std::ostream& fout,
- const std::string& libName, cmGeneratorTarget* target,
- std::vector<cmSourceGroup> &)
-{
- bool targetBuilds = (target->GetType() >= cmState::EXECUTABLE &&
- target->GetType() <= cmState::MODULE_LIBRARY);
-#ifdef CM_USE_OLD_VS6
- // Lookup the library and executable output directories.
- std::string libPath;
- if(this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
- {
- libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
- }
- std::string exePath;
- if(this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
- {
- exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
- }
-
- // Make sure there are trailing slashes.
- if(!libPath.empty())
- {
- if(libPath[libPath.size()-1] != '/')
- {
- libPath += "/";
- }
- }
- if(!exePath.empty())
- {
- if(exePath[exePath.size()-1] != '/')
- {
- exePath += "/";
- }
- }
-
- std::set<std::string> pathEmitted;
-
- // determine the link directories
- std::string libOptions;
- std::string libDebugOptions;
- std::string libOptimizedOptions;
-
- std::string libMultiLineOptions;
- std::string libMultiLineOptionsForDebug;
- std::string libMultiLineDebugOptions;
- std::string libMultiLineOptimizedOptions;
-
- if(!libPath.empty())
- {
- std::string lpath =
- this->ConvertToOutputFormat(libPath.c_str(), SHELL);
- if(lpath.empty())
- {
- lpath = ".";
- }
- std::string lpathIntDir = libPath + "$(INTDIR)";
- lpathIntDir =
- this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
- if(pathEmitted.insert(lpath).second)
- {
- libOptions += " /LIBPATH:";
- libOptions += lpathIntDir;
- libOptions += " ";
- libOptions += " /LIBPATH:";
- libOptions += lpath;
- libOptions += " ";
- libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptions += lpathIntDir;
- libMultiLineOptions += " ";
- libMultiLineOptions += " /LIBPATH:";
- libMultiLineOptions += lpath;
- libMultiLineOptions += " \n";
- libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptionsForDebug += lpathIntDir;
- libMultiLineOptionsForDebug += " ";
- libMultiLineOptionsForDebug += " /LIBPATH:";
- libMultiLineOptionsForDebug += lpath;
- libMultiLineOptionsForDebug += " \n";
- }
- }
- if(!exePath.empty())
- {
- std::string lpath =
- this->ConvertToOutputFormat(exePath.c_str(), SHELL);
- if(lpath.empty())
- {
- lpath = ".";
- }
- std::string lpathIntDir = exePath + "$(INTDIR)";
- lpathIntDir =
- this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
-
- if(pathEmitted.insert(lpath).second)
- {
- libOptions += " /LIBPATH:";
- libOptions += lpathIntDir;
- libOptions += " ";
- libOptions += " /LIBPATH:";
- libOptions += lpath;
- libOptions += " ";
- libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptions += lpathIntDir;
- libMultiLineOptions += " ";
- libMultiLineOptions += " /LIBPATH:";
- libMultiLineOptions += lpath;
- libMultiLineOptions += " \n";
- libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptionsForDebug += lpathIntDir;
- libMultiLineOptionsForDebug += " ";
- libMultiLineOptionsForDebug += " /LIBPATH:";
- libMultiLineOptionsForDebug += lpath;
- libMultiLineOptionsForDebug += " \n";
- }
- }
- std::vector<std::string>::const_iterator i;
- const std::vector<std::string>& libdirs =
- target->GetLinkDirectories();
- for(i = libdirs.begin(); i != libdirs.end(); ++i)
- {
- std::string path = *i;
- if(path[path.size()-1] != '/')
- {
- path += "/";
- }
- std::string lpath =
- this->ConvertToOutputFormat(path.c_str(), SHELL);
- if(lpath.empty())
- {
- lpath = ".";
- }
- std::string lpathIntDir = path + "$(INTDIR)";
- lpathIntDir =
- this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
- if(pathEmitted.insert(lpath).second)
- {
- libOptions += " /LIBPATH:";
- libOptions += lpathIntDir;
- libOptions += " ";
- libOptions += " /LIBPATH:";
- libOptions += lpath;
- libOptions += " ";
-
- libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptions += lpathIntDir;
- libMultiLineOptions += " ";
- libMultiLineOptions += " /LIBPATH:";
- libMultiLineOptions += lpath;
- libMultiLineOptions += " \n";
- libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
- libMultiLineOptionsForDebug += lpathIntDir;
- libMultiLineOptionsForDebug += " ";
- libMultiLineOptionsForDebug += " /LIBPATH:";
- libMultiLineOptionsForDebug += lpath;
- libMultiLineOptionsForDebug += " \n";
- }
- }
- // find link libraries
- const cmTarget::LinkLibraryVectorType& libs =
- target->Target->GetLinkLibrariesForVS6();
- cmTarget::LinkLibraryVectorType::const_iterator j;
- for(j = libs.begin(); j != libs.end(); ++j)
- {
- // add libraries to executables and dlls (but never include
- // a library in a library, bad recursion)
- // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES
- if ((target->GetType() != cmState::SHARED_LIBRARY
- && target->GetType() != cmState::STATIC_LIBRARY
- && target->GetType() != cmState::MODULE_LIBRARY) ||
- (target->GetType()==cmState::SHARED_LIBRARY
- && libName != GetVS6TargetName(j->first)) ||
- (target->GetType()==cmState::MODULE_LIBRARY
- && libName != GetVS6TargetName(j->first)))
- {
- // Compute the proper name to use to link this library.
- std::string lib;
- std::string libDebug;
- cmGeneratorTarget* tgt =
- this->GlobalGenerator->FindGeneratorTarget(j->first.c_str());
- if(tgt)
- {
- lib = cmSystemTools::GetFilenameWithoutExtension
- (tgt->GetFullName().c_str());
- libDebug = cmSystemTools::GetFilenameWithoutExtension
- (tgt->GetFullName("Debug").c_str());
- lib += ".lib";
- libDebug += ".lib";
- }
- else
- {
- lib = j->first.c_str();
- libDebug = j->first.c_str();
- if(j->first.find(".lib") == std::string::npos)
- {
- lib += ".lib";
- libDebug += ".lib";
- }
- }
- lib = this->ConvertToOutputFormat(lib.c_str(), SHELL);
- libDebug =
- this->ConvertToOutputFormat(libDebug.c_str(), SHELL);
-
- if (j->second == GENERAL_LibraryType)
- {
- libOptions += " ";
- libOptions += lib;
- libMultiLineOptions += "# ADD LINK32 ";
- libMultiLineOptions += lib;
- libMultiLineOptions += "\n";
- libMultiLineOptionsForDebug += "# ADD LINK32 ";
- libMultiLineOptionsForDebug += libDebug;
- libMultiLineOptionsForDebug += "\n";
- }
- if (j->second == DEBUG_LibraryType)
- {
- libDebugOptions += " ";
- libDebugOptions += lib;
-
- libMultiLineDebugOptions += "# ADD LINK32 ";
- libMultiLineDebugOptions += libDebug;
- libMultiLineDebugOptions += "\n";
- }
- if (j->second == OPTIMIZED_LibraryType)
- {
- libOptimizedOptions += " ";
- libOptimizedOptions += lib;
-
- libMultiLineOptimizedOptions += "# ADD LINK32 ";
- libMultiLineOptimizedOptions += lib;
- libMultiLineOptimizedOptions += "\n";
- }
- }
- }
-#endif
-
- // Get include options for this target.
- std::string includeOptionsDebug = this->GetTargetIncludeOptions(target,
- "DEBUG");
- std::string includeOptionsRelease = this->GetTargetIncludeOptions(target,
- "RELEASE");
- std::string includeOptionsRelWithDebInfo = this->GetTargetIncludeOptions(
- target,
- "RELWITHDEBINFO");
- std::string includeOptionsMinSizeRel = this->GetTargetIncludeOptions(target,
- "MINSIZEREL");
-
- // Get extra linker options for this target type.
- std::string extraLinkOptions;
- std::string extraLinkOptionsDebug;
- std::string extraLinkOptionsRelease;
- std::string extraLinkOptionsMinSizeRel;
- std::string extraLinkOptionsRelWithDebInfo;
- if(target->GetType() == cmState::EXECUTABLE)
- {
- extraLinkOptions = this->Makefile->
- GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
- extraLinkOptionsDebug = this->Makefile->
- GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_DEBUG");
- extraLinkOptionsRelease = this->Makefile->
- GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELEASE");
- extraLinkOptionsMinSizeRel = this->Makefile->
- GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_MINSIZEREL");
- extraLinkOptionsRelWithDebInfo = this->Makefile->
- GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO");
- }
- if(target->GetType() == cmState::SHARED_LIBRARY)
- {
- extraLinkOptions = this->Makefile->
- GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
- extraLinkOptionsDebug = this->Makefile->
- GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_DEBUG");
- extraLinkOptionsRelease = this->Makefile->
- GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELEASE");
- extraLinkOptionsMinSizeRel = this->Makefile->
- GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL");
- extraLinkOptionsRelWithDebInfo = this->Makefile->
- GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO");
- }
- if(target->GetType() == cmState::MODULE_LIBRARY)
- {
- extraLinkOptions = this->Makefile->
- GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
- extraLinkOptionsDebug = this->Makefile->
- GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_DEBUG");
- extraLinkOptionsRelease = this->Makefile->
- GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELEASE");
- extraLinkOptionsMinSizeRel = this->Makefile->
- GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL");
- extraLinkOptionsRelWithDebInfo = this->Makefile->
- GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO");
- }
-
- // Get extra linker options for this target.
- if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"))
- {
- extraLinkOptions += " ";
- extraLinkOptions += targetLinkFlags;
- }
-
- if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_DEBUG"))
- {
- extraLinkOptionsDebug += " ";
- extraLinkOptionsDebug += targetLinkFlags;
- }
-
- if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_RELEASE"))
- {
- extraLinkOptionsRelease += " ";
- extraLinkOptionsRelease += targetLinkFlags;
- }
-
- if(const char* targetLinkFlags =
- target->GetProperty("LINK_FLAGS_MINSIZEREL"))
- {
- extraLinkOptionsMinSizeRel += " ";
- extraLinkOptionsMinSizeRel += targetLinkFlags;
- }
-
- if(const char* targetLinkFlags =
- target->GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
- {
- extraLinkOptionsRelWithDebInfo += " ";
- extraLinkOptionsRelWithDebInfo += targetLinkFlags;
- }
-
- // Get standard libraries for this language.
- if(targetBuilds)
- {
- // Get the language to use for linking.
- std::vector<std::string> configs;
- target->Target->GetMakefile()->GetConfigurations(configs);
- std::vector<std::string>::const_iterator it = configs.begin();
- const std::string& linkLanguage = target->GetLinkerLanguage(*it);
- for ( ; it != configs.end(); ++it)
- {
- const std::string& configLinkLanguage = target->GetLinkerLanguage(*it);
- if (configLinkLanguage != linkLanguage)
- {
- cmSystemTools::Error
- ("Linker language must not vary by configuration for target: ",
- target->GetName().c_str());
- }
- }
- if(linkLanguage.empty())
- {
- cmSystemTools::Error
- ("CMake can not determine linker language for target: ",
- target->GetName().c_str());
- return;
- }
-
- // Compute the variable name to lookup standard libraries for this
- // language.
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += linkLanguage;
- standardLibsVar += "_STANDARD_LIBRARIES";
-
- // Add standard libraries.
- if(const char* stdLibs =
- this->Makefile->GetDefinition(standardLibsVar.c_str()))
- {
- extraLinkOptions += " ";
- extraLinkOptions += stdLibs;
- }
- }
-
- // Compute version number information.
- std::string targetVersionFlag;
- if(target->GetType() == cmState::EXECUTABLE ||
- target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)
- {
- int major;
- int minor;
- target->GetTargetVersion(major, minor);
- std::ostringstream targetVersionStream;
- targetVersionStream << "/version:" << major << "." << minor;
- targetVersionFlag = targetVersionStream.str();
- }
-
- // Compute the real name of the target.
- std::string outputName =
- "(OUTPUT_NAME is for libraries and executables only)";
- std::string outputNameDebug = outputName;
- std::string outputNameRelease = outputName;
- std::string outputNameMinSizeRel = outputName;
- std::string outputNameRelWithDebInfo = outputName;
- if(target->GetType() == cmState::EXECUTABLE ||
- target->GetType() == cmState::STATIC_LIBRARY ||
- target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)
- {
- outputName = target->GetFullName();
- outputNameDebug = target->GetFullName("Debug");
- outputNameRelease = target->GetFullName("Release");
- outputNameMinSizeRel = target->GetFullName("MinSizeRel");
- outputNameRelWithDebInfo = target->GetFullName("RelWithDebInfo");
- }
- else if(target->GetType() == cmState::OBJECT_LIBRARY)
- {
- outputName = target->GetName();
- outputName += ".lib";
- outputNameDebug = outputName;
- outputNameRelease = outputName;
- outputNameMinSizeRel = outputName;
- outputNameRelWithDebInfo = outputName;
- }
-
- // Compute the output directory for the target.
- std::string outputDirOld;
- std::string outputDirDebug;
- std::string outputDirRelease;
- std::string outputDirMinSizeRel;
- std::string outputDirRelWithDebInfo;
- if(target->GetType() == cmState::EXECUTABLE ||
- target->GetType() == cmState::STATIC_LIBRARY ||
- target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)
- {
-#ifdef CM_USE_OLD_VS6
- outputDirOld =
- removeQuotes(this->ConvertToOutputFormat
- (target->GetDirectory().c_str(), SHELL));
-#endif
- outputDirDebug =
- removeQuotes(this->ConvertToOutputFormat(
- target->GetDirectory("Debug").c_str(), SHELL));
- outputDirRelease =
- removeQuotes(this->ConvertToOutputFormat(
- target->GetDirectory("Release").c_str(), SHELL));
- outputDirMinSizeRel =
- removeQuotes(this->ConvertToOutputFormat(
- target->GetDirectory("MinSizeRel").c_str(), SHELL));
- outputDirRelWithDebInfo =
- removeQuotes(this->ConvertToOutputFormat(
- target->GetDirectory("RelWithDebInfo").c_str(), SHELL));
- }
- else if(target->GetType() == cmState::OBJECT_LIBRARY)
- {
- std::string outputDir = cmake::GetCMakeFilesDirectoryPostSlash();
- outputDirDebug = outputDir + "Debug";
- outputDirRelease = outputDir + "Release";
- outputDirMinSizeRel = outputDir + "MinSizeRel";
- outputDirRelWithDebInfo = outputDir + "RelWithDebInfo";
- }
-
- // Compute the proper link information for the target.
- std::string optionsDebug;
- std::string optionsRelease;
- std::string optionsMinSizeRel;
- std::string optionsRelWithDebInfo;
- if(target->GetType() == cmState::EXECUTABLE ||
- target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)
- {
- extraLinkOptionsDebug =
- extraLinkOptions + " " + extraLinkOptionsDebug;
- extraLinkOptionsRelease =
- extraLinkOptions + " " + extraLinkOptionsRelease;
- extraLinkOptionsMinSizeRel =
- extraLinkOptions + " " + extraLinkOptionsMinSizeRel;
- extraLinkOptionsRelWithDebInfo =
- extraLinkOptions + " " + extraLinkOptionsRelWithDebInfo;
- this->ComputeLinkOptions(target, "Debug", extraLinkOptionsDebug,
- optionsDebug);
- this->ComputeLinkOptions(target, "Release", extraLinkOptionsRelease,
- optionsRelease);
- this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel,
- optionsMinSizeRel);
- this->ComputeLinkOptions(target, "RelWithDebInfo",
- extraLinkOptionsRelWithDebInfo,
- optionsRelWithDebInfo);
- }
-
- // Compute the path of the import library.
- std::string targetImplibFlagDebug;
- std::string targetImplibFlagRelease;
- std::string targetImplibFlagMinSizeRel;
- std::string targetImplibFlagRelWithDebInfo;
- if(target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY ||
- target->GetType() == cmState::EXECUTABLE)
- {
- std::string fullPathImpDebug = target->GetDirectory("Debug", true);
- std::string fullPathImpRelease = target->GetDirectory("Release", true);
- std::string fullPathImpMinSizeRel =
- target->GetDirectory("MinSizeRel", true);
- std::string fullPathImpRelWithDebInfo =
- target->GetDirectory("RelWithDebInfo", true);
- fullPathImpDebug += "/";
- fullPathImpRelease += "/";
- fullPathImpMinSizeRel += "/";
- fullPathImpRelWithDebInfo += "/";
- fullPathImpDebug += target->GetFullName("Debug", true);
- fullPathImpRelease += target->GetFullName("Release", true);
- fullPathImpMinSizeRel += target->GetFullName("MinSizeRel", true);
- fullPathImpRelWithDebInfo += target->GetFullName("RelWithDebInfo", true);
-
- targetImplibFlagDebug = "/implib:";
- targetImplibFlagRelease = "/implib:";
- targetImplibFlagMinSizeRel = "/implib:";
- targetImplibFlagRelWithDebInfo = "/implib:";
- targetImplibFlagDebug +=
- this->ConvertToOutputFormat(fullPathImpDebug.c_str(), SHELL);
- targetImplibFlagRelease +=
- this->ConvertToOutputFormat(fullPathImpRelease.c_str(), SHELL);
- targetImplibFlagMinSizeRel +=
- this->ConvertToOutputFormat(fullPathImpMinSizeRel.c_str(), SHELL);
- targetImplibFlagRelWithDebInfo +=
- this->ConvertToOutputFormat(fullPathImpRelWithDebInfo.c_str(), SHELL);
- }
-
-#ifdef CM_USE_OLD_VS6
- // Compute link information for the target.
- if(!extraLinkOptions.empty())
- {
- libOptions += " ";
- libOptions += extraLinkOptions;
- libOptions += " ";
- libMultiLineOptions += "# ADD LINK32 ";
- libMultiLineOptions += extraLinkOptions;
- libMultiLineOptions += " \n";
- libMultiLineOptionsForDebug += "# ADD LINK32 ";
- libMultiLineOptionsForDebug += extraLinkOptions;
- libMultiLineOptionsForDebug += " \n";
- }
-#endif
-
- // are there any custom rules on the target itself
- // only if the target is a lib or exe
- std::string customRuleCodeRelease
- = this->CreateTargetRules(target, "RELEASE", libName);
- std::string customRuleCodeDebug
- = this->CreateTargetRules(target, "DEBUG", libName);
- std::string customRuleCodeMinSizeRel
- = this->CreateTargetRules(target, "MINSIZEREL", libName);
- std::string customRuleCodeRelWithDebInfo
- = this->CreateTargetRules(target, "RELWITHDEBINFO", libName);
-
- cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
- if(!fin)
- {
- cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
- }
- std::string staticLibOptions;
- std::string staticLibOptionsDebug;
- std::string staticLibOptionsRelease;
- std::string staticLibOptionsMinSizeRel;
- std::string staticLibOptionsRelWithDebInfo;
- if(target->GetType() == cmState::STATIC_LIBRARY )
- {
- const char *libflagsGlobal =
- this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS");
- this->AppendFlags(staticLibOptions, libflagsGlobal);
- this->AppendFlags(staticLibOptionsDebug, libflagsGlobal);
- this->AppendFlags(staticLibOptionsRelease, libflagsGlobal);
- this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal);
- this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal);
-
- this->AppendFlags(staticLibOptionsDebug, this->Makefile->
- GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG"));
- this->AppendFlags(staticLibOptionsRelease, this->Makefile->
- GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE"));
- this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile->
- GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL"));
- this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile->
- GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO"));
-
- const char *libflags = target->GetProperty("STATIC_LIBRARY_FLAGS");
- this->AppendFlags(staticLibOptions, libflags);
- this->AppendFlags(staticLibOptionsDebug, libflags);
- this->AppendFlags(staticLibOptionsRelease, libflags);
- this->AppendFlags(staticLibOptionsMinSizeRel, libflags);
- this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags);
-
- this->AppendFlags(staticLibOptionsDebug,
- target->GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"));
- this->AppendFlags(staticLibOptionsRelease,
- target->GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"));
- this->AppendFlags(staticLibOptionsMinSizeRel,
- target->GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"));
- this->AppendFlags(staticLibOptionsRelWithDebInfo,
- target->GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"));
-
- std::string objects;
- this->OutputObjects(target, "LIB", objects);
- if(!objects.empty())
- {
- objects = "\n" + objects;
- staticLibOptionsDebug += objects;
- staticLibOptionsRelease += objects;
- staticLibOptionsMinSizeRel += objects;
- staticLibOptionsRelWithDebInfo += objects;
- }
- }
-
- // Add the export symbol definition for shared library objects.
- std::string exportSymbol;
- if(const char* exportMacro = target->GetExportMacro())
- {
- exportSymbol = exportMacro;
- }
-
- std::string line;
- std::string libnameExports;
- if(!exportSymbol.empty())
- {
- libnameExports = "/D \"";
- libnameExports += exportSymbol;
- libnameExports += "\"";
- }
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
- if(!mfcFlag)
- {
- mfcFlag = "0";
- }
- cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS",
- libnameExports.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG",
- mfcFlag);
- if(target->GetType() == cmState::STATIC_LIBRARY ||
- target->GetType() == cmState::OBJECT_LIBRARY)
- {
- cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG",
- staticLibOptionsDebug.c_str());
- cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE",
- staticLibOptionsRelease.c_str());
- cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL",
- staticLibOptionsMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO",
- staticLibOptionsRelWithDebInfo.c_str());
- cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
- staticLibOptions.c_str());
- }
- if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
- {
- cmSystemTools::ReplaceString(line, "/nologo", "");
- }
-
-#ifdef CM_USE_OLD_VS6
- cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
- libOptions.c_str());
- cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
- libDebugOptions.c_str());
- cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
- libOptimizedOptions.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
- libMultiLineOptionsForDebug.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
- libMultiLineOptions.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
- libMultiLineDebugOptions.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES",
- libMultiLineOptimizedOptions.c_str());
-#endif
-
- // Substitute the rules for custom command. When specifying just the
- // target name for the command the command can be different for
- // different configs
- cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE",
- customRuleCodeRelease.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG",
- customRuleCodeDebug.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL",
- customRuleCodeMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO",
- customRuleCodeRelWithDebInfo.c_str());
-
- // Substitute the real output name into the template.
- cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG",
- outputNameDebug.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE",
- outputNameRelease.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL",
- outputNameMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO",
- outputNameRelWithDebInfo.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str());
-
- // Substitute the proper link information into the template.
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG",
- optionsDebug.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE",
- optionsRelease.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL",
- optionsMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO",
- optionsRelWithDebInfo.c_str());
-
- cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_DEBUG",
- includeOptionsDebug.c_str());
- cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELEASE",
- includeOptionsRelease.c_str());
- cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_MINSIZEREL",
- includeOptionsMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELWITHDEBINFO",
- includeOptionsRelWithDebInfo.c_str());
-
- cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
- targetVersionFlag.c_str());
- cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG",
- targetImplibFlagDebug.c_str());
- cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELEASE",
- targetImplibFlagRelease.c_str());
- cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_MINSIZEREL",
- targetImplibFlagMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO",
- targetImplibFlagRelWithDebInfo.c_str());
-
- std::string vs6name = GetVS6TargetName(libName);
- cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
-
-#ifdef CM_USE_OLD_VS6
- // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
- // are already quoted in the template file,
- // we need to remove the quotes here, we still need
- // to convert to output path for unix to win32 conversion
- cmSystemTools::ReplaceString
- (line, "LIBRARY_OUTPUT_PATH",
- removeQuotes(this->ConvertToOutputFormat
- (libPath.c_str(), SHELL)).c_str());
- cmSystemTools::ReplaceString
- (line, "EXECUTABLE_OUTPUT_PATH",
- removeQuotes(this->ConvertToOutputFormat
- (exePath.c_str(), SHELL)).c_str());
-#endif
-
- if(targetBuilds || target->GetType() == cmState::OBJECT_LIBRARY)
- {
- cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG",
- outputDirDebug.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELEASE",
- outputDirRelease.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_MINSIZEREL",
- outputDirMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELWITHDEBINFO",
- outputDirRelWithDebInfo.c_str());
- if(!outputDirOld.empty())
- {
- cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY",
- outputDirOld.c_str());
- }
- }
-
- cmSystemTools::ReplaceString(line,
- "EXTRA_DEFINES",
- this->Makefile->GetDefineFlags());
- const char* debugPostfix
- = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
- cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
- debugPostfix?debugPostfix:"");
- if(target->GetType() >= cmState::EXECUTABLE &&
- target->GetType() <= cmState::OBJECT_LIBRARY)
- {
- // store flags for each configuration
- std::string flags = " ";
- std::string flagsRelease = " ";
- std::string flagsMinSizeRel = " ";
- std::string flagsDebug = " ";
- std::string flagsRelWithDebInfo = " ";
- std::vector<std::string> configs;
- target->Target->GetMakefile()->GetConfigurations(configs);
- std::vector<std::string>::const_iterator it = configs.begin();
- const std::string& linkLanguage = target->GetLinkerLanguage(*it);
- for ( ; it != configs.end(); ++it)
- {
- const std::string& configLinkLanguage = target->GetLinkerLanguage(*it);
- if (configLinkLanguage != linkLanguage)
- {
- cmSystemTools::Error
- ("Linker language must not vary by configuration for target: ",
- target->GetName().c_str());
- }
- }
- if(linkLanguage.empty())
- {
- cmSystemTools::Error
- ("CMake can not determine linker language for target: ",
- target->GetName().c_str());
- return;
- }
- // if CXX is on and the target contains cxx code then add the cxx flags
- std::string baseFlagVar = "CMAKE_";
- baseFlagVar += linkLanguage;
- baseFlagVar += "_FLAGS";
- flags = this->Makefile->GetSafeDefinition(baseFlagVar.c_str());
-
- std::string flagVar = baseFlagVar + "_RELEASE";
- flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
-
- flagVar = baseFlagVar + "_MINSIZEREL";
- flagsMinSizeRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsMinSizeRel += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
-
- flagVar = baseFlagVar + "_DEBUG";
- flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
-
- flagVar = baseFlagVar + "_RELWITHDEBINFO";
- flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
-
- this->AddCompileOptions(flags, target, linkLanguage, "");
- this->AddCompileOptions(flagsDebug, target, linkLanguage, "Debug");
- this->AddCompileOptions(flagsRelease, target, linkLanguage, "Release");
- this->AddCompileOptions(flagsMinSizeRel, target, linkLanguage,
- "MinSizeRel");
- this->AddCompileOptions(flagsRelWithDebInfo, target, linkLanguage,
- "RelWithDebInfo");
-
- // if _UNICODE and _SBCS are not found, then add -D_MBCS
- std::string defs = this->Makefile->GetDefineFlags();
- if(flags.find("D_UNICODE") == flags.npos &&
- defs.find("D_UNICODE") == flags.npos &&
- flags.find("D_SBCS") == flags.npos &&
- defs.find("D_SBCS") == flags.npos)
- {
- flags += " /D \"_MBCS\"";
- }
-
- // Add per-target and per-configuration preprocessor definitions.
- std::set<std::string> definesSet;
- std::set<std::string> debugDefinesSet;
- std::set<std::string> releaseDefinesSet;
- std::set<std::string> minsizeDefinesSet;
- std::set<std::string> debugrelDefinesSet;
-
- this->AddCompileDefinitions(definesSet, target, "", linkLanguage);
- this->AddCompileDefinitions(debugDefinesSet, target,
- "DEBUG", linkLanguage);
- this->AddCompileDefinitions(releaseDefinesSet, target,
- "RELEASE", linkLanguage);
- this->AddCompileDefinitions(minsizeDefinesSet, target,
- "MINSIZEREL", linkLanguage);
- this->AddCompileDefinitions(debugrelDefinesSet, target,
- "RELWITHDEBINFO", linkLanguage);
-
- std::string defines = " ";
- std::string debugDefines = " ";
- std::string releaseDefines = " ";
- std::string minsizeDefines = " ";
- std::string debugrelDefines = " ";
-
- this->JoinDefines(definesSet, defines, "");
- this->JoinDefines(debugDefinesSet, debugDefines, "");
- this->JoinDefines(releaseDefinesSet, releaseDefines, "");
- this->JoinDefines(minsizeDefinesSet, minsizeDefines, "");
- this->JoinDefines(debugrelDefinesSet, debugrelDefines, "");
-
- flags += defines;
- flagsDebug += debugDefines;
- flagsRelease += releaseDefines;
- flagsMinSizeRel += minsizeDefines;
- flagsRelWithDebInfo += debugrelDefines;
-
- // The template files have CXX FLAGS in them, that need to be replaced.
- // There are not separate CXX and C template files, so we use the same
- // variable names. The previous code sets up flags* variables to
- // contain the correct C or CXX flags
- cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL",
- flagsMinSizeRel.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG",
- flagsDebug.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
- flagsRelWithDebInfo.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE",
- flagsRelease.c_str());
- cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
-
- cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_MINSIZEREL",
- minsizeDefines.c_str());
- cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_DEBUG",
- debugDefines.c_str());
- cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELWITHDEBINFO",
- debugrelDefines.c_str());
- cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELEASE",
- releaseDefines.c_str());
- cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS",
- defines.c_str());
- }
-
- fout << line.c_str() << std::endl;
- }
-}
-
-void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
-{
- cmsys::ifstream fin(this->DSPFooterTemplate.c_str());
- if(!fin)
- {
- cmSystemTools::Error("Error Reading ",
- this->DSPFooterTemplate.c_str());
- }
- std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- fout << line << std::endl;
- }
-}
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio6Generator
-::ComputeLinkOptions(cmGeneratorTarget *target,
- const std::string& configName,
- const std::string extraOptions,
- std::string& options)
-{
- // Compute the link information for this configuration.
- cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
- if(!pcli)
- {
- return;
- }
- cmComputeLinkInformation& cli = *pcli;
- typedef cmComputeLinkInformation::ItemVector ItemVector;
- ItemVector const& linkLibs = cli.GetItems();
- std::vector<std::string> const& linkDirs = cli.GetDirectories();
-
- this->OutputObjects(target, "LINK", options);
-
- // Build the link options code.
- for(std::vector<std::string>::const_iterator d = linkDirs.begin();
- d != linkDirs.end(); ++d)
- {
- std::string dir = *d;
- if(!dir.empty())
- {
- if(dir[dir.size()-1] != '/')
- {
- dir += "/";
- }
- dir += "$(IntDir)";
- options += "# ADD LINK32 /LIBPATH:";
- options += this->ConvertToOutputFormat(dir.c_str(), SHELL);
- options += " /LIBPATH:";
- options += this->ConvertToOutputFormat(d->c_str(), SHELL);
- options += "\n";
- }
- }
- for(ItemVector::const_iterator l = linkLibs.begin();
- l != linkLibs.end(); ++l)
- {
- options += "# ADD LINK32 ";
- if(l->IsPath)
- {
- options +=
- this->ConvertToOutputFormat(l->Value.c_str(), SHELL);
- }
- else if (!l->Target
- || l->Target->GetType() != cmState::INTERFACE_LIBRARY)
- {
- options += l->Value;
- }
- options += "\n";
- }
-
- // Add extra options if any.
- if(!extraOptions.empty())
- {
- options += "# ADD LINK32 ";
- options += extraOptions;
- options += "\n";
- }
-}
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio6Generator
-::OutputObjects(cmGeneratorTarget* target, const char* tool,
- std::string& options)
-{
- // VS 6 does not support per-config source locations so we
- // list object library content on the link line instead.
- std::vector<std::string> objs;
- target->UseObjectLibraries(objs, "");
- for(std::vector<std::string>::const_iterator
- oi = objs.begin(); oi != objs.end(); ++oi)
- {
- options += "# ADD ";
- options += tool;
- options += "32 ";
- options += this->ConvertToOutputFormat(oi->c_str(), SHELL);
- options += "\n";
- }
-}
-
-std::string
-cmLocalVisualStudio6Generator
-::GetTargetDirectory(cmGeneratorTarget const*) const
-{
- // No per-target directory for this generator (yet).
- return "";
-}
-
-//----------------------------------------------------------------------------
-std::string
-cmLocalVisualStudio6Generator
-::ComputeLongestObjectDirectory(cmGeneratorTarget const*) const
-{
- // Compute the maximum length configuration name.
- std::string config_max;
- for(std::vector<std::string>::const_iterator
- i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
- {
- // Strip the subdirectory name out of the configuration name.
- std::string config = this->GetConfigName(*i);
- if(config.size() > config_max.size())
- {
- config_max = config;
- }
- }
-
- // Compute the maximum length full path to the intermediate
- // files directory for any configuration. This is used to construct
- // object file names that do not produce paths that are too long.
- std::string dir_max;
- dir_max += this->GetCurrentBinaryDirectory();
- dir_max += "/";
- dir_max += config_max;
- dir_max += "/";
- return dir_max;
-}
-
-std::string
-cmLocalVisualStudio6Generator
-::GetConfigName(std::string const& configuration) const
-{
- // Strip the subdirectory name out of the configuration name.
- std::string config = configuration;
- std::string::size_type pos = config.find_last_of(" ");
- config = config.substr(pos+1, std::string::npos);
- config = config.substr(0, config.size()-1);
- return config;
-}
-
-//----------------------------------------------------------------------------
-bool
-cmLocalVisualStudio6Generator
-::CheckDefinition(std::string const& define) const
-{
- // Perform the standard check first.
- if(!this->cmLocalGenerator::CheckDefinition(define))
- {
- return false;
- }
-
- // Now do the VS6-specific check.
- if(define.find_first_of(" ") != define.npos &&
- define.find_first_of("\"$;") != define.npos)
- {
- std::ostringstream e;
- e << "WARNING: The VS6 IDE does not support preprocessor definition "
- << "values with spaces and '\"', '$', or ';'.\n"
- << "CMake is dropping a preprocessor definition: " << define << "\n"
- << "Consider defining the macro in a (configured) header file.\n";
- cmSystemTools::Message(e.str().c_str());
- return false;
- }
-
- // Assume it is supported.
- return true;
-}
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
deleted file mode 100644
index dab32a5..0000000
--- a/Source/cmLocalVisualStudio6Generator.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- 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 cmLocalVisualStudio6Generator_h
-#define cmLocalVisualStudio6Generator_h
-
-#include "cmLocalVisualStudioGenerator.h"
-
-class cmSourceFile;
-class cmSourceGroup;
-class cmCustomCommand;
-
-/** \class cmLocalVisualStudio6Generator
- * \brief Write a LocalUnix makefiles.
- *
- * cmLocalVisualStudio6Generator produces a LocalUnix makefile from its
- * member this->Makefile.
- */
-class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
-{
-public:
- ///! Set cache only and recurse to false by default.
- cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf);
-
- virtual ~cmLocalVisualStudio6Generator();
-
- virtual void AddCMakeListsRules();
-
- /**
- * Generate the makefile for this directory.
- */
- virtual void Generate();
-
- void OutputDSPFile();
-
- enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
-
- /**
- * Specify the type of the build: static, dll, or executable.
- */
- void SetBuildType(BuildType, const std::string& libName, cmGeneratorTarget*);
-
- virtual
- std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
- virtual std::string
- ComputeLongestObjectDirectory(cmGeneratorTarget const*) const;
-private:
- std::string DSPHeaderTemplate;
- std::string DSPFooterTemplate;
-
- void CreateSingleDSP(const std::string& lname, cmGeneratorTarget* tgt);
- void WriteDSPFile(std::ostream& fout, const std::string& libName,
- cmGeneratorTarget* tgt);
- void WriteDSPBeginGroup(std::ostream& fout,
- const char* group,
- const char* filter);
- void WriteDSPEndGroup(std::ostream& fout);
-
- void WriteDSPHeader(std::ostream& fout, const std::string& libName,
- cmGeneratorTarget* tgt, std::vector<cmSourceGroup> &sgs);
-
- void WriteDSPFooter(std::ostream& fout);
- void AddDSPBuildRule(cmGeneratorTarget* tgt);
- void WriteCustomRule(std::ostream& fout,
- const char* source,
- const cmCustomCommand& command,
- const char* flags);
- void AddUtilityCommandHack(cmGeneratorTarget* target, int count,
- std::vector<std::string>& depends,
- const cmCustomCommand& origCommand);
- void WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target,
- std::ostream &fout, const std::string& libName);
- class EventWriter;
- friend class EventWriter;
- cmsys::auto_ptr<cmCustomCommand>
- MaybeCreateOutputDir(cmGeneratorTarget *target, const std::string& config);
- std::string CreateTargetRules(cmGeneratorTarget* target,
- const std::string& configName,
- const std::string& libName);
- void ComputeLinkOptions(cmGeneratorTarget* target,
- const std::string& configName,
- const std::string extraOptions,
- std::string& options);
- void OutputObjects(cmGeneratorTarget* target, const char* tool,
- std::string& options);
- std::string GetTargetIncludeOptions(cmGeneratorTarget* target,
- const std::string& config);
- std::vector<std::string> Configurations;
-
- std::string GetConfigName(std::string const& configuration) const;
-
- // Special definition check for VS6.
- virtual bool CheckDefinition(std::string const& define) const;
-};
-
-#endif
-
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ae6a24e..abae564 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -25,7 +25,7 @@
#include <ctype.h> // for isspace
-static bool cmLVS6G_IsFAT(const char* dir);
+static bool cmLVS7G_IsFAT(const char* dir);
class cmLocalVisualStudio7GeneratorInternals
{
@@ -999,7 +999,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// Check if we need the FAT32 workaround.
// Check the filesystem type where the target will be written.
- if (cmLVS6G_IsFAT(target->GetDirectory(configName).c_str()))
+ if (cmLVS7G_IsFAT(target->GetDirectory(configName).c_str()))
{
// Add a flag telling the manifest tool to use a workaround
// for FAT32 file systems, which can cause an empty manifest
@@ -1012,6 +1012,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
this->OutputTargetRules(fout, configName, target, libName);
this->OutputBuildTool(fout, configName, target, targetOptions);
+ this->OutputDeploymentDebuggerTool(fout, configName, target);
fout << "\t\t</Configuration>\n";
}
@@ -1374,6 +1375,32 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
}
+void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
+ std::ostream& fout, std::string const& config, cmGeneratorTarget* target)
+{
+ if (this->WindowsCEProject)
+ {
+ if (const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY"))
+ {
+ fout <<
+ "\t\t\t<DeploymentTool\n"
+ "\t\t\t\tForceDirty=\"-1\"\n"
+ "\t\t\t\tRemoteDirectory=\"" << this->EscapeForXML(dir) << "\"\n"
+ "\t\t\t\tRegisterOutput=\"0\"\n"
+ "\t\t\t\tAdditionalFiles=\"\"/>\n"
+ ;
+ std::string const exe =
+ dir + std::string("\\") + target->GetFullName(config);
+ fout <<
+ "\t\t\t<DebuggerTool\n"
+ "\t\t\t\tRemoteExecutable=\"" << this->EscapeForXML(exe) << "\"\n"
+ "\t\t\t\tArguments=\"\"\n"
+ "\t\t\t/>\n"
+ ;
+ }
+ }
+}
+
//----------------------------------------------------------------------------
void
cmLocalVisualStudio7Generator
@@ -2365,7 +2392,7 @@ std::string cmLocalVisualStudio7Generator
//----------------------------------------------------------------------------
#include <windows.h>
-static bool cmLVS6G_IsFAT(const char* dir)
+static bool cmLVS7G_IsFAT(const char* dir)
{
if(dir[0] && dir[1] == ':')
{
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 7bb9cc6..562f485 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -92,6 +92,9 @@ private:
const std::string& libName);
void OutputBuildTool(std::ostream& fout, const std::string& configName,
cmGeneratorTarget* t, const Options& targetOptions);
+ void OutputDeploymentDebuggerTool(std::ostream& fout,
+ std::string const& config,
+ cmGeneratorTarget* target);
void OutputLibraryDirectories(std::ostream& fout,
std::vector<std::string> const& dirs);
void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget *target);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 600c985..aa6f7c8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -733,26 +733,6 @@ void cmMakefile::ConfigureFinalPass()
"with CMake 2.4 or later. For compatibility with older versions please "
"use any CMake 2.8.x release or lower.");
}
-#if defined(_WIN32) && !defined(__CYGWIN__)
- // Do old-style link dependency analysis only for CM_USE_OLD_VS6.
- if(this->GetGlobalGenerator()->IsForVS6())
- {
- for (cmTargets::iterator l = this->Targets.begin();
- l != this->Targets.end(); l++)
- {
- if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
- {
- continue;
- }
- // Erase any cached link information that might have been comptued
- // on-demand during the configuration. This ensures that build
- // system generation uses up-to-date information even if other cache
- // invalidation code in this source file is buggy.
-
- l->second.AnalyzeLibDependenciesForVS6(*this);
- }
- }
-#endif
}
//----------------------------------------------------------------------------
@@ -1334,14 +1314,6 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
return false;
}
- // VS6 IDE does not support definition values with spaces in
- // combination with '"', '$', or ';'.
- if((this->GetGlobalGenerator()->GetName() == "Visual Studio 6") &&
- (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos))
- {
- return false;
- }
-
// Definitions with non-trivial values require a policy check.
static cmsys::RegularExpression
trivial("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
@@ -3773,17 +3745,13 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
}
// Always search in the standard modules location.
- const char* cmakeRoot = this->GetDefinition("CMAKE_ROOT");
- if(cmakeRoot)
- {
- moduleInCMakeRoot = cmakeRoot;
- moduleInCMakeRoot += "/Modules/";
- moduleInCMakeRoot += filename;
- cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
- if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str()))
- {
- moduleInCMakeRoot = "";
- }
+ moduleInCMakeRoot = cmSystemTools::GetCMakeRoot();
+ moduleInCMakeRoot += "/Modules/";
+ moduleInCMakeRoot += filename;
+ cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
+ if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str()))
+ {
+ moduleInCMakeRoot = "";
}
// Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
@@ -3798,7 +3766,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty())
{
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
- std::string mods = cmakeRoot + std::string("/Modules/");
+ std::string mods = cmSystemTools::GetCMakeRoot() + "/Modules/";
if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
{
switch (this->GetPolicyStatus(cmPolicies::CMP0017))
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 1923ea4..435844e 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -841,37 +841,3 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->CleanFiles.insert(this->CleanFiles.end(),
libCleanFiles.begin(),libCleanFiles.end());
}
-
-//----------------------------------------------------------------------------
-void
-cmMakefileLibraryTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const std::string& lang,
- const char* name, bool so)
-{
- // Lookup the flag to specify the version.
- std::string fvar = "CMAKE_";
- fvar += lang;
- fvar += "_OSX_";
- fvar += name;
- fvar += "_VERSION_FLAG";
- const char* flag = this->Makefile->GetDefinition(fvar);
-
- // Skip if no such flag.
- if(!flag)
- {
- return;
- }
-
- // Lookup the target version information.
- int major;
- int minor;
- int patch;
- this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
- if(major > 0 || minor > 0 || patch > 0)
- {
- // Append the flag since a non-zero version is specified.
- std::ostringstream vflag;
- vflag << flag << major << "." << minor << "." << patch;
- this->LocalGenerator->AppendFlags(flags, vflag.str());
- }
-}
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 68980c3..009f15d 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -38,9 +38,6 @@ protected:
// Store the computd framework version for OS X Frameworks.
std::string FrameworkVersion;
-
- void AppendOSXVerFlag(std::string& flags, const std::string& lang,
- const char* name, bool so);
};
#endif
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 17561b5..c34df3c 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -504,6 +504,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
}
+ // Add OS X version flags, if any.
+ if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+ this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
+ {
+ this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage,
+ "COMPATIBILITY", true);
+ this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage,
+ "CURRENT", false);
+ }
+
this->addPoolNinjaVariable("JOB_POOL_LINK", &gt, vars);
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 08caea3..4cab81f 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -1003,8 +1003,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
SetupAutoRccTarget(target);
}
- const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
- std::string inputFile = cmakeRoot;
+ std::string inputFile = cmSystemTools::GetCMakeRoot();
inputFile += "/Modules/AutogenInfo.cmake.in";
std::string outputFile = targetDir;
outputFile += "/AutogenInfo.cmake";
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 3ba7287..9af54bf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -60,8 +60,7 @@
#endif
#if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <fcntl.h>
-# include "cmCryptoHash.h"
+# include "cmCryptoHash.h"
#endif
#if defined(CMAKE_USE_ELF_PARSER)
@@ -2184,8 +2183,10 @@ unsigned int cmSystemTools::RandomSeed()
} seed;
// Try using a real random source.
- cmsys::ifstream fin("/dev/urandom");
- if(fin && fin.read(seed.bytes, sizeof(seed)) &&
+ cmsys::ifstream fin;
+ fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read.
+ fin.open("/dev/urandom");
+ if(fin.good() && fin.read(seed.bytes, sizeof(seed)) &&
fin.gcount() == sizeof(seed))
{
return seed.integer;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1986e5f..576189f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -55,9 +55,6 @@ public:
cmTarget::cmTarget()
{
this->Makefile = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- this->LinkLibrariesForVS6Analyzed = false;
-#endif
this->HaveInstallRule = false;
this->DLLPlatform = false;
this->IsAndroid = false;
@@ -699,9 +696,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
cmTarget::LibraryID tmp;
tmp.first = lib;
tmp.second = llt;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- this->LinkLibrariesForVS6.push_back( tmp );
-#endif
this->OriginalLinkLibraries.push_back(tmp);
// Add the explicit dependency information for this target. This is
@@ -811,298 +805,6 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const
return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces);
}
-#if defined(_WIN32) && !defined(__CYGWIN__)
-//----------------------------------------------------------------------------
-void
-cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf )
-{
- // There are two key parts of the dependency analysis: (1)
- // determining the libraries in the link line, and (2) constructing
- // the dependency graph for those libraries.
- //
- // The latter is done using the cache entries that record the
- // dependencies of each library.
- //
- // The former is a more thorny issue, since it is not clear how to
- // determine if two libraries listed on the link line refer to the a
- // single library or not. For example, consider the link "libraries"
- // /usr/lib/libtiff.so -ltiff
- // Is this one library or two? The solution implemented here is the
- // simplest (and probably the only practical) one: two libraries are
- // the same if their "link strings" are identical. Thus, the two
- // libraries above are considered distinct. This also means that for
- // dependency analysis to be effective, the CMake user must specify
- // libraries build by his project without using any linker flags or
- // file extensions. That is,
- // LINK_LIBRARIES( One Two )
- // instead of
- // LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a )
- // The former is probably what most users would do, but it never
- // hurts to document the assumptions. :-) Therefore, in the analysis
- // code, the "canonical name" of a library is simply its name as
- // given to a LINK_LIBRARIES command.
- //
- // Also, we will leave the original link line intact; we will just add any
- // dependencies that were missing.
- //
- // There is a problem with recursive external libraries
- // (i.e. libraries with no dependency information that are
- // recursively dependent). We must make sure that the we emit one of
- // the libraries twice to satisfy the recursion, but we shouldn't
- // emit it more times than necessary. In particular, we must make
- // sure that handling this improbable case doesn't cost us when
- // dealing with the common case of non-recursive libraries. The
- // solution is to assume that the recursion is satisfied at one node
- // of the dependency tree. To illustrate, assume libA and libB are
- // extrenal and mutually dependent. Suppose libX depends on
- // libA, and libY on libA and libX. Then
- // TARGET_LINK_LIBRARIES( Y X A B A )
- // TARGET_LINK_LIBRARIES( X A B A )
- // TARGET_LINK_LIBRARIES( Exec Y )
- // would result in "-lY -lX -lA -lB -lA". This is the correct way to
- // specify the dependencies, since the mutual dependency of A and B
- // is resolved *every time libA is specified*.
- //
- // Something like
- // TARGET_LINK_LIBRARIES( Y X A B A )
- // TARGET_LINK_LIBRARIES( X A B )
- // TARGET_LINK_LIBRARIES( Exec Y )
- // would result in "-lY -lX -lA -lB", and the mutual dependency
- // information is lost. This is because in some case (Y), the mutual
- // dependency of A and B is listed, while in another other case (X),
- // it is not. Depending on which line actually emits A, the mutual
- // dependency may or may not be on the final link line. We can't
- // handle this pathalogical case cleanly without emitting extra
- // libraries for the normal cases. Besides, the dependency
- // information for X is wrong anyway: if we build an executable
- // depending on X alone, we would not have the mutual dependency on
- // A and B resolved.
- //
- // IMPROVEMENTS:
- // -- The current algorithm will not always pick the "optimal" link line
- // when recursive dependencies are present. It will instead break the
- // cycles at an aribtrary point. The majority of projects won't have
- // cyclic dependencies, so this is probably not a big deal. Note that
- // the link line is always correct, just not necessary optimal.
-
- {
- // Expand variables in link library names. This is for backwards
- // compatibility with very early CMake versions and should
- // eventually be removed. This code was moved here from the end of
- // old source list processing code which was called just before this
- // method.
- for(LinkLibraryVectorType::iterator p = this->LinkLibrariesForVS6.begin();
- p != this->LinkLibrariesForVS6.end(); ++p)
- {
- this->Makefile->ExpandVariablesInString(p->first, true, true);
- }
- }
-
- // The dependency map.
- DependencyMap dep_map;
-
- // 1. Build the dependency graph
- //
- for(LinkLibraryVectorType::reverse_iterator lib
- = this->LinkLibrariesForVS6.rbegin();
- lib != this->LinkLibrariesForVS6.rend(); ++lib)
- {
- this->GatherDependenciesForVS6( mf, *lib, dep_map);
- }
-
- // 2. Remove any dependencies that are already satisfied in the original
- // link line.
- //
- for(LinkLibraryVectorType::iterator lib = this->LinkLibrariesForVS6.begin();
- lib != this->LinkLibrariesForVS6.end(); ++lib)
- {
- for( LinkLibraryVectorType::iterator lib2 = lib;
- lib2 != this->LinkLibrariesForVS6.end(); ++lib2)
- {
- this->DeleteDependencyForVS6( dep_map, *lib, *lib2);
- }
- }
-
-
- // 3. Create the new link line by simply emitting any dependencies that are
- // missing. Start from the back and keep adding.
- //
- std::set<DependencyMap::key_type> done, visited;
- std::vector<DependencyMap::key_type> newLinkLibrariesForVS6;
- for(LinkLibraryVectorType::reverse_iterator lib =
- this->LinkLibrariesForVS6.rbegin();
- lib != this->LinkLibrariesForVS6.rend(); ++lib)
- {
- // skip zero size library entries, this may happen
- // if a variable expands to nothing.
- if (!lib->first.empty())
- {
- this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 );
- }
- }
-
- // 4. Add the new libraries to the link line.
- //
- for( std::vector<DependencyMap::key_type>::reverse_iterator k =
- newLinkLibrariesForVS6.rbegin();
- k != newLinkLibrariesForVS6.rend(); ++k )
- {
- // get the llt from the dep_map
- this->LinkLibrariesForVS6.push_back( std::make_pair(k->first,k->second) );
- }
- this->LinkLibrariesForVS6Analyzed = true;
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::InsertDependencyForVS6( DependencyMap& depMap,
- const LibraryID& lib,
- const LibraryID& dep)
-{
- depMap[lib].push_back(dep);
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap,
- const LibraryID& lib,
- const LibraryID& dep)
-{
- // Make sure there is an entry in the map for lib. If so, delete all
- // dependencies to dep. There may be repeated entries because of
- // external libraries that are specified multiple times.
- DependencyMap::iterator map_itr = depMap.find( lib );
- if( map_itr != depMap.end() )
- {
- DependencyList& depList = map_itr->second;
- DependencyList::iterator begin =
- std::remove(depList.begin(), depList.end(), dep);
- depList.erase(begin, depList.end());
- }
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::EmitForVS6(const LibraryID lib,
- const DependencyMap& dep_map,
- std::set<LibraryID>& emitted,
- std::set<LibraryID>& visited,
- DependencyList& link_line )
-{
- // It's already been emitted
- if( emitted.find(lib) != emitted.end() )
- {
- return;
- }
-
- // Emit the dependencies only if this library node hasn't been
- // visited before. If it has, then we have a cycle. The recursion
- // that got us here should take care of everything.
-
- if( visited.insert(lib).second )
- {
- if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies?
- {
- const DependencyList& dep_on = dep_map.find( lib )->second;
- DependencyList::const_reverse_iterator i;
-
- // To cater for recursive external libraries, we must emit
- // duplicates on this link line *unless* they were emitted by
- // some other node, in which case we assume that the recursion
- // was resolved then. We making the simplifying assumption that
- // any duplicates on a single link line are on purpose, and must
- // be preserved.
-
- // This variable will keep track of the libraries that were
- // emitted directly from the current node, and not from a
- // recursive call. This way, if we come across a library that
- // has already been emitted, we repeat it iff it has been
- // emitted here.
- std::set<DependencyMap::key_type> emitted_here;
- for( i = dep_on.rbegin(); i != dep_on.rend(); ++i )
- {
- if( emitted_here.find(*i) != emitted_here.end() )
- {
- // a repeat. Must emit.
- emitted.insert(*i);
- link_line.push_back( *i );
- }
- else
- {
- // Emit only if no-one else has
- if( emitted.find(*i) == emitted.end() )
- {
- // emit dependencies
- this->EmitForVS6( *i, dep_map, emitted, visited, link_line );
- // emit self
- emitted.insert(*i);
- emitted_here.insert(*i);
- link_line.push_back( *i );
- }
- }
- }
- }
- }
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf,
- const LibraryID& lib,
- DependencyMap& dep_map)
-{
- // If the library is already in the dependency map, then it has
- // already been fully processed.
- if( dep_map.find(lib) != dep_map.end() )
- {
- return;
- }
-
- const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" );
- if( deps && strcmp(deps,"") != 0 )
- {
- // Make sure this library is in the map, even if it has an empty
- // set of dependencies. This distinguishes the case of explicitly
- // no dependencies with that of unspecified dependencies.
- dep_map[lib];
-
- // Parse the dependency information, which is a set of
- // type, library pairs separated by ";". There is always a trailing ";".
- cmTargetLinkLibraryType llt = GENERAL_LibraryType;
- std::string depline = deps;
- std::string::size_type start = 0;
- std::string::size_type end;
- end = depline.find( ";", start );
- while( end != std::string::npos )
- {
- std::string l = depline.substr( start, end-start );
- if(!l.empty())
- {
- if (l == "debug")
- {
- llt = DEBUG_LibraryType;
- }
- else if (l == "optimized")
- {
- llt = OPTIMIZED_LibraryType;
- }
- else if (l == "general")
- {
- llt = GENERAL_LibraryType;
- }
- else
- {
- LibraryID lib2(l,llt);
- this->InsertDependencyForVS6( dep_map, lib, lib2);
- this->GatherDependenciesForVS6( mf, lib2, dep_map);
- llt = GENERAL_LibraryType;
- }
- }
- start = end+1; // skip the ;
- end = depline.find( ";", start );
- }
- // cannot depend on itself
- this->DeleteDependencyForVS6( dep_map, lib, lib);
- }
-}
-#endif
-
//----------------------------------------------------------------------------
static bool whiteListedInterfaceProperty(const std::string& prop)
{
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 97b0871..4e97c2c 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -245,13 +245,6 @@ public:
cmStringRange GetLinkImplementationEntries() const;
cmBacktraceRange GetLinkImplementationBacktraces() const;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- const LinkLibraryVectorType &GetLinkLibrariesForVS6() const {
- return this->LinkLibrariesForVS6;}
-
- void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
-#endif
-
struct StrictTargetComparison {
bool operator()(cmTarget const* t1, cmTarget const* t2) const;
};
@@ -259,57 +252,6 @@ public:
private:
bool HandleLocationPropertyPolicy(cmMakefile* context) const;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /**
- * A list of direct dependencies. Use in conjunction with DependencyMap.
- */
- typedef std::vector< LibraryID > DependencyList;
-
- /**
- * This map holds the dependency graph. map[x] returns a set of
- * direct dependencies of x. Note that the direct depenencies are
- * ordered. This is necessary to handle direct dependencies that
- * themselves have no dependency information.
- */
- typedef std::map< LibraryID, DependencyList > DependencyMap;
-
- /**
- * Inserts \a dep at the end of the dependency list of \a lib.
- */
- void InsertDependencyForVS6( DependencyMap& depMap,
- const LibraryID& lib,
- const LibraryID& dep);
-
- /*
- * Deletes \a dep from the dependency list of \a lib.
- */
- void DeleteDependencyForVS6( DependencyMap& depMap,
- const LibraryID& lib,
- const LibraryID& dep);
-
- /**
- * Emits the library \a lib and all its dependencies into link_line.
- * \a emitted keeps track of the libraries that have been emitted to
- * avoid duplicates--it is more efficient than searching
- * link_line. \a visited is used detect cycles. Note that \a
- * link_line is in reverse order, in that the dependencies of a
- * library are listed before the library itself.
- */
- void EmitForVS6( const LibraryID lib,
- const DependencyMap& dep_map,
- std::set<LibraryID>& emitted,
- std::set<LibraryID>& visited,
- DependencyList& link_line);
-
- /**
- * Finds the dependencies for \a lib and inserts them into \a
- * dep_map.
- */
- void GatherDependenciesForVS6( const cmMakefile& mf,
- const LibraryID& lib,
- DependencyMap& dep_map);
-#endif
-
const char* GetSuffixVariableInternal(bool implib) const;
const char* GetPrefixVariableInternal(bool implib) const;
@@ -338,9 +280,6 @@ private:
std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands;
LinkLibraryVectorType PrevLinkedLibraries;
LinkLibraryVectorType OriginalLinkLibraries;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- LinkLibraryVectorType LinkLibrariesForVS6;
-#endif
cmMakefile* Makefile;
cmTargetInternalPointer Internal;
cmState::TargetType TargetTypeValue;
@@ -351,9 +290,6 @@ private:
bool IsImportedTarget;
bool ImportedGloballyVisible;
bool BuildInterfaceIncludesAppended;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- bool LinkLibrariesForVS6Analyzed;
-#endif
std::string ProcessSourceItemCMP0049(const std::string& s);
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 6fd6ab7..1c795c4 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -12,9 +12,11 @@
#include "cmTimestamp.h"
#include <cstring>
+#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sstream>
//----------------------------------------------------------------------------
std::string cmTimestamp::CurrentTime(
@@ -44,7 +46,7 @@ std::string cmTimestamp::FileModificationTime(const char* path,
//----------------------------------------------------------------------------
std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
- std::string formatString, bool utcFlag)
+ std::string formatString, bool utcFlag) const
{
if(formatString.empty())
{
@@ -79,12 +81,12 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
for(std::string::size_type i = 0; i < formatString.size(); ++i)
{
char c1 = formatString[i];
- char c2 = (i+1 < formatString.size()) ?
- formatString[i+1] : static_cast<char>(0);
+ char c2 = (i + 1 < formatString.size()) ?
+ formatString[i + 1] : static_cast<char>(0);
if(c1 == '%' && c2 != 0)
{
- result += AddTimestampComponent(c2, timeStruct);
+ result += AddTimestampComponent(c2, timeStruct, timeT);
++i;
}
else
@@ -97,8 +99,40 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
}
//----------------------------------------------------------------------------
+time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm &tm) const
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ return _mkgmtime(&tm);
+#else
+ // From Linux timegm() manpage.
+
+ std::string tz_old = "TZ=";
+ if (const char* tz = cmSystemTools::GetEnv("TZ"))
+ {
+ tz_old += tz;
+ }
+
+ // The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
+ // It seems that "TZ=" does NOT work, at least under Windows
+ // with neither MSVC nor MinGW, so let's use explicit "TZ=UTC"
+
+ cmSystemTools::PutEnv("TZ=UTC");
+
+ tzset();
+
+ time_t result = mktime(&tm);
+
+ cmSystemTools::PutEnv(tz_old);
+
+ tzset();
+
+ return result;
+#endif
+}
+
+//----------------------------------------------------------------------------
std::string cmTimestamp::AddTimestampComponent(
- char flag, struct tm& timeStruct)
+ char flag, struct tm& timeStruct, const time_t timeT) const
{
std::string formatString = "%";
formatString += flag;
@@ -117,6 +151,26 @@ std::string cmTimestamp::AddTimestampComponent(
case 'y':
case 'Y':
break;
+ case 's': // Seconds since UNIX epoch (midnight 1-jan-1970)
+ {
+ // Build a time_t for UNIX epoch and substract from the input "timeT":
+ struct tm tmUnixEpoch;
+ memset(&tmUnixEpoch, 0, sizeof(tmUnixEpoch));
+ tmUnixEpoch.tm_mday = 1;
+ tmUnixEpoch.tm_year = 1970-1900;
+
+ const time_t unixEpoch = this->CreateUtcTimeTFromTm(tmUnixEpoch);
+ if (unixEpoch == -1)
+ {
+ cmSystemTools::Error("Error generating UNIX epoch in "
+ "STRING(TIMESTAMP ...). Please, file a bug report aginst CMake");
+ return std::string();
+ }
+
+ std::stringstream ss;
+ ss << static_cast<long int>(difftime(timeT, unixEpoch));
+ return ss.str();
+ }
default:
{
return formatString;
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 24c1869..7c4b216 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -16,7 +16,7 @@
#include <time.h>
/** \class cmTimestamp
- * \brief Utility class to generate sting representation of a timestamp
+ * \brief Utility class to generate string representation of a timestamp
*
*/
class cmTimestamp
@@ -30,10 +30,13 @@ public:
const std::string& formatString, bool utcFlag);
private:
- std::string CreateTimestampFromTimeT(time_t timeT,
- std::string formatString, bool utcFlag);
+ time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
- std::string AddTimestampComponent(char flag, struct tm& timeStruct);
+ std::string CreateTimestampFromTimeT(
+ time_t timeT, std::string formatString, bool utcFlag) const;
+
+ std::string AddTimestampComponent(
+ char flag, struct tm& timeStruct, time_t timeT) const;
};
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 12ce015..87fbbdf 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -28,7 +28,7 @@ bool cmTryCompileCommand
return false;
}
- this->TryCompileCode(argv);
+ this->TryCompileCode(argv, false);
// if They specified clean then we clean up what we can
if (this->SrcFileSignature)
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index b9ffe5e..d4a36c9 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -135,7 +135,7 @@ bool cmTryRunCommand
this->CompileResultVariable = argv[1];
// do the try compile
- int res = this->TryCompileCode(tryCompile);
+ int res = this->TryCompileCode(tryCompile, true);
// now try running the command if it compiled
if (!res)
diff --git a/Source/cmVS14CLFlagTable.h b/Source/cmVS14CLFlagTable.h
index 422f47b..173f624 100644
--- a/Source/cmVS14CLFlagTable.h
+++ b/Source/cmVS14CLFlagTable.h
@@ -28,6 +28,8 @@ static cmVS7FlagTable cmVS14CLFlagTable[] =
"Custom", "Custom", 0},
{"Optimization", "Od",
"Disabled", "Disabled", 0},
+ {"Optimization", "Os",
+ "Minimize Size", "MinSize", 0},
{"Optimization", "O1",
"Minimize Size", "MinSpace", 0},
{"Optimization", "O2",
@@ -172,6 +174,24 @@ static cmVS7FlagTable cmVS14CLFlagTable[] =
{"CompileAsManaged", "clr:oldSyntax",
"Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
+ {"CppLanguageStandard", "",
+ "Default", "Default", 0},
+ {"CppLanguageStandard", "std=c++98",
+ "C++03", "c++98", 0},
+ {"CppLanguageStandard", "std=c++11",
+ "C++11", "c++11", 0},
+ {"CppLanguageStandard", "std=c++1y",
+ "C++14", "c++1y", 0 },
+ {"CppLanguageStandard", "std=c++14",
+ "C++14", "c++1y", 0 },
+ {"CppLanguageStandard", "std=gnu++98",
+ "C++03 (GNU Dialect)", "gnu++98", 0},
+ {"CppLanguageStandard", "std=gnu++11",
+ "C++11 (GNU Dialect)", "gnu++11", 0},
+ {"CppLanguageStandard", "std=gnu++1y",
+ "C++14 (GNU Dialect)", "gnu++1y", 0},
+ {"CppLanguageStandard", "std=gnu++14",
+ "C++14 (GNU Dialect)", "gnu++1y", 0},
//Bool Properties
{"CompileAsWinRT", "ZW", "", "true", 0},
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index da950be..31873b5 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -696,43 +696,51 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
i->c_str(),
1, " Label=\"Configuration\"", "\n");
std::string configType = "<ConfigurationType>";
- switch(this->GeneratorTarget->GetType())
- {
- case cmState::SHARED_LIBRARY:
- case cmState::MODULE_LIBRARY:
- configType += "DynamicLibrary";
- break;
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY:
- configType += "StaticLibrary";
- break;
- case cmState::EXECUTABLE:
- if(this->NsightTegra &&
- !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
- {
- // Android executables are .so too.
+ if (const char* vsConfigurationType =
+ this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE"))
+ {
+ configType += cmVS10EscapeXML(vsConfigurationType);
+ }
+ else
+ {
+ switch(this->GeneratorTarget->GetType())
+ {
+ case cmState::SHARED_LIBRARY:
+ case cmState::MODULE_LIBRARY:
configType += "DynamicLibrary";
- }
- else
- {
- configType += "Application";
- }
- break;
- case cmState::UTILITY:
- case cmState::GLOBAL_TARGET:
- if(this->NsightTegra)
- {
- // Tegra-Android platform does not understand "Utility".
+ break;
+ case cmState::OBJECT_LIBRARY:
+ case cmState::STATIC_LIBRARY:
configType += "StaticLibrary";
- }
- else
- {
- configType += "Utility";
- }
- break;
- case cmState::UNKNOWN_LIBRARY:
- case cmState::INTERFACE_LIBRARY:
- break;
+ break;
+ case cmState::EXECUTABLE:
+ if(this->NsightTegra &&
+ !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
+ {
+ // Android executables are .so too.
+ configType += "DynamicLibrary";
+ }
+ else
+ {
+ configType += "Application";
+ }
+ break;
+ case cmState::UTILITY:
+ case cmState::GLOBAL_TARGET:
+ if(this->NsightTegra)
+ {
+ // Tegra-Android platform does not understand "Utility".
+ configType += "StaticLibrary";
+ }
+ else
+ {
+ configType += "Utility";
+ }
+ break;
+ case cmState::UNKNOWN_LIBRARY:
+ case cmState::INTERFACE_LIBRARY:
+ break;
+ }
}
configType += "</ConfigurationType>\n";
this->WriteString(configType.c_str(), 2);
@@ -2070,7 +2078,18 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
if(this->MSTools)
{
- this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+ cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
+ const char* toolset = this->GlobalGenerator->GetPlatformToolset();
+ if (toolset && clangToolset.find(toolset))
+ {
+ this->WriteString("<ObjectFileName>"
+ "$(IntDir)%(filename).obj"
+ "</ObjectFileName>\n", 3);
+ }
+ else
+ {
+ this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+ }
// If not in debug mode, write the DebugInformationFormat field
// without value so PDBs don't get generated uselessly.
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 5bc34c1..911e154 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -111,102 +111,102 @@ void cmXCodeObject::Print(std::ostream& out)
for(i = this->ObjectAttributes.begin();
i != this->ObjectAttributes.end(); ++i)
{
- cmXCodeObject* object = i->second;
- if(i->first != "isa")
- {
- cmXCodeObject::Indent(3*indentFactor, out);
- }
- else
- {
+ if(i->first == "isa")
continue;
- }
- if(object->TypeValue == OBJECT_LIST)
- {
- out << i->first << " = (" << separator;
- for(unsigned int k = 0; k < i->second->List.size(); k++)
- {
- cmXCodeObject::Indent(4*indentFactor, out);
- out << i->second->List[k]->Id;
- i->second->List[k]->PrintComment(out);
- out << "," << separator;
- }
- cmXCodeObject::Indent(3*indentFactor, out);
- out << ");" << separator;
- }
- else if(object->TypeValue == ATTRIBUTE_GROUP)
+
+ PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this);
+ }
+ cmXCodeObject::Indent(2*indentFactor, out);
+ out << "};\n";
+}
+
+void cmXCodeObject::PrintAttribute(std::ostream& out, const int level,
+ const std::string separator,
+ const int factor, const std::string& name,
+ const cmXCodeObject* object,
+ const cmXCodeObject* parent)
+{
+ cmXCodeObject::Indent(level * factor, out);
+ switch(object->TypeValue)
+ {
+ case OBJECT_LIST:
{
- std::map<std::string, cmXCodeObject*>::iterator j;
- out << i->first << " = {";
- if(separator == "\n")
+ out << name << " = (";
+ if(parent->TypeValue != ATTRIBUTE_GROUP)
{
out << separator;
}
- for(j = object->ObjectAttributes.begin(); j !=
- object->ObjectAttributes.end(); ++j)
+ for(unsigned int i = 0; i < object->List.size(); ++i)
{
- cmXCodeObject::Indent(4 *indentFactor, out);
-
- if(j->second->TypeValue == STRING)
- {
- cmXCodeObject::PrintString(out,j->first);
- out << " = ";
- j->second->PrintString(out);
- out << ";";
- }
- else if(j->second->TypeValue == OBJECT_LIST)
+ if(object->List[i]->TypeValue == STRING)
{
- cmXCodeObject::PrintString(out,j->first);
- out << " = (";
- for(unsigned int k = 0; k < j->second->List.size(); k++)
+ object->List[i]->PrintString(out);
+ if(i+1 < object->List.size())
{
- if(j->second->List[k]->TypeValue == STRING)
- {
- j->second->List[k]->PrintString(out);
- out << ", ";
- }
- else
- {
- out << "List_" << k << "_TypeValue_IS_NOT_STRING, ";
- }
+ out << ",";
}
- out << ");";
}
else
{
- cmXCodeObject::PrintString(out,j->first);
- out << " = error_unexpected_TypeValue_" <<
- j->second->TypeValue << ";";
+ cmXCodeObject::Indent((level + 1) * factor, out);
+ out << object->List[i]->Id;
+ object->List[i]->PrintComment(out);
+ out << "," << separator;
}
+ }
+ if(parent->TypeValue != ATTRIBUTE_GROUP)
+ {
+ cmXCodeObject::Indent(level * factor, out);
+ }
+ out << ");" << separator;
+ }
+ break;
+ case ATTRIBUTE_GROUP:
+ {
+ out << name << " = {";
+ if(separator == "\n")
+ {
out << separator;
}
- cmXCodeObject::Indent(3 *indentFactor, out);
+ std::map<std::string, cmXCodeObject*>::const_iterator i;
+ for(i = object->ObjectAttributes.begin();
+ i != object->ObjectAttributes.end(); ++i)
+ {
+ PrintAttribute(out, (level + 1) * factor, separator, factor,
+ i->first, i->second, object);
+ }
+ cmXCodeObject::Indent(level * factor, out);
out << "};" << separator;
}
- else if(object->TypeValue == OBJECT_REF)
+ break;
+
+ case OBJECT_REF:
{
- cmXCodeObject::PrintString(out,i->first);
+ cmXCodeObject::PrintString(out, name);
out << " = " << object->Object->Id;
- if(object->Object->HasComment() && i->first != "remoteGlobalIDString")
+ if(object->Object->HasComment() && name != "remoteGlobalIDString")
{
object->Object->PrintComment(out);
}
out << ";" << separator;
}
- else if(object->TypeValue == STRING)
+ break;
+
+ case STRING:
{
- cmXCodeObject::PrintString(out,i->first);
+ cmXCodeObject::PrintString(out, name);
out << " = ";
object->PrintString(out);
out << ";" << separator;
}
- else
+ break;
+
+ default:
{
- out << "what is this?? " << i->first << "\n";
+ break;
}
}
- cmXCodeObject::Indent(2*indentFactor, out);
- out << "};\n";
}
//----------------------------------------------------------------------------
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index bd0f43f..2d876da 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -75,6 +75,10 @@ public:
}
static void Indent(int level, std::ostream& out);
void Print(std::ostream& out);
+ void PrintAttribute(std::ostream& out, const int level,
+ const std::string separator, const int factor,
+ const std::string& name, const cmXCodeObject* object,
+ const cmXCodeObject* parent);
virtual void PrintComment(std::ostream&) {}
static void PrintList(std::vector<cmXCodeObject*> const&,
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
index f9b3b49..6a9172a 100644
--- a/Source/cmXMLWriter.cxx
+++ b/Source/cmXMLWriter.cxx
@@ -67,6 +67,13 @@ void cmXMLWriter::EndElement()
this->ElementOpen = false;
}
+void cmXMLWriter::Element(const char* name)
+{
+ this->CloseStartElement();
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->Output << '<' << name << "/>";
+}
+
void cmXMLWriter::BreakAttributes()
{
this->BreakAttrib = true;
@@ -85,6 +92,13 @@ void cmXMLWriter::CData(std::string const& data)
this->Output << "<![CDATA[" << data << "]]>";
}
+void cmXMLWriter::Doctype(const char* doctype)
+{
+ this->CloseStartElement();
+ this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->Output << "<!DOCTYPE " << doctype << ">";
+}
+
void cmXMLWriter::ProcessingInstruction(const char* target, const char* data)
{
this->CloseStartElement();
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index c38c0de..3083059 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -41,6 +41,8 @@ public:
this->Output << name << "=\"" << SafeAttribute(value) << '"';
}
+ void Element(const char* name);
+
template <typename T>
void Element(std::string const& name, T const& value)
{
@@ -60,6 +62,8 @@ public:
void CData(std::string const& data);
+ void Doctype(const char* doctype);
+
void ProcessingInstruction(const char* target, const char* data);
void FragmentFile(const char* fname);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8f6b952..dcc95af 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -51,8 +51,6 @@
// include the generator
#if defined(_WIN32) && !defined(__CYGWIN__)
# if !defined(CMAKE_BOOT_MINGW)
-# include "cmGlobalVisualStudio6Generator.h"
-# include "cmGlobalVisualStudio7Generator.h"
# include "cmGlobalVisualStudio71Generator.h"
# include "cmGlobalVisualStudio8Generator.h"
# include "cmGlobalVisualStudio9Generator.h"
@@ -1429,8 +1427,6 @@ int cmake::ActualConfigure()
const char* GeneratorName;
};
VSRegistryEntryName version[] = {
- {"6.0", "Visual Studio 6"},
- {"7.0", "Visual Studio 7"},
{"7.1", "Visual Studio 7 .NET 2003"},
{"8.0", "Visual Studio 8 2005"},
{"9.0", "Visual Studio 9 2008"},
@@ -1837,10 +1833,6 @@ void cmake::AddDefaultGenerators()
this->Generators.push_back(
cmGlobalVisualStudio71Generator::NewFactory());
this->Generators.push_back(
- cmGlobalVisualStudio7Generator::NewFactory());
- this->Generators.push_back(
- cmGlobalVisualStudio6Generator::NewFactory());
- this->Generators.push_back(
cmGlobalBorlandMakefileGenerator::NewFactory());
this->Generators.push_back(
cmGlobalNMakeMakefileGenerator::NewFactory());
@@ -2417,8 +2409,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// we have to find the module directory, so we can copy the files
this->AddCMakePaths();
- std::string modulesPath =
- this->State->GetInitializedCacheValue("CMAKE_ROOT");
+ std::string modulesPath = cmSystemTools::GetCMakeRoot();
modulesPath += "/Modules";
std::string inFile = modulesPath;
inFile += "/SystemInformation.cmake";
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index a06b26f..600cc1a 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -60,6 +60,7 @@ static const char * cmDocumentationUsageNote[][2] =
#define CMAKE_BUILD_OPTIONS \
" <dir> = Project binary directory to be built.\n" \
" --target <tgt> = Build <tgt> instead of default targets.\n" \
+ " May only be specified once.\n" \
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
" --clean-first = Build target 'clean' first, then build.\n" \
" (To clean only, use --target 'clean'.)\n" \
@@ -386,6 +387,7 @@ static int do_build(int ac, char const* const* av)
std::string dir;
std::vector<std::string> nativeOptions;
bool clean = false;
+ bool hasTarget = false;
enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
Doing doing = DoingDir;
@@ -397,7 +399,17 @@ static int do_build(int ac, char const* const* av)
}
else if(strcmp(av[i], "--target") == 0)
{
- doing = DoingTarget;
+ if (!hasTarget)
+ {
+ doing = DoingTarget;
+ hasTarget = true;
+ }
+ else
+ {
+ std::cerr << "'--target' may not be specified more than once.\n\n";
+ dir = "";
+ break;
+ }
}
else if(strcmp(av[i], "--config") == 0)
{
@@ -449,13 +461,6 @@ static int do_build(int ac, char const* const* av)
return 1;
}
- // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
- //
- if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
- {
- config = config.substr(2);
- }
-
cmake cm;
return cm.Build(dir, target, config, nativeOptions, clean);
#endif
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index 3636836..f713294 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -20,6 +20,7 @@
#if 0
# include "CommandLineArguments.hxx.in"
# include "Configure.hxx.in"
+# include "String.hxx.in"
#endif
#include <vector>
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index b9d25a8..b75acb2 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -254,7 +254,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti)\
- t = a + F(b,c,d) + X[k] + Ti;\
+ t = a + F(b,c,d) + X[k] + (Ti);\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 7, T1);
@@ -280,7 +280,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
- t = a + G(b,c,d) + X[k] + Ti;\
+ t = a + G(b,c,d) + X[k] + (Ti);\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 1, 5, T17);
@@ -306,7 +306,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
- t = a + H(b,c,d) + X[k] + Ti;\
+ t = a + H(b,c,d) + X[k] + (Ti);\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 5, 4, T33);
@@ -332,7 +332,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
- t = a + I(b,c,d) + X[k] + Ti;\
+ t = a + I(b,c,d) + X[k] + (Ti);\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 6, T49);
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index c5ebc97..96563a2 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -77,6 +77,7 @@
# define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit)
# define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt)
# define kwsysProcess_Kill kwsys_ns(Process_Kill)
+# define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime)
#endif
#if defined(__cplusplus)
@@ -392,6 +393,11 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp);
*/
kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
+/**
+ * Reset the start time of the child process to the current time.
+ */
+kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp);
+
#if defined(__cplusplus)
} /* extern "C" */
#endif
@@ -456,6 +462,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
# undef kwsysProcess_WaitForExit
# undef kwsysProcess_Interrupt
# undef kwsysProcess_Kill
+# undef kwsysProcess_ResetStartTime
# endif
#endif
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 07c644b..b577982 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
{
cp->Timeout = 0;
}
+ // Force recomputation of TimeoutTime.
+ cp->TimeoutTime.tv_sec = -1;
}
/*--------------------------------------------------------------------------*/
@@ -3056,3 +3058,14 @@ static void kwsysProcessesSignalHandler(int signum
errno = old_errno;
}
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_ResetStartTime(kwsysProcess* cp)
+{
+ if(!cp)
+ {
+ return;
+ }
+ /* Reset start time. */
+ cp->StartTime = kwsysProcessTimeGetCurrent();
+}
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 1f8749f..2b93e69 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -17,7 +17,7 @@
duplicate the above list of headers. */
#if 0
# include "Process.h.in"
-# include "Encoding_c.h.in"
+# include "Encoding.h.in"
#endif
/*
@@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
{
cp->Timeout = 0;
}
+ // Force recomputation of TimeoutTime.
+ cp->TimeoutTime.QuadPart = -1;
}
/*--------------------------------------------------------------------------*/
@@ -3015,3 +3017,14 @@ static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
/* Continue on to default Ctrl handler (which calls ExitProcess). */
return FALSE;
}
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_ResetStartTime(kwsysProcess* cp)
+{
+ if(!cp)
+ {
+ return;
+ }
+ /* Reset start time. */
+ cp->StartTime = kwsysProcessTimeGetCurrent();
+}
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index cddcc8d..512d5fb 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -43,7 +43,6 @@
#if 0
# include "SystemInformation.hxx.in"
# include "Process.h.in"
-# include "Configure.hxx.in"
#endif
#include <iostream>
@@ -177,13 +176,13 @@ typedef struct rlimit ResourceLimitType;
# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
# define iostreamLongLong(x) (x)
# else
-# define iostreamLongLong(x) ((long)x)
+# define iostreamLongLong(x) ((long)(x))
# endif
#elif defined(KWSYS_USE___INT64)
# if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
# define iostreamLongLong(x) (x)
# else
-# define iostreamLongLong(x) ((long)x)
+# define iostreamLongLong(x) ((long)(x))
# endif
#else
# error "No Long Long"
@@ -201,13 +200,13 @@ typedef struct rlimit ResourceLimitType;
# endif
#endif
-#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64)
+#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && !defined(__clang__)
#define USE_ASM_INSTRUCTIONS 1
#else
#define USE_ASM_INSTRUCTIONS 0
#endif
-#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
#include <intrin.h>
#define USE_CPUID_INTRINSICS 1
#else
@@ -861,7 +860,7 @@ void SystemInformation::RunMemoryCheck()
// --------------------------------------------------------------
// SystemInformationImplementation starts here
-#define STORE_TLBCACHE_INFO(x,y) x = (x < y) ? y : x
+#define STORE_TLBCACHE_INFO(x,y) x = (x < (y)) ? (y) : x
#define TLBCACHE_INFO_UNITS (15)
#define CLASSICAL_CPU_FREQ_LOOP 10000000
#define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
@@ -3570,33 +3569,44 @@ SystemInformationImplementation::GetHostMemoryUsed()
return (statex.ullTotalPhys - statex.ullAvailPhys)/1024;
# endif
#elif defined(__linux)
- const char *names[3]={"MemTotal:","MemFree:",NULL};
- SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)};
- int ierr=GetFieldsFromFile("/proc/meminfo",names,values);
+ // First try to use MemAvailable, but it only works on newer kernels
+ const char *names2[3]={"MemTotal:","MemAvailable:",NULL};
+ SystemInformation::LongLong values2[2]={SystemInformation::LongLong(0)};
+ int ierr=GetFieldsFromFile("/proc/meminfo",names2,values2);
if (ierr)
{
- return ierr;
- }
- SystemInformation::LongLong &memTotal=values[0];
- SystemInformation::LongLong &memFree=values[1];
- return memTotal - memFree;
+ const char *names4[5]={"MemTotal:","MemFree:","Buffers:","Cached:",NULL};
+ SystemInformation::LongLong values4[4]={SystemInformation::LongLong(0)};
+ ierr=GetFieldsFromFile("/proc/meminfo",names4,values4);
+ if(ierr)
+ {
+ return ierr;
+ }
+ SystemInformation::LongLong &memTotal=values4[0];
+ SystemInformation::LongLong &memFree=values4[1];
+ SystemInformation::LongLong &memBuffers=values4[2];
+ SystemInformation::LongLong &memCached=values4[3];
+ return memTotal - memFree - memBuffers - memCached;
+ }
+ SystemInformation::LongLong &memTotal=values2[0];
+ SystemInformation::LongLong &memAvail=values2[1];
+ return memTotal - memAvail;
#elif defined(__APPLE__)
SystemInformation::LongLong psz=getpagesize();
if (psz<1)
{
return -1;
}
- const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL};
- SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)};
+ const char *names[3]={"Pages wired down:","Pages active:",NULL};
+ SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)};
int ierr=GetFieldsFromCommand("vm_stat", names, values);
if (ierr)
{
return -1;
}
- SystemInformation::LongLong &vmActive=values[0];
- SystemInformation::LongLong &vmInactive=values[1];
- SystemInformation::LongLong &vmWired=values[2];
- return ((vmActive+vmInactive+vmWired)*psz)/1024;
+ SystemInformation::LongLong &vmWired=values[0];
+ SystemInformation::LongLong &vmActive=values[1];
+ return ((vmActive+vmWired)*psz)/1024;
#else
return 0;
#endif
@@ -4622,7 +4632,7 @@ std::string SystemInformationImplementation::RunProcess(std::vector<const char*>
double timeout = 255;
int pipe; // pipe id as returned by kwsysProcess_WaitForData()
- while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout),
+ while( ( static_cast<void>(pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout)),
(pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s
{
buffer.append(data, length);
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index e3428f8..0c7f419 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -35,10 +35,12 @@
#include <fstream>
#include <sstream>
#include <set>
+#include <vector>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
+# include "RegularExpression.hxx.in"
# include "SystemTools.hxx.in"
# include "Directory.hxx.in"
# include "FStream.hxx.in"
@@ -87,6 +89,7 @@
// Windows API.
#if defined(_WIN32)
# include <windows.h>
+# include <winioctl.h>
# ifndef INVALID_FILE_ATTRIBUTES
# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
# endif
@@ -2754,6 +2757,106 @@ std::string SystemTools::GetLastSystemError()
return strerror(e);
}
+#ifdef _WIN32
+
+static bool IsJunction(const std::wstring& source)
+{
+#ifdef FSCTL_GET_REPARSE_POINT
+ const DWORD JUNCTION_ATTRS = FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_REPARSE_POINT;
+ DWORD attrs = GetFileAttributesW(source.c_str());
+ if (attrs == INVALID_FILE_ATTRIBUTES)
+ {
+ return false;
+ }
+ if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS)
+ {
+ return false;
+ }
+
+ // Adjust privileges so that we can succefully open junction points.
+ HANDLE token;
+ TOKEN_PRIVILEGES privs;
+ OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
+ LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid);
+ privs.PrivilegeCount = 1;
+ privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
+ CloseHandle(token);
+
+ HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ,
+ 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (dir == INVALID_HANDLE_VALUE)
+ {
+ return false;
+ }
+
+ // Query whether this is a reparse point or not.
+ BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+ REPARSE_GUID_DATA_BUFFER *reparse_buffer =
+ (REPARSE_GUID_DATA_BUFFER*) buffer;
+ DWORD sentinel;
+
+ BOOL success = DeviceIoControl(
+ dir, FSCTL_GET_REPARSE_POINT,
+ NULL, 0,
+ reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE,
+ &sentinel, NULL);
+
+ CloseHandle(dir);
+
+ return (success && (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT));
+#else
+ return false;
+#endif
+}
+
+static bool DeleteJunction(const std::wstring& source)
+{
+#ifdef FSCTL_DELETE_REPARSE_POINT
+ // Adjust privileges so that we can succefully open junction points as
+ // read/write.
+ HANDLE token;
+ TOKEN_PRIVILEGES privs;
+ OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
+ LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid);
+ privs.PrivilegeCount = 1;
+ privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
+ CloseHandle(token);
+
+ HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (dir == INVALID_HANDLE_VALUE)
+ {
+ return false;
+ }
+
+ // Set up the structure so that we can delete the junction.
+ std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0);
+ REPARSE_GUID_DATA_BUFFER *reparse_buffer =
+ (REPARSE_GUID_DATA_BUFFER*) &buffer[0];
+ DWORD sentinel;
+
+ reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
+
+ BOOL success = DeviceIoControl(
+ dir, FSCTL_DELETE_REPARSE_POINT,
+ reparse_buffer, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
+ NULL, 0,
+ &sentinel, NULL);
+
+ CloseHandle(dir);
+
+ return !!success;
+#else
+ return false;
+#endif
+}
+#endif
+
bool SystemTools::RemoveFile(const std::string& source)
{
#ifdef _WIN32
@@ -2781,6 +2884,10 @@ bool SystemTools::RemoveFile(const std::string& source)
SetLastError(err);
return false;
}
+ if (IsJunction(ws) && !DeleteJunction(ws))
+ {
+ return false;
+ }
if (DeleteFileW(ws.c_str()) ||
GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_PATH_NOT_FOUND)
@@ -4651,8 +4758,9 @@ bool SystemTools::GetLineFromStream(std::istream& is,
// been reached. Clear the fail bit just before reading.
while(!haveNewline &&
leftToRead != 0 &&
- (is.clear(is.rdstate() & ~std::ios::failbit),
- is.getline(buffer, bufferSize), is.gcount() > 0))
+ (static_cast<void>(is.clear(is.rdstate() & ~std::ios::failbit)),
+ static_cast<void>(is.getline(buffer, bufferSize)),
+ is.gcount() > 0))
{
// We have read at least one byte.
haveData = true;
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 695a134..7c58769 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -53,7 +53,7 @@ static std::string GetLibName(const char* lname)
* r2: should GetSymbolAddress succeed ?
* r3: should CloseLibrary succeed ?
*/
-int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3)
+static int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3)
{
std::cerr << "Testing: " << libname << std::endl;
kwsys::DynamicLoader::LibraryHandle l
diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx
index ab1f83e..ae66ceb 100644
--- a/Source/kwsys/testHashSTL.cxx
+++ b/Source/kwsys/testHashSTL.cxx
@@ -18,7 +18,6 @@
#if 0
# include "hash_map.hxx.in"
# include "hash_set.hxx.in"
-# include "hashtable.hxx.in"
#endif
#include <iostream>
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
index 396a09d..5ff7955 100644
--- a/Source/kwsys/testIOS.cxx
+++ b/Source/kwsys/testIOS.cxx
@@ -18,6 +18,12 @@
#include <vector>
#include <string.h> /* strlen */
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "Configure.hxx.in"
+#endif
+
int testIOS(int, char*[])
{
std::ostringstream ostr;