summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt4
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx622
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h105
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx87
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h42
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx102
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.h39
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx171
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h66
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx91
-rw-r--r--Source/CPack/WiX/cmWIXPatch.h45
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx2
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.h2
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx8
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.h8
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.h29
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx14
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h16
-rw-r--r--Source/CPack/cmCPackGenerator.cxx6
-rw-r--r--Source/CPack/cmCPackGenerator.h1
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx6
-rw-r--r--Source/cmLocalGenerator.cxx70
-rw-r--r--Source/cmLocalGenerator.h18
-rw-r--r--Source/cmLocalNinjaGenerator.cxx10
-rw-r--r--Source/cmLocalNinjaGenerator.h6
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx8
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx28
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx29
-rw-r--r--Source/cmMakefileTargetGenerator.cxx40
-rw-r--r--Source/cmMakefileTargetGenerator.h5
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/kwsys/CMakeLists.txt6
-rw-r--r--Source/kwsys/FStream.cxx76
-rw-r--r--Source/kwsys/FStream.hxx.in21
-rw-r--r--Source/kwsys/SharedForward.h.in8
-rw-r--r--Source/kwsys/SystemInformation.cxx21
-rw-r--r--Source/kwsys/SystemTools.cxx3
-rw-r--r--Source/kwsys/testFStream.cxx142
40 files changed, 1348 insertions, 616 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 175a034..966e0f6 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -562,7 +562,11 @@ if(WIN32)
set(CPACK_SRCS ${CPACK_SRCS}
CPack/WiX/cmCPackWIXGenerator.cxx
CPack/WiX/cmWIXSourceWriter.cxx
+ CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+ CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+ CPack/WiX/cmWIXFilesSourceWriter.cxx
CPack/WiX/cmWIXRichTextFormatWriter.cxx
+ CPack/WiX/cmWIXPatch.cxx
CPack/WiX/cmWIXPatchParser.cxx
)
endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index a1ae3b3..8fdad13 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 0)
-set(CMake_VERSION_PATCH 20140226)
+set(CMake_VERSION_PATCH 20140306)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 43119d6..a385e40 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -1,6 +1,6 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
- Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
+ Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
@@ -19,6 +19,9 @@
#include <CPack/cmCPackComponentGroup.h>
#include "cmWIXSourceWriter.h"
+#include "cmWIXDirectoriesSourceWriter.h"
+#include "cmWIXFeaturesSourceWriter.h"
+#include "cmWIXFilesSourceWriter.h"
#include "cmWIXRichTextFormatWriter.h"
#include <cmsys/SystemTools.hxx>
@@ -28,11 +31,9 @@
#include <rpc.h> // for GUID generation
-#include <sys/types.h>
-#include <sys/stat.h>
-
cmCPackWIXGenerator::cmCPackWIXGenerator():
- HasDesktopShortcuts(false)
+ HasDesktopShortcuts(false),
+ Patch(Logger)
{
}
@@ -44,15 +45,9 @@ int cmCPackWIXGenerator::InitializeInternal()
return this->Superclass::InitializeInternal();
}
-bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
+bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
- std::string logFileName = cpackTopLevel + "/wix.log";
+ std::string logFileName = this->CPackTopLevel + "/wix.log";
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Running WiX command: " << command << std::endl);
@@ -81,7 +76,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
}
bool cmCPackWIXGenerator::RunCandleCommand(
- const std::string& sourceFile, const std::string& objectFile)
+ std::string const& sourceFile, std::string const& objectFile)
{
std::string executable;
if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
@@ -108,7 +103,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(
return RunWiXCommand(command.str());
}
-bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
+bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
{
std::string executable;
if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
@@ -121,8 +116,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
- for(extension_set_t::const_iterator i = LightExtensions.begin();
- i != LightExtensions.end(); ++i)
+ for(extension_set_t::const_iterator i = this->LightExtensions.begin();
+ i != this->LightExtensions.end(); ++i)
{
command << " -ext " << QuotePath(*i);
}
@@ -182,15 +177,14 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
"you might want to set this explicitly." << std::endl);
}
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
+ if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
{
return false;
}
if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
{
- std::string licenseFilename = cpackTopLevel + "/License.rtf";
+ std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
if(!CreateLicenseFile())
@@ -213,7 +207,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{
std::string defaultRef = "WixUI_InstallDir";
- if(Components.size())
+ if(this->Components.size())
{
defaultRef = "WixUI_FeatureTree";
}
@@ -221,17 +215,24 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
}
- CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
- CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
+ const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
+ if(packageContact != 0 &&
+ GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
+ {
+ SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
+ }
+
+ CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
+ CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
- LightExtensions.insert("WixUIExtension");
- CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
- CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
+ this->LightExtensions.insert("WixUIExtension");
+ CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions);
+ CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if(patchFilePath)
{
- LoadPatchFragments(patchFilePath);
+ this->Patch.LoadFragments(patchFilePath);
}
return true;
@@ -244,10 +245,8 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
return false;
}
- if(!CreateWiXVariablesIncludeFile())
- {
- return false;
- }
+ CreateWiXVariablesIncludeFile();
+ CreateWiXPropertiesIncludeFile();
if(!CreateWiXSourceFiles())
{
@@ -257,9 +256,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
AppendUserSuppliedExtraSources();
std::stringstream objectFiles;
- for(size_t i = 0; i < WixSources.size(); ++i)
+ for(size_t i = 0; i < this->WixSources.size(); ++i)
{
- const std::string& sourceFilename = WixSources[i];
+ std::string const& sourceFilename = this->WixSources[i];
std::string objectFilename =
cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@@ -282,7 +281,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
if(!cpackWixExtraSources) return;
- cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
+ cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@@ -297,22 +296,18 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
for(size_t i = 0; i < expandedExtraObjects.size(); ++i)
{
- stream << " " << QuotePath(expandedExtraObjects[i]);
+ stream << " " << QuotePath(expandedExtraObjects[i]);
}
}
-bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
+void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
std::string includeFilename =
- cpackTopLevel + "/cpack_variables.wxi";
+ this->CPackTopLevel + "/cpack_variables.wxi";
+
+ cmWIXSourceWriter includeFile(
+ this->Logger, includeFilename, true);
- cmWIXSourceWriter includeFile(Logger, includeFilename, true);
CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR");
@@ -326,12 +321,39 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
GetOption("CPACK_PACKAGE_NAME"));
CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
+}
- return true;
+void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
+{
+ std::string includeFilename =
+ this->CPackTopLevel + "/properties.wxi";
+
+ cmWIXSourceWriter includeFile(
+ this->Logger, includeFilename, true);
+
+ std::string prefix = "CPACK_WIX_PROPERTY_";
+ std::vector<std::string> options = GetOptions();
+
+ for(size_t i = 0; i < options.size(); ++i)
+ {
+ std::string const& name = options[i];
+
+ if(name.length() > prefix.length() &&
+ name.substr(0, prefix.length()) == prefix)
+ {
+ std::string id = name.substr(prefix.length());
+ std::string value = GetOption(name.c_str());
+
+ includeFile.BeginElement("Property");
+ includeFile.AddAttribute("Id", id);
+ includeFile.AddAttribute("Value", value);
+ includeFile.EndElement("Property");
+ }
+ }
}
void cmCPackWIXGenerator::CopyDefinition(
- cmWIXSourceWriter &source, const std::string &name)
+ cmWIXSourceWriter &source, std::string const& name)
{
const char* value = GetOption(name.c_str());
if(value)
@@ -341,7 +363,7 @@ void cmCPackWIXGenerator::CopyDefinition(
}
void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
- const std::string& name, const std::string& value)
+ std::string const& name, std::string const& value)
{
std::stringstream tmp;
tmp << name << "=\"" << value << '"';
@@ -352,81 +374,47 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
std::string directoryDefinitionsFilename =
- cpackTopLevel + "/directories.wxs";
+ this->CPackTopLevel + "/directories.wxs";
- WixSources.push_back(directoryDefinitionsFilename);
+ this->WixSources.push_back(directoryDefinitionsFilename);
- cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
+ cmWIXDirectoriesSourceWriter directoryDefinitions(
+ this->Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment");
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "TARGETDIR");
- directoryDefinitions.AddAttribute("Name", "SourceDir");
-
- directoryDefinitions.BeginElement("Directory");
- if(GetArchitecture() == "x86")
- {
- directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder");
- }
- else
- {
- directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder");
- }
-
- std::vector<std::string> install_root;
-
- std::string tmp;
- if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp))
+ std::string installRoot;
+ if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
{
return false;
}
- cmSystemTools::SplitPath(tmp.c_str(), install_root);
-
- if(!install_root.empty() && install_root.back().empty())
- {
- install_root.pop_back();
- }
-
- for(size_t i = 1; i < install_root.size(); ++i)
- {
- directoryDefinitions.BeginElement("Directory");
-
- if(i == install_root.size() - 1)
- {
- directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT");
- }
- else
- {
- std::stringstream ss;
- ss << "INSTALL_PREFIX_" << i;
- directoryDefinitions.AddAttribute("Id", ss.str());
- }
+ directoryDefinitions.BeginElement("Directory");
+ directoryDefinitions.AddAttribute("Id", "TARGETDIR");
+ directoryDefinitions.AddAttribute("Name", "SourceDir");
- directoryDefinitions.AddAttribute("Name", install_root[i]);
- }
+ size_t installRootSize =
+ directoryDefinitions.BeginInstallationPrefixDirectory(
+ GetProgramFilesFolderId(), installRoot);
std::string fileDefinitionsFilename =
- cpackTopLevel + "/files.wxs";
+ this->CPackTopLevel + "/files.wxs";
+
+ this->WixSources.push_back(fileDefinitionsFilename);
- WixSources.push_back(fileDefinitionsFilename);
+ cmWIXFilesSourceWriter fileDefinitions(
+ this->Logger, fileDefinitionsFilename);
- cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
- cpackTopLevel +"/features.wxs";
+ this->CPackTopLevel +"/features.wxs";
- WixSources.push_back(featureDefinitionsFilename);
+ this->WixSources.push_back(featureDefinitionsFilename);
+
+ cmWIXFeaturesSourceWriter featureDefinitions(
+ this->Logger, featureDefinitionsFilename);
- cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment");
featureDefinitions.BeginElement("Feature");
@@ -439,13 +427,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
return false;
}
- featureDefinitions.AddAttribute("Title", cpackPackageName);
+ featureDefinitions.AddAttribute("Title", cpackPackageName);
featureDefinitions.AddAttribute("Level", "1");
- if(!CreateCMakePackageRegistryEntry(featureDefinitions))
+ const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
+ if(package)
{
- return false;
+ featureDefinitions.CreateCMakePackageRegistryEntry(
+ package, GetOption("CPACK_WIX_UPGRADE_GUID"));
}
if(!CreateFeatureHierarchy(featureDefinitions))
@@ -471,7 +461,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
else
{
for(std::map<std::string, cmCPackComponent>::const_iterator
- i = Components.begin(); i != Components.end(); ++i)
+ i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
@@ -513,31 +503,51 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
featureDefinitions.EndElement("Fragment");
fileDefinitions.EndElement("Fragment");
- for(size_t i = 1; i < install_root.size(); ++i)
- {
- directoryDefinitions.EndElement("Directory");
- }
-
- directoryDefinitions.EndElement("Directory");
+ directoryDefinitions.EndInstallationPrefixDirectory(
+ installRootSize);
if(hasShortcuts)
{
- CreateStartMenuFolder(directoryDefinitions);
+ directoryDefinitions.EmitStartMenuFolder(
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
}
if(this->HasDesktopShortcuts)
{
- CreateDesktopFolder(directoryDefinitions);
+ directoryDefinitions.EmitDesktopFolder();
}
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndElement("Fragment");
+ if(!GenerateMainSourceFileFromTemplate())
+ {
+ return false;
+ }
+
+ return this->Patch.CheckForUnappliedFragments();
+}
+
+std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
+{
+ if(GetArchitecture() == "x86")
+ {
+ return "ProgramFilesFolder";
+ }
+ else
+ {
+ return "ProgramFiles64Folder";
+ }
+}
+
+bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
+{
std::string wixTemplate = FindTemplate("WIX.template.in");
if(GetOption("CPACK_WIX_TEMPLATE") != 0)
{
wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
}
+
if(wixTemplate.empty())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -545,7 +555,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
- std::string mainSourceFilePath = cpackTopLevel + "/main.wxs";
+ std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
{
@@ -556,68 +566,13 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
- WixSources.push_back(mainSourceFilePath);
-
- std::string fragmentList;
- for(cmWIXPatchParser::fragment_map_t::const_iterator
- i = Fragments.begin(); i != Fragments.end(); ++i)
- {
- if(!fragmentList.empty())
- {
- fragmentList += ", ";
- }
-
- fragmentList += "'";
- fragmentList += i->first;
- fragmentList += "'";
- }
-
- if(fragmentList.size())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Some XML patch fragments did not have matching IDs: " <<
- fragmentList << std::endl);
- return false;
- }
-
- return true;
-}
-
-bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry(
- cmWIXSourceWriter& featureDefinitions)
-{
- const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
- if(!package)
- {
- return true;
- }
-
- featureDefinitions.BeginElement("Component");
- featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY");
- featureDefinitions.AddAttribute("Directory", "TARGETDIR");
- featureDefinitions.AddAttribute("Guid", "*");
-
- std::string registryKey =
- std::string("Software\\Kitware\\CMake\\Packages\\") + package;
-
- std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID");
-
- featureDefinitions.BeginElement("RegistryValue");
- featureDefinitions.AddAttribute("Root", "HKLM");
- featureDefinitions.AddAttribute("Key", registryKey);
- featureDefinitions.AddAttribute("Name", upgradeGuid);
- featureDefinitions.AddAttribute("Type", "string");
- featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]");
- featureDefinitions.AddAttribute("KeyPath", "yes");
- featureDefinitions.EndElement("RegistryValue");
-
- featureDefinitions.EndElement("Component");
+ this->WixSources.push_back(mainSourceFilePath);
return true;
}
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
- cmWIXSourceWriter& featureDefinitions)
+ cmWIXFeaturesSourceWriter& featureDefinitions)
{
for(std::map<std::string, cmCPackComponentGroup>::const_iterator
i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
@@ -625,105 +580,30 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmCPackComponentGroup const& group = i->second;
if(group.ParentGroup == 0)
{
- if(!EmitFeatureForComponentGroup(featureDefinitions, group))
- {
- return false;
- }
+ featureDefinitions.EmitFeatureForComponentGroup(group);
}
}
for(std::map<std::string, cmCPackComponent>::const_iterator
- i = Components.begin(); i != Components.end(); ++i)
+ i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
if(!component.Group)
{
- if(!EmitFeatureForComponent(featureDefinitions, component))
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool cmCPackWIXGenerator::EmitFeatureForComponentGroup(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponentGroup const& group)
-{
- featureDefinitions.BeginElement("Feature");
- featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name);
-
- if(group.IsExpandedByDefault)
- {
- featureDefinitions.AddAttribute("Display", "expand");
- }
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Title", group.DisplayName);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Description", group.Description);
-
- for(std::vector<cmCPackComponentGroup*>::const_iterator
- i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
- {
- if(!EmitFeatureForComponentGroup(featureDefinitions, **i))
- {
- return false;
- }
- }
-
- for(std::vector<cmCPackComponent*>::const_iterator
- i = group.Components.begin(); i != group.Components.end(); ++i)
- {
- if(!EmitFeatureForComponent(featureDefinitions, **i))
- {
- return false;
+ featureDefinitions.EmitFeatureForComponent(component);
}
}
- featureDefinitions.EndElement("Feature");
-
- return true;
-}
-
-bool cmCPackWIXGenerator::EmitFeatureForComponent(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponent const& component)
-{
- featureDefinitions.BeginElement("Feature");
- featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Title", component.DisplayName);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Description", component.Description);
-
- if(component.IsRequired)
- {
- featureDefinitions.AddAttribute("Absent", "disallow");
- }
-
- if(component.IsHidden)
- {
- featureDefinitions.AddAttribute("Display", "hidden");
- }
-
- featureDefinitions.EndElement("Feature");
-
return true;
}
bool cmCPackWIXGenerator::AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap)
{
featureDefinitions.BeginElement("FeatureRef");
@@ -768,8 +648,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions)
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions)
{
bool thisHasDesktopShortcuts = false;
@@ -799,6 +679,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.BeginElement("DirectoryRef");
fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+
fileDefinitions.BeginElement("Component");
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
@@ -809,63 +690,34 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& id = i->first;
cmWIXShortcut const& shortcut = i->second;
- std::string shortcutId = std::string("CM_S") + id;
- std::string fileId = std::string("CM_F") + id;
-
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", shortcutId);
- fileDefinitions.AddAttribute("Name", shortcut.textLabel);
- std::string target = "[#" + fileId + "]";
- fileDefinitions.AddAttribute("Target", target);
- fileDefinitions.AddAttribute("WorkingDirectory",
- shortcut.workingDirectoryId);
- fileDefinitions.EndElement("Shortcut");
+ fileDefinitions.EmitShortcut(id, shortcut, false);
- if (shortcut.desktop)
+ if(shortcut.desktop)
{
- thisHasDesktopShortcuts = true;
+ thisHasDesktopShortcuts = true;
}
}
if(cpackComponentName.empty())
{
- CreateUninstallShortcut(cpackPackageName, fileDefinitions);
+ fileDefinitions.EmitUninstallShortcut(cpackPackageName);
}
- fileDefinitions.BeginElement("RemoveFolder");
- fileDefinitions.AddAttribute("Id",
+ fileDefinitions.EmitRemoveFolder(
"CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
- fileDefinitions.AddAttribute("On", "uninstall");
- fileDefinitions.EndElement("RemoveFolder");
std::string registryKey =
std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
- fileDefinitions.BeginElement("RegistryValue");
- fileDefinitions.AddAttribute("Root", "HKCU");
- fileDefinitions.AddAttribute("Key", registryKey);
-
- std::string valueName;
- if(!cpackComponentName.empty())
- {
- valueName = cpackComponentName + "_";
- }
- valueName += "installed";
-
- fileDefinitions.AddAttribute("Name", valueName);
- fileDefinitions.AddAttribute("Type", "integer");
- fileDefinitions.AddAttribute("Value", "1");
- fileDefinitions.AddAttribute("KeyPath", "yes");
- fileDefinitions.EndElement("RegistryValue");
+ fileDefinitions.EmitStartMenuShortcutRegistryValue(
+ registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
- if (thisHasDesktopShortcuts)
+ if(thisHasDesktopShortcuts)
{
this->HasDesktopShortcuts = true;
componentId = "CM_DESKTOP_SHORTCUT" + idSuffix;
@@ -876,7 +728,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
- for (shortcut_map_t::const_iterator
+ for(shortcut_map_t::const_iterator
i = shortcutMap.begin(); i != shortcutMap.end(); ++i)
{
std::string const& id = i->first;
@@ -885,34 +737,16 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
if (!shortcut.desktop)
continue;
- std::string shortcutId = std::string("CM_DS") + id;
- std::string fileId = std::string("CM_F") + id;
-
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", shortcutId);
- fileDefinitions.AddAttribute("Name", shortcut.textLabel);
- std::string target = "[#" + fileId + "]";
- fileDefinitions.AddAttribute("Target", target);
- fileDefinitions.AddAttribute("WorkingDirectory",
- shortcut.workingDirectoryId);
- fileDefinitions.EndElement("Shortcut");
+ fileDefinitions.EmitShortcut(id, shortcut, true);
}
- fileDefinitions.BeginElement("RegistryValue");
- fileDefinitions.AddAttribute("Root", "HKCU");
- fileDefinitions.AddAttribute("Key", registryKey);
- fileDefinitions.AddAttribute("Name", valueName + "_desktop");
- fileDefinitions.AddAttribute("Type", "integer");
- fileDefinitions.AddAttribute("Value", "1");
- fileDefinitions.AddAttribute("KeyPath", "yes");
- fileDefinitions.EndElement("RegistryValue");
+ fileDefinitions.EmitDesktopShortcutRegistryValue(
+ registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
}
featureDefinitions.EndElement("FeatureRef");
@@ -920,19 +754,6 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
return true;
}
-void cmCPackWIXGenerator::CreateUninstallShortcut(
- std::string const& packageName,
- cmWIXSourceWriter& fileDefinitions)
-{
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", "UNINSTALL");
- fileDefinitions.AddAttribute("Name", "Uninstall " + packageName);
- fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName);
- fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe");
- fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]");
- fileDefinitions.EndElement("Shortcut");
-}
-
bool cmCPackWIXGenerator::CreateLicenseFile()
{
std::string licenseSourceFilename;
@@ -981,11 +802,11 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
}
void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
- const std::string& topdir,
- const std::string& directoryId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ std::string const& topdir,
+ std::string const& directoryId,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& packageExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap)
@@ -993,6 +814,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
cmsys::Directory dir;
dir.Load(topdir.c_str());
+ if(dir.GetNumberOfFiles() == 2)
+ {
+ std::string componentId = fileDefinitions.EmitComponentCreateFolder(
+ directoryId, GenerateGUID());
+
+ featureDefinitions.EmitComponentRef(componentId);
+
+ return;
+ }
+
for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
{
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
@@ -1026,44 +857,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
desktopExecutables,
shortcutMap);
- ApplyPatchFragment(subDirectoryId, directoryDefinitions);
+ this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory");
}
else
{
- std::string componentId = std::string("CM_C") + id;
- std::string fileId = std::string("CM_F") + id;
-
- fileDefinitions.BeginElement("DirectoryRef");
- fileDefinitions.AddAttribute("Id", directoryId);
-
- fileDefinitions.BeginElement("Component");
- fileDefinitions.AddAttribute("Id", componentId);
- fileDefinitions.AddAttribute("Guid", "*");
+ std::string componentId = fileDefinitions.EmitComponentFile(
+ directoryId, id, fullPath, this->Patch);
- fileDefinitions.BeginElement("File");
- fileDefinitions.AddAttribute("Id", fileId);
- fileDefinitions.AddAttribute("Source", fullPath);
- fileDefinitions.AddAttribute("KeyPath", "yes");
-
- mode_t fileMode = 0;
- cmSystemTools::GetPermissions(fullPath.c_str(), fileMode);
-
- if(!(fileMode & S_IWRITE))
- {
- fileDefinitions.AddAttribute("ReadOnly", "yes");
- }
-
- ApplyPatchFragment(fileId, fileDefinitions);
- fileDefinitions.EndElement("File");
-
- ApplyPatchFragment(componentId, fileDefinitions);
- fileDefinitions.EndElement("Component");
- fileDefinitions.EndElement("DirectoryRef");
-
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
for(size_t j = 0; j < packageExecutables.size(); ++j)
{
@@ -1092,7 +894,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
}
bool cmCPackWIXGenerator::RequireOption(
- const std::string& name, std::string &value) const
+ std::string const& name, std::string &value) const
{
const char* tmp = GetOption(name.c_str());
if(tmp)
@@ -1140,13 +942,13 @@ std::string cmCPackWIXGenerator::GenerateGUID()
return cmSystemTools::UpperCase(result);
}
-std::string cmCPackWIXGenerator::QuotePath(const std::string& path)
+std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
{
return std::string("\"") + path + '"';
}
std::string cmCPackWIXGenerator::GetRightmostExtension(
- const std::string& filename)
+ std::string const& filename)
{
std::string extension;
@@ -1159,7 +961,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
return cmSystemTools::LowerCase(extension);
}
-std::string cmCPackWIXGenerator::PathToId(const std::string& path)
+std::string cmCPackWIXGenerator::PathToId(std::string const& path)
{
id_map_t::const_iterator i = PathToIdMap.find(path);
if(i != PathToIdMap.end()) return i->second;
@@ -1168,7 +970,7 @@ std::string cmCPackWIXGenerator::PathToId(const std::string& path)
return id;
}
-std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
+std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
{
std::vector<std::string> components;
cmSystemTools::SplitPath(path.c_str(), components, false);
@@ -1222,7 +1024,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
}
std::string cmCPackWIXGenerator::CreateHashedId(
- const std::string& path, const std::string& normalizedFilename)
+ std::string const& path, std::string const& normalizedFilename)
{
cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1");
std::string hash = sha1->HashString(path.c_str());
@@ -1245,7 +1047,7 @@ std::string cmCPackWIXGenerator::CreateHashedId(
}
std::string cmCPackWIXGenerator::NormalizeComponentForId(
- const std::string& component, size_t& replacementCount)
+ std::string const& component, size_t& replacementCount)
{
std::string result;
result.resize(component.size());
@@ -1276,7 +1078,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
}
void cmCPackWIXGenerator::CollectExtensions(
- const std::string& variableName, extension_set_t& extensions)
+ std::string const& variableName, extension_set_t& extensions)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@@ -1292,7 +1094,7 @@ void cmCPackWIXGenerator::CollectExtensions(
}
void cmCPackWIXGenerator::AddCustomFlags(
- const std::string& variableName, std::ostream& stream)
+ std::string const& variableName, std::ostream& stream)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@@ -1306,69 +1108,3 @@ void cmCPackWIXGenerator::AddCustomFlags(
stream << " " << QuotePath(*i);
}
}
-
-void cmCPackWIXGenerator::CreateStartMenuFolder(
- cmWIXSourceWriter& directoryDefinitions)
-{
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder");
-
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
- const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- directoryDefinitions.AddAttribute("Name", startMenuFolder);
- directoryDefinitions.EndElement("Directory");
-
- directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::CreateDesktopFolder(
- cmWIXSourceWriter& directoryDefinitions)
-{
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "DesktopFolder");
- directoryDefinitions.AddAttribute("Name", "Desktop");
- directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
-{
- cmWIXPatchParser parser(Fragments, Logger);
- parser.ParseFile(patchFilePath.c_str());
-}
-
-void cmCPackWIXGenerator::ApplyPatchFragment(
- const std::string& id, cmWIXSourceWriter& writer)
-{
- cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
- if(i == Fragments.end()) return;
-
- const cmWIXPatchElement& fragment = i->second;
- for(cmWIXPatchElement::child_list_t::const_iterator
- j = fragment.children.begin(); j != fragment.children.end(); ++j)
- {
- ApplyPatchElement(**j, writer);
- }
-
- Fragments.erase(i);
-}
-
-void cmCPackWIXGenerator::ApplyPatchElement(
- const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
-{
- writer.BeginElement(element.name);
-
- for(cmWIXPatchElement::attributes_t::const_iterator
- i = element.attributes.begin(); i != element.attributes.end(); ++i)
- {
- writer.AddAttribute(i->first, i->second);
- }
-
- for(cmWIXPatchElement::child_list_t::const_iterator
- i = element.children.begin(); i != element.children.end(); ++i)
- {
- ApplyPatchElement(**i, writer);
- }
-
- writer.EndElement(element.name);
-}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 1de4810..4c9f8c7 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -13,25 +13,18 @@
#ifndef cmCPackWIXGenerator_h
#define cmCPackWIXGenerator_h
-#include "cmWIXPatchParser.h"
+#include "cmWIXPatch.h"
+#include "cmWIXShortcut.h"
#include <CPack/cmCPackGenerator.h>
#include <string>
#include <map>
-struct cmWIXShortcut
-{
- cmWIXShortcut()
- :desktop(false)
- {}
-
- std::string textLabel;
- std::string workingDirectoryId;
- bool desktop;
-};
-
class cmWIXSourceWriter;
+class cmWIXDirectoriesSourceWriter;
+class cmWIXFilesSourceWriter;
+class cmWIXFeaturesSourceWriter;
/** \class cmCPackWIXGenerator
* \brief A generator for WIX files
@@ -78,48 +71,39 @@ private:
bool PackageFilesImpl();
- bool CreateWiXVariablesIncludeFile();
+ void CreateWiXVariablesIncludeFile();
+
+ void CreateWiXPropertiesIncludeFile();
void CopyDefinition(
- cmWIXSourceWriter &source, const std::string &name);
+ cmWIXSourceWriter &source, std::string const& name);
void AddDefinition(cmWIXSourceWriter& source,
- const std::string& name, const std::string& value);
+ std::string const& name, std::string const& value);
bool CreateWiXSourceFiles();
- bool CreateCMakePackageRegistryEntry(
- cmWIXSourceWriter& featureDefinitions);
+ std::string GetProgramFilesFolderId() const;
- bool CreateFeatureHierarchy(
- cmWIXSourceWriter& featureDefinitions);
-
- bool EmitFeatureForComponentGroup(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponentGroup const& group);
+ bool GenerateMainSourceFileFromTemplate();
- bool EmitFeatureForComponent(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponent const& component);
+ bool CreateFeatureHierarchy(
+ cmWIXFeaturesSourceWriter& featureDefinitions);
bool AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap);
bool CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions);
-
- void CreateUninstallShortcut(
- std::string const& packageName,
- cmWIXSourceWriter& fileDefinitions);
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions);
void AppendUserSuppliedExtraSources();
@@ -127,60 +111,49 @@ private:
bool CreateLicenseFile();
- bool RunWiXCommand(const std::string& command);
+ bool RunWiXCommand(std::string const& command);
bool RunCandleCommand(
- const std::string& sourceFile, const std::string& objectFile);
+ std::string const& sourceFile, std::string const& objectFile);
- bool RunLightCommand(const std::string& objectFiles);
+ bool RunLightCommand(std::string const& objectFiles);
- void AddDirectoryAndFileDefinitons(const std::string& topdir,
- const std::string& directoryId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ void AddDirectoryAndFileDefinitons(std::string const& topdir,
+ std::string const& directoryId,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& pkgExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap);
- bool RequireOption(const std::string& name, std::string& value) const;
+ bool RequireOption(std::string const& name, std::string& value) const;
std::string GetArchitecture() const;
static std::string GenerateGUID();
- static std::string QuotePath(const std::string& path);
+ static std::string QuotePath(std::string const& path);
- static std::string GetRightmostExtension(const std::string& filename);
+ static std::string GetRightmostExtension(std::string const& filename);
- std::string PathToId(const std::string& path);
+ std::string PathToId(std::string const& path);
- std::string CreateNewIdForPath(const std::string& path);
+ std::string CreateNewIdForPath(std::string const& path);
static std::string CreateHashedId(
- const std::string& path, const std::string& normalizedFilename);
+ std::string const& path, std::string const& normalizedFilename);
std::string NormalizeComponentForId(
- const std::string& component, size_t& replacementCount);
+ std::string const& component, size_t& replacementCount);
static bool IsLegalIdCharacter(char c);
void CollectExtensions(
- const std::string& variableName, extension_set_t& extensions);
+ std::string const& variableName, extension_set_t& extensions);
void AddCustomFlags(
- const std::string& variableName, std::ostream& stream);
-
- void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
-
- void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions);
-
- void LoadPatchFragments(const std::string& patchFilePath);
-
- void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
-
- void ApplyPatchElement(const cmWIXPatchElement& element,
- cmWIXSourceWriter& writer);
+ std::string const& variableName, std::ostream& stream);
std::vector<std::string> WixSources;
id_map_t PathToIdMap;
@@ -189,9 +162,11 @@ private:
extension_set_t CandleExtensions;
extension_set_t LightExtensions;
- cmWIXPatchParser::fragment_map_t Fragments;
-
bool HasDesktopShortcuts;
+
+ std::string CPackTopLevel;
+
+ cmWIXPatch Patch;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
new file mode 100644
index 0000000..a93f89b
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -0,0 +1,87 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 "cmWIXDirectoriesSourceWriter.h"
+
+cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
+ std::string const& startMenuFolder)
+{
+ BeginElement("Directory");
+ AddAttribute("Id", "ProgramMenuFolder");
+
+ BeginElement("Directory");
+ AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+ AddAttribute("Name", startMenuFolder);
+ EndElement("Directory");
+
+ EndElement("Directory");
+}
+
+void cmWIXDirectoriesSourceWriter::EmitDesktopFolder()
+{
+ BeginElement("Directory");
+ AddAttribute("Id", "DesktopFolder");
+ AddAttribute("Name", "Desktop");
+ EndElement("Directory");
+}
+
+size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
+ std::string const& programFilesFolderId,
+ std::string const& installRootString)
+{
+ BeginElement("Directory");
+ AddAttribute("Id", programFilesFolderId);
+
+ std::vector<std::string> installRoot;
+
+ cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
+
+ if(!installRoot.empty() && installRoot.back().empty())
+ {
+ installRoot.pop_back();
+ }
+
+ for(size_t i = 1; i < installRoot.size(); ++i)
+ {
+ BeginElement("Directory");
+
+ if(i == installRoot.size() - 1)
+ {
+ AddAttribute("Id", "INSTALL_ROOT");
+ }
+ else
+ {
+ std::stringstream tmp;
+ tmp << "INSTALL_PREFIX_" << i;
+ AddAttribute("Id", tmp.str());
+ }
+
+ AddAttribute("Name", installRoot[i]);
+ }
+
+ return installRoot.size();
+}
+
+void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
+{
+ for(size_t i = 0; i < size; ++i)
+ {
+ EndElement("Directory");
+ }
+}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
new file mode 100644
index 0000000..f51fdb4
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -0,0 +1,42 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 cmWIXDirectoriesSourceWriter_h
+#define cmWIXDirectoriesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+#include <string>
+
+/** \class cmWIXDirectoriesSourceWriter
+ * \brief Helper class to generate directories.wxs
+ */
+class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void EmitStartMenuFolder(std::string const& startMenuFolder);
+
+ void EmitDesktopFolder();
+
+ size_t BeginInstallationPrefixDirectory(
+ std::string const& programFilesFolderId,
+ std::string const& installRootString);
+
+ void EndInstallationPrefixDirectory(size_t size);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
new file mode 100644
index 0000000..0bcfc38
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -0,0 +1,102 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 "cmWIXFeaturesSourceWriter.h"
+
+cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
+ std::string const& package,
+ std::string const& upgradeGuid)
+{
+ BeginElement("Component");
+ AddAttribute("Id", "CM_PACKAGE_REGISTRY");
+ AddAttribute("Directory", "TARGETDIR");
+ AddAttribute("Guid", "*");
+
+ std::string registryKey =
+ std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+
+ BeginElement("RegistryValue");
+ AddAttribute("Root", "HKLM");
+ AddAttribute("Key", registryKey);
+ AddAttribute("Name", upgradeGuid);
+ AddAttribute("Type", "string");
+ AddAttribute("Value", "[INSTALL_ROOT]");
+ AddAttribute("KeyPath", "yes");
+ EndElement("RegistryValue");
+
+ EndElement("Component");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
+ cmCPackComponentGroup const& group)
+{
+ BeginElement("Feature");
+ AddAttribute("Id", "CM_G_" + group.Name);
+
+ if(group.IsExpandedByDefault)
+ {
+ AddAttribute("Display", "expand");
+ }
+
+ AddAttributeUnlessEmpty("Title", group.DisplayName);
+ AddAttributeUnlessEmpty("Description", group.Description);
+
+ for(std::vector<cmCPackComponentGroup*>::const_iterator
+ i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
+ {
+ EmitFeatureForComponentGroup(**i);
+ }
+
+ for(std::vector<cmCPackComponent*>::const_iterator
+ i = group.Components.begin(); i != group.Components.end(); ++i)
+ {
+ EmitFeatureForComponent(**i);
+ }
+
+ EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
+ cmCPackComponent const& component)
+{
+ BeginElement("Feature");
+ AddAttribute("Id", "CM_C_" + component.Name);
+
+ AddAttributeUnlessEmpty("Title", component.DisplayName);
+ AddAttributeUnlessEmpty("Description", component.Description);
+
+ if(component.IsRequired)
+ {
+ AddAttribute("Absent", "disallow");
+ }
+
+ if(component.IsHidden)
+ {
+ AddAttribute("Display", "hidden");
+ }
+
+ EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
+{
+ BeginElement("ComponentRef");
+ AddAttribute("Id", id);
+ EndElement("ComponentRef");
+}
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
new file mode 100644
index 0000000..7670417
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -0,0 +1,39 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 cmWIXFeaturesSourceWriter_h
+#define cmWIXFeaturesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFeaturesSourceWriter
+ * \brief Helper class to generate features.wxs
+ */
+class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void CreateCMakePackageRegistryEntry(
+ std::string const& package,
+ std::string const& upgradeGuid);
+
+ void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
+
+ void EmitFeatureForComponent(const cmCPackComponent& component);
+
+ void EmitComponentRef(std::string const& id);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
new file mode 100644
index 0000000..3fd959e
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -0,0 +1,171 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 "cmWIXFilesSourceWriter.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFilesSourceWriter::EmitShortcut(
+ std::string const& id,
+ cmWIXShortcut const& shortcut,
+ bool desktop)
+{
+ std::string shortcutId;
+
+ if(desktop)
+ {
+ shortcutId = "CM_DS";
+ }
+ else
+ {
+ shortcutId = "CM_S";
+ }
+
+ shortcutId += id;
+
+ std::string fileId = std::string("CM_F") + id;
+
+ BeginElement("Shortcut");
+ AddAttribute("Id", shortcutId);
+ AddAttribute("Name", shortcut.textLabel);
+ std::string target = "[#" + fileId + "]";
+ AddAttribute("Target", target);
+ AddAttribute("WorkingDirectory", shortcut.workingDirectoryId);
+ EndElement("Shortcut");
+}
+
+void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
+{
+ BeginElement("RemoveFolder");
+ AddAttribute("Id", id);
+ AddAttribute("On", "uninstall");
+ EndElement("RemoveFolder");
+}
+
+void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName)
+{
+ EmitInstallRegistryValue(registryKey, cpackComponentName, std::string());
+}
+
+void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName)
+{
+ EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop");
+}
+
+void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName,
+ std::string const& suffix)
+{
+ std::string valueName;
+ if(!cpackComponentName.empty())
+ {
+ valueName = cpackComponentName + "_";
+ }
+
+ valueName += "installed";
+ valueName += suffix;
+
+ BeginElement("RegistryValue");
+ AddAttribute("Root", "HKCU");
+ AddAttribute("Key", registryKey);
+ AddAttribute("Name", valueName);
+ AddAttribute("Type", "integer");
+ AddAttribute("Value", "1");
+ AddAttribute("KeyPath", "yes");
+ EndElement("RegistryValue");
+}
+
+void cmWIXFilesSourceWriter::EmitUninstallShortcut(
+ std::string const& packageName)
+{
+ BeginElement("Shortcut");
+ AddAttribute("Id", "UNINSTALL");
+ AddAttribute("Name", "Uninstall " + packageName);
+ AddAttribute("Description", "Uninstalls " + packageName);
+ AddAttribute("Target", "[SystemFolder]msiexec.exe");
+ AddAttribute("Arguments", "/x [ProductCode]");
+ EndElement("Shortcut");
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
+ std::string const& directoryId, std::string const& guid)
+{
+ std::string componentId =
+ std::string("CM_C_EMPTY_") + directoryId;
+
+ BeginElement("DirectoryRef");
+ AddAttribute("Id", directoryId);
+
+ BeginElement("Component");
+ AddAttribute("Id", componentId);
+ AddAttribute("Guid", guid);
+
+ BeginElement("CreateFolder");
+
+ EndElement("CreateFolder");
+ EndElement("Component");
+ EndElement("DirectoryRef");
+
+ return componentId;
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentFile(
+ std::string const& directoryId,
+ std::string const& id,
+ std::string const& filePath,
+ cmWIXPatch &patch)
+{
+ std::string componentId = std::string("CM_C") + id;
+ std::string fileId = std::string("CM_F") + id;
+
+ BeginElement("DirectoryRef");
+ AddAttribute("Id", directoryId);
+
+ BeginElement("Component");
+ AddAttribute("Id", componentId);
+ AddAttribute("Guid", "*");
+
+ BeginElement("File");
+ AddAttribute("Id", fileId);
+ AddAttribute("Source", filePath);
+ AddAttribute("KeyPath", "yes");
+
+ mode_t fileMode = 0;
+ cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
+
+ if(!(fileMode & S_IWRITE))
+ {
+ AddAttribute("ReadOnly", "yes");
+ }
+
+ patch.ApplyFragment(fileId, *this);
+ EndElement("File");
+
+ patch.ApplyFragment(componentId, *this);
+ EndElement("Component");
+ EndElement("DirectoryRef");
+
+ return componentId;
+}
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
new file mode 100644
index 0000000..13122c2
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -0,0 +1,66 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 cmWIXFilesSourceWriter_h
+#define cmWIXFilesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXShortcut.h"
+#include "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFilesSourceWriter
+ * \brief Helper class to generate files.wxs
+ */
+class cmWIXFilesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXFilesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void EmitShortcut(
+ std::string const& id,
+ cmWIXShortcut const& shortcut,
+ bool desktop);
+
+ void EmitRemoveFolder(std::string const& id);
+
+ void EmitStartMenuShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName);
+
+ void EmitDesktopShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName);
+
+ void EmitUninstallShortcut(std::string const& packageName);
+
+ std::string EmitComponentCreateFolder(
+ std::string const& directoryId,
+ std::string const& guid);
+
+ std::string EmitComponentFile(
+ std::string const& directoryId,
+ std::string const& id,
+ std::string const& filePath,
+ cmWIXPatch &patch);
+
+private:
+ void EmitInstallRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName,
+ std::string const& suffix);
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
new file mode 100644
index 0000000..b5202e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -0,0 +1,91 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
+ Logger(logger)
+{
+
+}
+
+void cmWIXPatch::LoadFragments(std::string const& patchFilePath)
+{
+ cmWIXPatchParser parser(Fragments, Logger);
+ parser.ParseFile(patchFilePath.c_str());
+}
+
+void cmWIXPatch::ApplyFragment(
+ std::string const& id, cmWIXSourceWriter& writer)
+{
+ cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
+ if(i == Fragments.end()) return;
+
+ const cmWIXPatchElement& fragment = i->second;
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ j = fragment.children.begin(); j != fragment.children.end(); ++j)
+ {
+ ApplyElement(**j, writer);
+ }
+
+ Fragments.erase(i);
+}
+
+void cmWIXPatch::ApplyElement(
+ const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+{
+ writer.BeginElement(element.name);
+
+ for(cmWIXPatchElement::attributes_t::const_iterator
+ i = element.attributes.begin(); i != element.attributes.end(); ++i)
+ {
+ writer.AddAttribute(i->first, i->second);
+ }
+
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ i = element.children.begin(); i != element.children.end(); ++i)
+ {
+ ApplyElement(**i, writer);
+ }
+
+ writer.EndElement(element.name);
+}
+
+
+bool cmWIXPatch::CheckForUnappliedFragments()
+{
+ std::string fragmentList;
+ for(cmWIXPatchParser::fragment_map_t::const_iterator
+ i = Fragments.begin(); i != Fragments.end(); ++i)
+ {
+ if(!fragmentList.empty())
+ {
+ fragmentList += ", ";
+ }
+
+ fragmentList += "'";
+ fragmentList += i->first;
+ fragmentList += "'";
+ }
+
+ if(fragmentList.size())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Some XML patch fragments did not have matching IDs: " <<
+ fragmentList << std::endl);
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h
new file mode 100644
index 0000000..7b7b2f1
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -0,0 +1,45 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 cmWIXPatch_h
+#define cmWIXPatch_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXPatchParser.h"
+
+#include <string>
+
+/** \class cmWIXPatch
+ * \brief Class that maintains and applies patch fragments
+ */
+class cmWIXPatch
+{
+public:
+ cmWIXPatch(cmCPackLog* logger);
+
+ void LoadFragments(std::string const& patchFilePath);
+
+ void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer);
+
+ bool CheckForUnappliedFragments();
+
+private:
+ void ApplyElement(const cmWIXPatchElement& element,
+ cmWIXSourceWriter& writer);
+
+ cmCPackLog* Logger;
+
+ cmWIXPatchParser::fragment_map_t Fragments;
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 7ceaf1f..10af1f6 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -132,7 +132,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
Valid = false;
}
-void cmWIXPatchParser::ReportValidationError(const std::string& message)
+void cmWIXPatchParser::ReportValidationError(std::string const& message)
{
ReportError(XML_GetCurrentLineNumber(Parser),
XML_GetCurrentColumnNumber(Parser),
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index 91b3b66..da3adf5 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -50,7 +50,7 @@ private:
virtual void EndElement(const char *name);
virtual void ReportError(int line, int column, const char* msg);
- void ReportValidationError(const std::string& message);
+ void ReportValidationError(std::string const& message);
bool IsValid() const;
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index ddc1d71..f27caa9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,7 +15,7 @@
#include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
- const std::string& filename):
+ std::string const& filename):
File(filename.c_str(), std::ios::binary)
{
StartGroup();
@@ -33,7 +33,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
File.put(0);
}
-void cmWIXRichTextFormatWriter::AddText(const std::string& text)
+void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
typedef unsigned char rtf_byte_t;
@@ -167,12 +167,12 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
ControlWord("fs20");
}
-void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
{
File << "\\" << keyword;
}
-void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
{
File << "\\*\\" << keyword;
}
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index 2b665d4..f6327fb 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -22,10 +22,10 @@
class cmWIXRichTextFormatWriter
{
public:
- cmWIXRichTextFormatWriter(const std::string& filename);
+ cmWIXRichTextFormatWriter(std::string const& filename);
~cmWIXRichTextFormatWriter();
- void AddText(const std::string& text);
+ void AddText(std::string const& text);
private:
void WriteHeader();
@@ -35,8 +35,8 @@ private:
void WriteDocumentPrefix();
- void ControlWord(const std::string& keyword);
- void NewControlWord(const std::string& keyword);
+ void ControlWord(std::string const& keyword);
+ void NewControlWord(std::string const& keyword);
void StartGroup();
void EndGroup();
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
new file mode 100644
index 0000000..93095e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -0,0 +1,29 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Kitware, Inc.
+
+ 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 cmWIXFilesShortcut_h
+#define cmWIXFilesShortcut_h
+
+#include <string>
+
+struct cmWIXShortcut
+{
+ cmWIXShortcut()
+ :desktop(false)
+ {}
+
+ std::string textLabel;
+ std::string workingDirectoryId;
+ bool desktop;
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index e83c226..aad19da 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -17,7 +17,7 @@
#include <windows.h>
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
- const std::string& filename,
+ std::string const& filename,
bool isIncludeFile):
Logger(logger),
File(filename.c_str()),
@@ -51,7 +51,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
EndElement(Elements.back());
}
-void cmWIXSourceWriter::BeginElement(const std::string& name)
+void cmWIXSourceWriter::BeginElement(std::string const& name)
{
if(State == BEGIN)
{
@@ -101,7 +101,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
}
void cmWIXSourceWriter::AddProcessingInstruction(
- const std::string& target, const std::string& content)
+ std::string const& target, std::string const& content)
{
if(State == BEGIN)
{
@@ -116,7 +116,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(
}
void cmWIXSourceWriter::AddAttribute(
- const std::string& key, const std::string& value)
+ std::string const& key, std::string const& value)
{
std::string utf8 = WindowsCodepageToUtf8(value);
@@ -124,7 +124,7 @@ void cmWIXSourceWriter::AddAttribute(
}
void cmWIXSourceWriter::AddAttributeUnlessEmpty(
- const std::string& key, const std::string& value)
+ std::string const& key, std::string const& value)
{
if(value.size())
{
@@ -132,7 +132,7 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty(
}
}
-std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
+std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value)
{
if(value.empty())
{
@@ -184,7 +184,7 @@ void cmWIXSourceWriter::Indent(size_t count)
}
std::string cmWIXSourceWriter::EscapeAttributeValue(
- const std::string& value)
+ std::string const& value)
{
std::string result;
result.reserve(value.size());
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 894ad78..65b7240 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -26,24 +26,24 @@ class cmWIXSourceWriter
{
public:
cmWIXSourceWriter(cmCPackLog* logger,
- const std::string& filename, bool isIncludeFile = false);
+ std::string const& filename, bool isIncludeFile = false);
~cmWIXSourceWriter();
- void BeginElement(const std::string& name);
+ void BeginElement(std::string const& name);
- void EndElement(const std::string& name);
+ void EndElement(std::string const& name);
void AddProcessingInstruction(
- const std::string& target, const std::string& content);
+ std::string const& target, std::string const& content);
void AddAttribute(
- const std::string& key, const std::string& value);
+ std::string const& key, std::string const& value);
void AddAttributeUnlessEmpty(
- const std::string& key, const std::string& value);
+ std::string const& key, std::string const& value);
- static std::string WindowsCodepageToUtf8(const std::string& value);
+ static std::string WindowsCodepageToUtf8(std::string const& value);
private:
enum State
@@ -56,7 +56,7 @@ private:
void Indent(size_t count);
- static std::string EscapeAttributeValue(const std::string& value);
+ static std::string EscapeAttributeValue(std::string const& value);
cmCPackLog* Logger;
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 96491aa..e1dd4e9 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -1202,6 +1202,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const
}
//----------------------------------------------------------------------
+std::vector<std::string> cmCPackGenerator::GetOptions() const
+{
+ return this->MakefileMap->GetDefinitions();
+}
+
+//----------------------------------------------------------------------
int cmCPackGenerator::PackageFiles()
{
return 0;
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index bb33aa0..b1a7840 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -102,6 +102,7 @@ public:
void SetOption(const char* op, const char* value);
void SetOptionIfNotSet(const char* op, const char* value);
const char* GetOption(const char* op) const;
+ std::vector<std::string> GetOptions() const;
bool IsSet(const char* name) const;
bool IsOn(const char* name) const;
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3c65c55..0503d94 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -871,6 +871,12 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
{
std::string gcovCommand
= this->CTest->GetCTestConfiguration("CoverageCommand");
+ if (gcovCommand.empty())
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not find gcov." << std::endl);
+ return 0;
+ }
std::string gcovExtraFlags
= this->CTest->GetCTestConfiguration("CoverageExtraFlags");
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4266dd0..b86a956 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1228,7 +1228,8 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
- std::string const& result)
+ std::string const& result,
+ OutputFormat format)
{
// If this is a windows shell, the result has a space, and the path
// already exists, we can use a short-path to reference it without a
@@ -1239,7 +1240,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
std::string tmp;
if(cmSystemTools::GetShortPath(remote, tmp))
{
- return this->Convert(tmp.c_str(), NONE, SHELL, true);
+ return this->Convert(tmp.c_str(), NONE, format, true);
}
}
@@ -1250,33 +1251,36 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToOutputForExisting(const char* remote,
- RelativeRoot local)
+ RelativeRoot local,
+ OutputFormat format)
{
// Perform standard conversion.
- std::string result = this->Convert(remote, local, SHELL, true);
+ std::string result = this->Convert(remote, local, format, true);
// Consider short-path.
- return this->ConvertToOutputForExistingCommon(remote, result);
+ return this->ConvertToOutputForExistingCommon(remote, result, format);
}
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
- const char* local)
+ const char* local,
+ OutputFormat format)
{
// Perform standard conversion.
- std::string result = this->Convert(remote, local, SHELL, true);
+ std::string result = this->Convert(remote, local, format, true);
// Consider short-path.
const char* remotePath = this->GetRelativeRootPath(remote);
- return this->ConvertToOutputForExistingCommon(remotePath, result);
+ return this->ConvertToOutputForExistingCommon(remotePath, result, format);
}
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
+ OutputFormat format)
{
- return this->ConvertToOutputForExisting(path.c_str());
+ return this->ConvertToOutputForExisting(path.c_str(), START_OUTPUT, format);
}
//----------------------------------------------------------------------------
@@ -1291,6 +1295,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
return "";
}
+ OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
cmOStringStream includeFlags;
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
@@ -1350,10 +1355,9 @@ std::string cmLocalGenerator::GetIncludeFlags(
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
if(emitted.insert(frameworkDir).second)
{
- OutputFormat format = forResponseFile? RESPONSE : SHELL;
includeFlags
<< fwSearchFlag << this->Convert(frameworkDir.c_str(),
- START_OUTPUT, format, true)
+ START_OUTPUT, shellFormat, true)
<< " ";
}
continue;
@@ -1372,16 +1376,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
flagUsed = true;
}
- std::string includePath;
- if(forResponseFile)
- {
- includePath = this->Convert(i->c_str(), START_OUTPUT,
- RESPONSE, true);
- }
- else
- {
- includePath = this->ConvertToIncludeReference(*i);
- }
+ std::string includePath =
+ this->ConvertToIncludeReference(*i, shellFormat);
if(quotePaths && includePath.size() && includePath[0] != '\"')
{
includeFlags << "\"";
@@ -1675,7 +1671,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
}
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *target, false);
+ *target, false, false);
}
break;
case cmTarget::EXECUTABLE:
@@ -1700,7 +1696,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *target, false);
+ *target, false, false);
if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{
@@ -1755,7 +1751,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
}
-std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
+std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
+ OutputFormat format)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
// Work-ardound command line parsing limitations in MSVC 6.0 and
@@ -1777,14 +1774,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
sp += lib.substr(pos);
// Convert to an output path.
- return this->Convert(sp.c_str(), NONE, SHELL);
+ return this->Convert(sp.c_str(), NONE, format);
}
}
}
#endif
// Normal behavior.
- return this->Convert(lib.c_str(), START_OUTPUT, SHELL);
+ return this->Convert(lib.c_str(), START_OUTPUT, format);
}
/**
@@ -1796,8 +1793,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget &tgt,
- bool relink)
+ bool relink,
+ bool forResponseFile)
{
+ OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
+ bool escapeAllowMakeVars = !forResponseFile;
cmOStringStream fout;
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
@@ -1840,7 +1840,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
fdi != fwDirs.end(); ++fdi)
{
frameworkPath += fwSearchFlag;
- frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
+ frameworkPath += this->Convert(fdi->c_str(), NONE, shellFormat, false);
frameworkPath += " ";
}
}
@@ -1850,7 +1850,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
libDir != libDirs.end(); ++libDir)
{
- std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
+ std::string libpath = this->ConvertToOutputForExisting(libDir->c_str(),
+ START_OUTPUT,
+ shellFormat);
linkPath += " " + libPathFlag;
linkPath += libpath;
linkPath += libPathTerminator;
@@ -1868,7 +1870,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
}
if(li->IsPath)
{
- linkLibs += this->ConvertToLinkReference(li->Value);
+ linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
}
else
{
@@ -1893,7 +1895,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
ri != runtimeDirs.end(); ++ri)
{
rpath += cli.GetRuntimeFlag();
- rpath += this->Convert(ri->c_str(), NONE, SHELL, false);
+ rpath += this->Convert(ri->c_str(), NONE, shellFormat, false);
rpath += " ";
}
fout << rpath;
@@ -1907,7 +1909,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!rpath.empty())
{
fout << cli.GetRuntimeFlag();
- fout << this->EscapeForShell(rpath.c_str(), true);
+ fout << this->EscapeForShell(rpath.c_str(), escapeAllowMakeVars);
fout << " ";
}
}
@@ -1917,7 +1919,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
{
fout << cli.GetRPathLinkFlag();
- fout << this->EscapeForShell(rpath_link.c_str(), true);
+ fout << this->EscapeForShell(rpath_link.c_str(), escapeAllowMakeVars);
fout << " ";
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 0f7fd25..2e05804 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -198,14 +198,17 @@ public:
///! for existing files convert to output path and short path if spaces
std::string ConvertToOutputForExisting(const char* remote,
- RelativeRoot local = START_OUTPUT);
+ RelativeRoot local = START_OUTPUT,
+ OutputFormat format = SHELL);
/** For existing path identified by RelativeRoot convert to output
path and short path if spaces. */
std::string ConvertToOutputForExisting(RelativeRoot remote,
- const char* local = 0);
+ const char* local = 0,
+ OutputFormat format = SHELL);
- virtual std::string ConvertToIncludeReference(std::string const& path);
+ virtual std::string ConvertToIncludeReference(std::string const& path,
+ OutputFormat format = SHELL);
/** Called from command-line hook to clear dependencies. */
virtual void ClearDependencies(cmMakefile* /* mf */,
@@ -369,7 +372,8 @@ protected:
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget &,
- bool relink);
+ bool relink,
+ bool forResponseFile);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,
@@ -412,7 +416,8 @@ protected:
std::string FindRelativePathTopBinary();
void SetupPathConversions();
- virtual std::string ConvertToLinkReference(std::string const& lib);
+ virtual std::string ConvertToLinkReference(std::string const& lib,
+ OutputFormat format = SHELL);
/** Check whether the native build system supports the given
definition. Issues a warning. */
@@ -465,7 +470,8 @@ protected:
bool BackwardsCompatibilityFinal;
private:
std::string ConvertToOutputForExistingCommon(const char* remote,
- std::string const& result);
+ std::string const& result,
+ OutputFormat format);
void AddSharedFlags(std::string& flags, const char* lang, bool shared);
bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cd12c9d..862823f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -143,15 +143,17 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
// Virtual protected methods.
std::string
-cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib)
+cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib,
+ OutputFormat format)
{
- return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL);
+ return this->Convert(lib.c_str(), HOME_OUTPUT, format);
}
std::string
-cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path,
+ OutputFormat format)
{
- return this->Convert(path.c_str(), HOME_OUTPUT, SHELL);
+ return this->Convert(path.c_str(), HOME_OUTPUT, format);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index ea854c6..8b26806 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -97,11 +97,13 @@ public:
void AppendCustomCommandDeps(const cmCustomCommand *cc,
cmNinjaDeps &ninjaDeps);
- virtual std::string ConvertToLinkReference(std::string const& lib);
+ virtual std::string ConvertToLinkReference(std::string const& lib,
+ OutputFormat format = SHELL);
protected:
- virtual std::string ConvertToIncludeReference(std::string const& path);
+ virtual std::string ConvertToIncludeReference(std::string const& path,
+ OutputFormat format = SHELL);
private:
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ce24d8d..d11bf55 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1044,7 +1044,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
cmOStringStream libdeps;
this->Internal->OutputObjects(libdeps, &target);
@@ -1104,7 +1104,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1202,7 +1202,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1423,7 +1423,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
this->WriteGroup(&sg, target, fout, libName, configs);
}
- if(this->GetVersion() >= VS8)
+ if(this->GetVersion() >= VS8 && !this->FortranProject)
{
// VS >= 8 support per-config source locations so we
// list object library content as external objects.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f248c57..556e7a4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3337,7 +3337,8 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
{
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
- if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile))
+ std::string mods = cmakeRoot + std::string("/Modules/");
+ if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
{
switch (this->GetPolicyStatus(cmPolicies::CMP0017))
{
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 03fdda2..1802054 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -307,14 +307,26 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
// Select whether to use a response file for objects.
- bool useResponseFile = false;
+ bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
if(this->Makefile->IsOn(responseVar.c_str()))
{
- useResponseFile = true;
+ useResponseFileForObjects = true;
+ }
+ }
+
+ // Select whether to use a response file for libraries.
+ bool useResponseFileForLibs = false;
+ {
+ std::string responseVar = "CMAKE_";
+ responseVar += linkLanguage;
+ responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+ if(this->Makefile->IsOn(responseVar.c_str()))
+ {
+ useResponseFileForLibs = true;
}
}
@@ -325,17 +337,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Collect up flags to link in needed libraries.
std::string linkLibs;
- std::string frameworkPath;
- std::string linkPath;
- this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *this->GeneratorTarget,
- relink);
- linkLibs = frameworkPath + linkPath + linkLibs;
+ this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends);
+
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
- this->CreateObjectLists(useLinkScript, false, useResponseFile,
- buildObjs, depends);
+ this->CreateObjectLists(useLinkScript, false,
+ useResponseFileForObjects, buildObjs, depends);
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 807aca8..39e00b2 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -474,14 +474,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
// Select whether to use a response file for objects.
- bool useResponseFile = false;
+ bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
if(this->Makefile->IsOn(responseVar.c_str()))
{
- useResponseFile = true;
+ useResponseFileForObjects = true;
+ }
+ }
+
+ // Select whether to use a response file for libraries.
+ bool useResponseFileForLibs = false;
+ {
+ std::string responseVar = "CMAKE_";
+ responseVar += linkLanguage;
+ responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+ if(this->Makefile->IsOn(responseVar.c_str()))
+ {
+ useResponseFileForLibs = true;
}
}
@@ -528,7 +540,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
useLinkScript = true;
// Archiving rules never use a response file.
- useResponseFile = false;
+ useResponseFileForObjects = false;
// Limit the length of individual object lists to less than the
// 32K command line length limit on Windows. We could make this a
@@ -546,19 +558,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string linkLibs;
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{
- std::string frameworkPath;
- std::string linkPath;
- this->LocalGenerator
- ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *this->GeneratorTarget, relink);
- linkLibs = frameworkPath + linkPath + linkLibs;
+ this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends);
}
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
- this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile,
- buildObjs, depends);
+ this->CreateObjectLists(useLinkScript, useArchiveRules,
+ useResponseFileForObjects, buildObjs, depends);
cmLocalGenerator::RuleVariables vars;
vars.TargetPDB = targetOutPathPDB.c_str();
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e8a9fd1..facbcc6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1833,6 +1833,46 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
+::CreateLinkLibs(std::string& linkLibs, bool relink,
+ bool useResponseFile,
+ std::vector<std::string>& makefile_depends)
+{
+ std::string frameworkPath;
+ std::string linkPath;
+ this->LocalGenerator
+ ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+ *this->GeneratorTarget, relink,
+ useResponseFile);
+ linkLibs = frameworkPath + linkPath + linkLibs;
+
+ if(useResponseFile)
+ {
+ // Lookup the response file reference flag.
+ std::string responseFlagVar = "CMAKE_";
+ responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
+ responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+ const char* responseFlag =
+ this->Makefile->GetDefinition(responseFlagVar.c_str());
+ if(!responseFlag)
+ {
+ responseFlag = "@";
+ }
+
+ // Create this response file.
+ std::string link_rsp =
+ this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
+
+ // Reference the response file.
+ linkLibs = responseFlag;
+ linkLibs += this->Convert(link_rsp.c_str(),
+ cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
std::vector<std::string>& makefile_depends)
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4f8fafa..72dc6bc 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -163,6 +163,11 @@ protected:
std::string const& options,
std::vector<std::string>& makefile_depends);
+ /** Create list of flags for link libraries. */
+ void CreateLinkLibs(std::string& linkLibs, bool relink,
+ bool useResponseFile,
+ std::vector<std::string>& makefile_depends);
+
/** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 33fb0fc..abbabe7 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -653,7 +653,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeOutputDirectory(path.c_str());
}
- else if((i < args.size()-1) && (arg.find("--check-build-system",0) == 0))
+ else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0))
{
this->CheckBuildSystemArgument = args[++i];
this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 24ea518..3ad5c2e 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -685,6 +685,7 @@ IF(KWSYS_USE_SystemInformation)
# usually it's in libc but on FreeBSD
# it's in libexecinfo
FIND_LIBRARY(EXECINFO_LIB "execinfo")
+ MARK_AS_ADVANCED(EXECINFO_LIB)
IF (NOT EXECINFO_LIB)
SET(EXECINFO_LIB "")
ENDIF()
@@ -1076,6 +1077,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$"))
)
ENDIF()
+IF(WIN32)
+ # Help enforce the use of wide Windows apis.
+ ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
+ENDIF()
+
IF(KWSYS_USE_String)
# Activate code in "String.c". See the comment in the source.
SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
diff --git a/Source/kwsys/FStream.cxx b/Source/kwsys/FStream.cxx
new file mode 100644
index 0000000..018652c
--- /dev/null
+++ b/Source/kwsys/FStream.cxx
@@ -0,0 +1,76 @@
+/*============================================================================
+ KWSys - Kitware System Library
+ 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 "kwsysPrivate.h"
+#include KWSYS_HEADER(FStream.hxx)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "FStream.hxx.in"
+#endif
+
+namespace KWSYS_NAMESPACE
+{
+namespace FStream
+{
+
+BOM ReadBOM(std::istream& in)
+{
+ if(!in.good())
+ {
+ return BOM_None;
+ }
+ unsigned long orig = in.tellg();
+ unsigned char bom[4];
+ in.read(reinterpret_cast<char*>(bom), 2);
+ if(!in.good())
+ {
+ in.seekg(orig);
+ return BOM_None;
+ }
+ if(bom[0] == 0xEF && bom[1] == 0xBB)
+ {
+ in.read(reinterpret_cast<char*>(bom+2), 1);
+ if(in.good() && bom[2] == 0xBF)
+ {
+ return BOM_UTF8;
+ }
+ }
+ else if(bom[0] == 0xFE && bom[1] == 0xFF)
+ {
+ return BOM_UTF16BE;
+ }
+ else if(bom[0] == 0x00 && bom[1] == 0x00)
+ {
+ in.read(reinterpret_cast<char*>(bom+2), 2);
+ if(in.good() && bom[2] == 0xFE && bom[3] == 0xFF)
+ {
+ return BOM_UTF32BE;
+ }
+ }
+ else if(bom[0] == 0xFF && bom[1] == 0xFE)
+ {
+ unsigned long p = in.tellg();
+ in.read(reinterpret_cast<char*>(bom+2), 2);
+ if(in.good() && bom[2] == 0x00 && bom[3] == 0x00)
+ {
+ return BOM_UTF32LE;
+ }
+ in.seekg(p);
+ return BOM_UTF16LE;
+ }
+ in.seekg(orig);
+ return BOM_None;
+}
+
+} // FStream namespace
+} //KWSYS_NAMESPACE
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index 916a93e..45425ff 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -161,13 +161,28 @@ class basic_ofstream : public std::basic_ostream<CharType,Traits>
typedef basic_ofstream<char> ofstream;
#else
- using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf;
using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
#endif
+ namespace FStream
+ {
+ enum BOM
+ {
+ BOM_None,
+ BOM_UTF8,
+ BOM_UTF16BE,
+ BOM_UTF16LE,
+ BOM_UTF32BE,
+ BOM_UTF32LE
+ };
+
+ // Read a BOM, if one exists.
+ // If a BOM exists, the stream is advanced to after the BOM.
+ // This function requires a seekable stream (but not a relative
+ // seekable stream).
+ BOM ReadBOM(std::istream& in);
+ }
}
-
-
#endif
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index 8bbc74a..dd4d462 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
- DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
+ DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
out_path, 0);
return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH;
#else
@@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
{
#if defined(_WIN32)
int result = 0;
- HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
+ HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
+ HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE)
{
@@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message)
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
DWORD original = GetLastError();
- DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, 0, original,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
message, KWSYS_SHARED_FORWARD_MAXPATH, 0);
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 5f20853..9c26380 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -4698,11 +4698,28 @@ bool SystemInformationImplementation::QueryHaikuInfo()
{
#if defined(__HAIKU__)
+ // CPU count
system_info info;
get_system_info(&info);
-
this->NumberOfPhysicalCPU = info.cpu_count;
- this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F;
+
+ // CPU speed
+ uint32 topologyNodeCount = 0;
+ cpu_topology_node_info* topology = 0;
+ get_cpu_topology_info(0, &topologyNodeCount);
+ if (topologyNodeCount != 0)
+ topology = new cpu_topology_node_info[topologyNodeCount];
+ get_cpu_topology_info(topology, &topologyNodeCount);
+
+ for (uint32 i = 0; i < topologyNodeCount; i++) {
+ if (topology[i].type == B_TOPOLOGY_CORE) {
+ this->CPUSpeedInMHz = topology[i].data.core.default_frequency /
+ 1000000.0f;
+ break;
+ }
+ }
+
+ delete[] topology;
// Physical Memory
this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ;
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index f4a443f..b6a2437 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -188,6 +188,9 @@ static inline char *realpath(const char *path, char *resolved_path)
#endif
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
+
+#include <wctype.h>
+
inline int Mkdir(const char* dir)
{
return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str());
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index 8942549..9abfd4c 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -16,11 +16,17 @@
#endif
#include KWSYS_HEADER(FStream.hxx)
+#include KWSYS_HEADER(ios/iostream)
+#include <string.h>
+#ifdef __BORLANDC__
+# include <mem.h> /* memcmp */
+#endif
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "FStream.hxx.in"
+# include "kwsys_ios_iostream.h.in"
#endif
@@ -36,6 +42,141 @@ static int testNoFile()
return 0;
}
+static kwsys::FStream::BOM expected_bom[5] =
+{
+ kwsys::FStream::BOM_UTF8,
+ kwsys::FStream::BOM_UTF16LE,
+ kwsys::FStream::BOM_UTF16BE,
+ kwsys::FStream::BOM_UTF32LE,
+ kwsys::FStream::BOM_UTF32BE
+};
+
+static unsigned char expected_bom_data[5][5] =
+{
+ {3, 0xEF, 0xBB, 0xBF},
+ {2, 0xFF, 0xFE},
+ {2, 0xFE, 0xFF},
+ {4, 0xFF, 0xFE, 0x00, 0x00},
+ {4, 0x00, 0x00, 0xFE, 0xFF},
+};
+
+static unsigned char file_data[5][45] =
+{
+ {11, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'},
+ {22, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, 0x00,
+ 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64, 0x00},
+ {22, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20,
+ 0x00, 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64},
+ {44, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
+ 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00,
+ 0x6C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00},
+ {44, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C,
+ 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72,
+ 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64},
+};
+
+//----------------------------------------------------------------------------
+static int testBOM()
+{
+ // test various encodings in binary mode
+ for(int i=0; i<5; i++)
+ {
+ {
+ kwsys::ofstream out("bom.txt", kwsys::ofstream::binary);
+ out.write(reinterpret_cast<const char*>(expected_bom_data[i]+1),
+ *expected_bom_data[i]);
+ out.write(reinterpret_cast<const char*>(file_data[i]+1),
+ file_data[i][0]);
+ }
+
+ kwsys::ifstream in("bom.txt", kwsys::ofstream::binary);
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != expected_bom[i])
+ {
+ kwsys_ios::cout << "Unexpected BOM " << i << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[i][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data " << i << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[i]+1, file_data[i][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data " << i << std::endl;
+ return 1;
+ }
+
+ }
+
+ // test text file without bom
+ {
+ {
+ kwsys::ofstream out("bom.txt");
+ out << "Hello World";
+ }
+
+ kwsys::ifstream in("bom.txt");
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != kwsys::FStream::BOM_None)
+ {
+ kwsys_ios::cout << "Unexpected BOM for none case" << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[0][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data for none case" << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data for none case" << std::endl;
+ return 1;
+ }
+ }
+
+ // test text file with utf-8 bom
+ {
+ {
+ kwsys::ofstream out("bom.txt");
+ out.write(reinterpret_cast<const char*>(expected_bom_data[0]+1),
+ *expected_bom_data[0]);
+ out << "Hello World";
+ }
+
+ kwsys::ifstream in("bom.txt");
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != kwsys::FStream::BOM_UTF8)
+ {
+ kwsys_ios::cout << "Unexpected BOM for utf-8 case" << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[0][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data for utf-8 case" << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data for utf-8 case" << std::endl;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
//----------------------------------------------------------------------------
int testFStream(int, char*[])
@@ -43,6 +184,7 @@ int testFStream(int, char*[])
int ret = 0;
ret |= testNoFile();
+ ret |= testBOM();
return ret;
}