diff options
Diffstat (limited to 'Source/CPack')
45 files changed, 3301 insertions, 754 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx new file mode 100644 index 0000000..732938b --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -0,0 +1,545 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmCPackIFWGenerator.h" + +#include "cmCPackIFWPackage.h" +#include "cmCPackIFWInstaller.h" + +#include <CPack/cmCPackLog.h> +#include <CPack/cmCPackComponentGroup.h> + +#include <cmsys/SystemTools.hxx> +#include <cmsys/Glob.hxx> +#include <cmsys/Directory.hxx> +#include <cmsys/RegularExpression.hxx> + +#include <cmGlobalGenerator.h> +#include <cmLocalGenerator.h> +#include <cmSystemTools.h> +#include <cmMakefile.h> +#include <cmGeneratedFileStream.h> +#include <cmXMLSafe.h> + +//---------------------------------------------------------------------------- +cmCPackIFWGenerator::cmCPackIFWGenerator() +{ +} + +//---------------------------------------------------------------------------- +cmCPackIFWGenerator::~cmCPackIFWGenerator() +{ +} + +//---------------------------------------------------------------------------- +int cmCPackIFWGenerator::PackageFiles() +{ + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Configuration" << std::endl); + + // Installer configuragion + Installer.GenerateInstallerFile(); + + // Packages configuration + Installer.GeneratePackageFiles(); + + std::string ifwTLD = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + std::string ifwTmpFile = ifwTLD; + ifwTmpFile += "/IFWOutput.log"; + + // Run repogen + if (!DownloadSite.empty()) + { + std::string ifwCmd = RepoGen; + ifwCmd += " -c " + this->toplevel + "/config/config.xml"; + ifwCmd += " -p " + this->toplevel + "/packages"; + + if(!PkgsDirsVector.empty()) + { + for(std::vector<std::string>::iterator it = PkgsDirsVector.begin(); + it != PkgsDirsVector.end(); ++it) + { + ifwCmd += " -p " + *it; + } + } + + if (!OnlineOnly && !DownloadedPackages.empty()) + { + ifwCmd += " -i "; + std::set<cmCPackIFWPackage*>::iterator it + = DownloadedPackages.begin(); + ifwCmd += (*it)->Name; + ++it; + while(it != DownloadedPackages.end()) + { + ifwCmd += "," + (*it)->Name; + ++it; + } + } + ifwCmd += " " + this->toplevel + "/repository"; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd + << std::endl); + std::string output; + int retVal = 1; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Generate repository" << std::endl); + bool res = cmSystemTools::RunSingleCommand( + ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); + if ( !res || retVal ) + { + cmGeneratedFileStream ofs(ifwTmpFile.c_str()); + ofs << "# Run command: " << ifwCmd << std::endl + << "# Output:" << std::endl + << output << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: " + << ifwCmd << std::endl + << "Please check " << ifwTmpFile << " for errors" + << std::endl); + return 0; + } + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel + << "/repository generated" << std::endl); + } + + // Run binary creator + { + std::string ifwCmd = BinCreator; + ifwCmd += " -c " + this->toplevel + "/config/config.xml"; + ifwCmd += " -p " + this->toplevel + "/packages"; + + if(!PkgsDirsVector.empty()) + { + for(std::vector<std::string>::iterator it = PkgsDirsVector.begin(); + it != PkgsDirsVector.end(); ++it) + { + ifwCmd += " -p " + *it; + } + } + + if (OnlineOnly) + { + ifwCmd += " --online-only"; + } + else if (!DownloadedPackages.empty() && !DownloadSite.empty()) + { + ifwCmd += " -e "; + std::set<cmCPackIFWPackage*>::iterator it + = DownloadedPackages.begin(); + ifwCmd += (*it)->Name; + ++it; + while(it != DownloadedPackages.end()) + { + ifwCmd += "," + (*it)->Name; + ++it; + } + } + else if (!DependentPackages.empty()) + { + ifwCmd += " -i "; + // Binary + std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin(); + while(bit != BinaryPackages.end()) + { + ifwCmd += (*bit)->Name + ","; + ++bit; + } + // Depend + DependenceMap::iterator it = DependentPackages.begin(); + ifwCmd += it->second.Name; + ++it; + while(it != DependentPackages.end()) + { + ifwCmd += "," + it->second.Name; + ++it; + } + } + // TODO: set correct name for multipackages + if (this->packageFileNames.size() > 0) + { + ifwCmd += " " + packageFileNames[0]; + } + else + { + ifwCmd += " installer"; + } + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd + << std::endl); + std::string output; + int retVal = 1; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); + bool res = cmSystemTools::RunSingleCommand( + ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); + if ( !res || retVal ) + { + cmGeneratedFileStream ofs(ifwTmpFile.c_str()); + ofs << "# Run command: " << ifwCmd << std::endl + << "# Output:" << std::endl + << output << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: " + << ifwCmd << std::endl + << "Please check " << ifwTmpFile << " for errors" + << std::endl); + return 0; + } + } + + return 1; +} + +//---------------------------------------------------------------------------- +const char *cmCPackIFWGenerator::GetPackagingInstallPrefix() +{ + const char *defPrefix = cmCPackGenerator::GetPackagingInstallPrefix(); + + std::string tmpPref = defPrefix ? defPrefix : ""; + + if(this->Components.empty()) + { + tmpPref += "packages/" + GetRootPackageName() + "/data"; + } + + this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str()); + + return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX"); +} + +//---------------------------------------------------------------------------- +const char *cmCPackIFWGenerator::GetOutputExtension() +{ + const char *suffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX"); + return suffix ? suffix : cmCPackGenerator::GetOutputExtension(); +} + +//---------------------------------------------------------------------------- +int cmCPackIFWGenerator::InitializeInternal() +{ + // Search Qt Installer Framework tools + + if(!this->IsOn("CPACK_IFW_BINARYCREATOR_EXECUTABLE_FOUND") || + !this->IsOn("CPACK_IFW_REPOGEN_EXECUTABLE_FOUND")) + { + this->ReadListFile("CPackIFW.cmake"); + } + + // Look 'binarycreator' executable (needs) + + if(this->IsOn("CPACK_IFW_BINARYCREATOR_EXECUTABLE_FOUND")) + { + const char *ifwBinCreatorStr = + this->GetOption("CPACK_IFW_BINARYCREATOR_EXECUTABLE"); + BinCreator = ifwBinCreatorStr ? ifwBinCreatorStr : ""; + } + else + { + BinCreator = ""; + } + + if (BinCreator.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find QtIFW compiler \"binarycreator\": " + "likely it is not installed, or not in your PATH" + << std::endl); + return 0; + } + + // Look 'repogen' executable (optional) + + if(this->IsOn("CPACK_IFW_REPOGEN_EXECUTABLE_FOUND")) + { + const char *ifwRepoGenStr = + this->GetOption("CPACK_IFW_REPOGEN_EXECUTABLE"); + RepoGen = ifwRepoGenStr ? ifwRepoGenStr : ""; + } + else + { + RepoGen = ""; + } + + // Variables that Change Behavior + + // Resolve duplicate names + ResolveDuplicateNames = this->IsOn("CPACK_IFW_RESOLVE_DUPLICATE_NAMES"); + + // Additional packages dirs + PkgsDirsVector.clear(); + if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) + { + cmSystemTools::ExpandListArgument(dirs, + PkgsDirsVector); + } + + // Remote repository + + if (const char *site = this->GetOption("CPACK_DOWNLOAD_SITE")) + { + DownloadSite = site; + } + + OnlineOnly = this->IsOn("CPACK_DOWNLOAD_ALL") ? true : false; + + if (!DownloadSite.empty() && RepoGen.empty()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find QtIFW repository generator \"repogen\": " + "likely it is not installed, or not in your PATH" + << std::endl); + return 0; + } + + // Installer + Installer.Generator = this; + Installer.ConfigureFromOptions(); + + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------------- +std::string +cmCPackIFWGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) +{ + const std::string prefix = "packages/"; + const std::string suffix = "/data"; + + if (componentPackageMethod == ONE_PACKAGE) { + return std::string(prefix + GetRootPackageName() + suffix); + } + + return prefix + + GetComponentPackageName(&Components[componentName]) + + suffix; +} + +//---------------------------------------------------------------------------- +cmCPackComponent* +cmCPackIFWGenerator::GetComponent(const std::string &projectName, + const std::string &componentName) +{ + ComponentsMap::iterator cit = Components.find(componentName); + if ( cit != Components.end() ) return &(cit->second); + + cmCPackComponent* component + = cmCPackGenerator::GetComponent(projectName, componentName); + if(!component) return component; + + std::string name = GetComponentPackageName(component); + PackagesMap::iterator pit = Packages.find(name); + if(pit != Packages.end()) return component; + + cmCPackIFWPackage *package = &Packages[name]; + package->Name = name; + package->Generator = this; + if(package->ConfigureFromComponent(component)) + { + package->Installer = &Installer; + Installer.Packages.insert( + std::pair<std::string, cmCPackIFWPackage*>( + name, package)); + ComponentPackages.insert( + std::pair<cmCPackComponent*, cmCPackIFWPackage*>( + component, package)); + if(component->IsDownloaded) + { + DownloadedPackages.insert(package); + } + else + { + BinaryPackages.insert(package); + } + } + else + { + Packages.erase(name); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot configure package \"" << name << + "\" for component \"" << component->Name << "\"" + << std::endl); + } + + return component; +} + +//---------------------------------------------------------------------------- +cmCPackComponentGroup* +cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName, + const std::string &groupName) +{ + cmCPackComponentGroup* group + = cmCPackGenerator::GetComponentGroup(projectName, groupName); + if(!group) return group; + + std::string name = GetGroupPackageName(group); + PackagesMap::iterator pit = Packages.find(name); + if(pit != Packages.end()) return group; + + cmCPackIFWPackage *package = &Packages[name]; + package->Name = name; + package->Generator = this; + if(package->ConfigureFromGroup(group)) + { + package->Installer = &Installer; + Installer.Packages.insert( + std::pair<std::string, cmCPackIFWPackage*>( + name, package)); + GroupPackages.insert( + std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>( + group, package)); + BinaryPackages.insert(package); + } + else + { + Packages.erase(name); + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot configure package \"" << name << + "\" for component group \"" << group->Name << "\"" + << std::endl); + } + return group; +} + +//---------------------------------------------------------------------------- +enum cmCPackGenerator::CPackSetDestdirSupport +cmCPackIFWGenerator::SupportsSetDestdir() const +{ + return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED; +} + +//---------------------------------------------------------------------------- +bool cmCPackIFWGenerator::SupportsAbsoluteDestination() const +{ + return false; +} + +//---------------------------------------------------------------------------- +bool cmCPackIFWGenerator::SupportsComponentInstallation() const +{ + return true; +} + +//---------------------------------------------------------------------------- +bool cmCPackIFWGenerator::IsOnePackage() const +{ + return componentPackageMethod == ONE_PACKAGE; +} + +//---------------------------------------------------------------------------- +std::string cmCPackIFWGenerator::GetRootPackageName() +{ + // Default value + std::string name = "root"; + if (const char* optIFW_PACKAGE_GROUP = + this->GetOption("CPACK_IFW_PACKAGE_GROUP")) + { + // Configure from root group + cmCPackIFWPackage package; + package.Generator = this; + package.ConfigureFromGroup(optIFW_PACKAGE_GROUP); + name = package.Name; + } + else if (const char* optIFW_PACKAGE_NAME = + this->GetOption("CPACK_IFW_PACKAGE_NAME")) + { + // Configure from root package name + name = optIFW_PACKAGE_NAME; + } + else if (const char* optPACKAGE_NAME = + this->GetOption("CPACK_PACKAGE_NAME")) + { + // Configure from package name + name = optPACKAGE_NAME; + } + return name; +} + +//---------------------------------------------------------------------------- +std::string +cmCPackIFWGenerator::GetGroupPackageName(cmCPackComponentGroup *group) const +{ + std::string name; + if (!group) return name; + if (cmCPackIFWPackage* package = GetGroupPackage(group)) + { + return package->Name; + } + const char* option = GetOption( + "CPACK_IFW_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(group->Name) + + "_NAME"); + name = option ? option : group->Name; + if(group->ParentGroup) + { + cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup); + bool dot = !ResolveDuplicateNames; + if(dot && name.substr(0, package->Name.size()) == package->Name) + { + dot = false; + } + if(dot) + { + name = package->Name + "." + name; + } + } + return name; +} + +//---------------------------------------------------------------------------- +std::string cmCPackIFWGenerator::GetComponentPackageName( + cmCPackComponent *component) const +{ + std::string name; + if (!component) return name; + if (cmCPackIFWPackage* package = GetComponentPackage(component)) + { + return package->Name; + } + std::string prefix = "CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + + "_"; + const char* option = GetOption(prefix + "NAME"); + name = option ? option : component->Name; + if(component->Group) + { + cmCPackIFWPackage* package = GetGroupPackage(component->Group); + if((componentPackageMethod == ONE_PACKAGE_PER_GROUP) + || IsOn(prefix + "COMMON")) + { + return package->Name; + } + bool dot = !ResolveDuplicateNames; + if(dot && name.substr(0, package->Name.size()) == package->Name) + { + dot = false; + } + if(dot) + { + name = package->Name + "." + name; + } + } + return name; +} + +//---------------------------------------------------------------------------- +cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage( + cmCPackComponentGroup *group) const +{ + std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit + = GroupPackages.find(group); + return pit != GroupPackages.end() ? pit->second : 0; +} + +//---------------------------------------------------------------------------- +cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( + cmCPackComponent *component) const +{ + std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit + = ComponentPackages.find(component); + return pit != ComponentPackages.end() ? pit->second : 0; +} diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h new file mode 100644 index 0000000..7211e04 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -0,0 +1,137 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackIFWGenerator_h +#define cmCPackIFWGenerator_h + +#include <CPack/cmCPackGenerator.h> + +#include "cmCPackIFWPackage.h" +#include "cmCPackIFWInstaller.h" + +/** \class cmCPackIFWGenerator + * \brief A generator for Qt Installer Framework tools + * + * http://qt-project.org/doc/qtinstallerframework/index.html + */ +class cmCPackIFWGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator); + + typedef std::map<std::string, cmCPackIFWPackage> PackagesMap; + typedef std::map<std::string, cmCPackComponent> ComponentsMap; + typedef std::map<std::string, cmCPackComponentGroup> ComponentGoupsMap; + typedef std::map<std::string, cmCPackIFWPackage::DependenceStruct> + DependenceMap; + + /** + * Construct IFW generator + */ + cmCPackIFWGenerator(); + + /** + * Destruct IFW generator + */ + virtual ~cmCPackIFWGenerator(); + +protected: // cmCPackGenerator reimplementation + + /** + * @brief Initialize generator + * @return 0 on failure + */ + virtual int InitializeInternal(); + virtual int PackageFiles(); + virtual const char* GetPackagingInstallPrefix(); + + /** + * @brief Extension of binary installer + * @return Executable suffix or value from default implementation + */ + virtual const char* GetOutputExtension(); + + virtual std::string GetComponentInstallDirNameSuffix( + const std::string& componentName); + + /** + * @brief Get Component + * @param projectName Project name + * @param componentName Component name + * + * This method calls the base implementation. + * + * @return Pointer to component + */ + virtual cmCPackComponent* GetComponent( + const std::string& projectName, + const std::string& componentName); + + /** + * @brief Get group of component + * @param projectName Project name + * @param groupName Component group name + * + * This method calls the base implementation. + * + * @return Pointer to component group + */ + virtual cmCPackComponentGroup* GetComponentGroup( + const std::string& projectName, + const std::string& groupName); + + enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const; + virtual bool SupportsAbsoluteDestination() const; + virtual bool SupportsComponentInstallation() const; + +protected: // Methods + + bool IsOnePackage() const; + + std::string GetRootPackageName(); + + std::string GetGroupPackageName(cmCPackComponentGroup *group) const; + std::string GetComponentPackageName(cmCPackComponent *component) const; + + cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const; + cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const; + +protected: // Data + + friend class cmCPackIFWPackage; + friend class cmCPackIFWInstaller; + + // Installer + cmCPackIFWInstaller Installer; + // Collection of packages + PackagesMap Packages; + // Collection of binary packages + std::set<cmCPackIFWPackage*> BinaryPackages; + // Collection of downloaded packages + std::set<cmCPackIFWPackage*> DownloadedPackages; + // Dependent packages + DependenceMap DependentPackages; + std::map<cmCPackComponent*, cmCPackIFWPackage*> ComponentPackages; + std::map<cmCPackComponentGroup*, cmCPackIFWPackage*> GroupPackages; + +private: + std::string RepoGen; + std::string BinCreator; + + std::string DownloadSite; + + bool OnlineOnly; + bool ResolveDuplicateNames; + std::vector<std::string> PkgsDirsVector; +}; + +#endif diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx new file mode 100644 index 0000000..fcb07e6 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -0,0 +1,304 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmCPackIFWInstaller.h" + +#include "cmCPackIFWGenerator.h" + +#include <CPack/cmCPackLog.h> + +#include <cmGeneratedFileStream.h> +#include <cmXMLSafe.h> + +#ifdef cmCPackLogger +# undef cmCPackLogger +#endif +#define cmCPackLogger(logType, msg) \ + do { \ + cmOStringStream cmCPackLog_msg; \ + cmCPackLog_msg << msg; \ + if(Generator) { \ + Generator->Logger->Log(logType, __FILE__, __LINE__, \ + cmCPackLog_msg.str().c_str()); \ + } \ + } while ( 0 ) + +//---------------------------------------------------------------------------- +cmCPackIFWInstaller::cmCPackIFWInstaller() : + Generator(0) +{ +} + +//---------------------------------------------------------------------------- +const char *cmCPackIFWInstaller::GetOption(const std::string &op) const +{ + return Generator ? Generator->GetOption(op) : 0; +} + +//---------------------------------------------------------------------------- +void cmCPackIFWInstaller::ConfigureFromOptions() +{ + // Name; + if (const char* optIFW_PACKAGE_NAME = + this->GetOption("CPACK_IFW_PACKAGE_NAME")) + { + Name = optIFW_PACKAGE_NAME; + } + else if (const char* optPACKAGE_NAME = + this->GetOption("CPACK_PACKAGE_NAME")) + { + Name = optPACKAGE_NAME; + } + else + { + Name = "Your package"; + } + + // Title; + if (const char* optIFW_PACKAGE_TITLE = + GetOption("CPACK_IFW_PACKAGE_TITLE")) + { + Title = optIFW_PACKAGE_TITLE; + } + else if (const char* optPACKAGE_DESCRIPTION_SUMMARY = + GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) + { + Title = optPACKAGE_DESCRIPTION_SUMMARY; + } + else + { + Title = "Your package description"; + } + + // Version; + if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) + { + Version = option; + } + else + { + Version = "1.0.0"; + } + + // Publisher + if(const char* optIFW_PACKAGE_PUBLISHER = + GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) + { + Publisher = optIFW_PACKAGE_PUBLISHER; + } + else if(const char* optPACKAGE_VENDOR = GetOption("CPACK_PACKAGE_VENDOR")) + { + Publisher = optPACKAGE_VENDOR; + } + + // ProductUrl + if(const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) + { + ProductUrl = option; + } + + // ApplicationIcon + if(const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) + { + if(cmSystemTools::FileExists(option)) + { + InstallerApplicationIcon = option; + } + else + { + // TODO: implement warning + } + } + + // WindowIcon + if(const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) + { + if(cmSystemTools::FileExists(option)) + { + InstallerWindowIcon = option; + } + else + { + // TODO: implement warning + } + } + + // Logo + if(const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) + { + if(cmSystemTools::FileExists(option)) + { + Logo = option; + } + else + { + // TODO: implement warning + } + } + + // Default target directory for installation + if (const char* optIFW_TARGET_DIRECTORY = + GetOption("CPACK_IFW_TARGET_DIRECTORY")) + { + TargetDir = optIFW_TARGET_DIRECTORY; + } + else if (const char *optPACKAGE_INSTALL_DIRECTORY = + GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) + { + TargetDir = "@ApplicationsDir@/"; + TargetDir += optPACKAGE_INSTALL_DIRECTORY; + } + else + { + TargetDir = "@RootDir@/usr/local"; + } + + // Default target directory for installation with administrator rights + if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) + { + AdminTargetDir = option; + } +} + +//---------------------------------------------------------------------------- +void cmCPackIFWInstaller::GenerateInstallerFile() +{ + // Lazy directory initialization + if(Directory.empty() && Generator) + { + Directory = Generator->toplevel; + } + + // Output stream + cmGeneratedFileStream xout((Directory + "/config/config.xml").data()); + + xout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; + xout << "<Installer>" << std::endl; + + xout << " <Name>" << cmXMLSafe(Name).str() << "</Name>" << std::endl; + + xout << " <Version>" << Version << "</Version>" << std::endl; + + xout << " <Title>" << cmXMLSafe(Title).str() << "</Title>" + << std::endl; + + if(!Publisher.empty()) + { + xout << " <Publisher>" << cmXMLSafe(Publisher).str() + << "</Publisher>" << std::endl; + } + + if(!ProductUrl.empty()) + { + xout << " <ProductUrl>" << ProductUrl << "</ProductUrl>" << std::endl; + } + + // ApplicationIcon + if(!InstallerApplicationIcon.empty()) + { + std::string name = + cmSystemTools::GetFilenameName(InstallerApplicationIcon); + std::string path = Directory + "/config/" + name; + name = cmSystemTools::GetFilenameWithoutExtension(name); + cmsys::SystemTools::CopyFileIfDifferent( + InstallerApplicationIcon.data(), path.data()); + xout << " <InstallerApplicationIcon>" << name + << "</InstallerApplicationIcon>" << std::endl; + } + + // WindowIcon + if(!InstallerWindowIcon.empty()) + { + std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon); + std::string path = Directory + "/config/" + name; + cmsys::SystemTools::CopyFileIfDifferent( + InstallerWindowIcon.data(), path.data()); + xout << " <InstallerWindowIcon>" << name + << "</InstallerWindowIcon>" << std::endl; + } + + // Logo + if(!Logo.empty()) + { + std::string name = cmSystemTools::GetFilenameName(Logo); + std::string path = Directory + "/config/" + name; + cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data()); + xout << " <Logo>" << name << "</Logo>" << std::endl; + } + + if(!TargetDir.empty()) + { + xout << " <TargetDir>" << TargetDir << "</TargetDir>" << std::endl; + } + + if(!AdminTargetDir.empty()) + { + xout << " <AdminTargetDir>" << AdminTargetDir + << "</AdminTargetDir>" << std::endl; + } + + // Site + if (!Generator->DownloadSite.empty()) + { + xout << " <RemoteRepositories>" << std::endl; + xout << " <Repository>" << std::endl; + xout << " <Url>" << Generator->DownloadSite + << "</Url>" << std::endl; + // These properties can not be set from "cpack_configure_downloads" + // <Enabled>1</Enabled> + // <Username>user</Username> + // <Password>password</Password> + // <DisplayName>Example repository</DisplayName> + xout << " </Repository>" << std::endl; + xout << " </RemoteRepositories>" << std::endl; + } + + // CPack IFW default policy + xout << " <!-- CPack IFW default policy -->" << std::endl; + xout << " <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>" + << std::endl; + xout << " <AllowSpaceInPath>true</AllowSpaceInPath>" << std::endl; + + xout << "</Installer>" << std::endl; +} + +//---------------------------------------------------------------------------- +void cmCPackIFWInstaller::GeneratePackageFiles() +{ + if (Packages.empty() || Generator->IsOnePackage()) + { + // Generate default package + cmCPackIFWPackage package; + package.Generator = Generator; + package.Installer = this; + // Check package group + if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) + { + package.ConfigureFromGroup(option); + package.ForcedInstallation = "true"; + } + else + { + package.ConfigureFromOptions(); + } + package.GeneratePackageFile(); + return; + } + + // Generate packages meta information + for(PackagesMap::iterator pit = Packages.begin(); + pit != Packages.end(); ++pit) + { + cmCPackIFWPackage* package = pit->second; + package->GeneratePackageFile(); + } +} diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h new file mode 100644 index 0000000..1630a94 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -0,0 +1,84 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackIFWInstaller_h +#define cmCPackIFWInstaller_h + +#include <cmStandardIncludes.h> + +class cmCPackIFWPackage; +class cmCPackIFWGenerator; + +/** \class cmCPackIFWInstaller + * \brief A binary installer to be created CPack IFW generator + */ +class cmCPackIFWInstaller +{ +public: // Types + + typedef std::map<std::string, cmCPackIFWPackage*> PackagesMap; + +public: // Constructor + + /** + * Construct installer + */ + cmCPackIFWInstaller(); + +public: // Configuration + + /// Name of the product being installed + std::string Name; + + /// Version number of the product being installed + std::string Version; + + /// Name of the installer as displayed on the title bar + std::string Title; + + /// Publisher of the software (as shown in the Windows Control Panel) + std::string Publisher; + + /// URL to a page that contains product information on your web site + std::string ProductUrl; + + /// Filename for a custom installer icon + std::string InstallerApplicationIcon; + + /// Filename for a custom window icon + std::string InstallerWindowIcon; + + /// Filename for a logo + std::string Logo; + + /// Default target directory for installation + std::string TargetDir; + + /// Default target directory for installation with administrator rights + std::string AdminTargetDir; + +public: // Internal implementation + + const char* GetOption(const std::string& op) const; + + void ConfigureFromOptions(); + + void GenerateInstallerFile(); + + void GeneratePackageFiles(); + + cmCPackIFWGenerator* Generator; + PackagesMap Packages; + std::string Directory; +}; + +#endif // cmCPackIFWInstaller_h diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx new file mode 100644 index 0000000..3c45639 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -0,0 +1,540 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmCPackIFWPackage.h" + +#include "cmCPackIFWGenerator.h" + +#include <CPack/cmCPackLog.h> + +#include <cmGeneratedFileStream.h> +#include <cmTimestamp.h> + +//----------------------------------------------------------------- Logger --- +#ifdef cmCPackLogger +# undef cmCPackLogger +#endif +#define cmCPackLogger(logType, msg) \ + do { \ + cmOStringStream cmCPackLog_msg; \ + cmCPackLog_msg << msg; \ + if(Generator) { \ + Generator->Logger->Log(logType, __FILE__, __LINE__, \ + cmCPackLog_msg.str().c_str()); \ + } \ + } while ( 0 ) + +//---------------------------------------------------------- CompareStruct --- +cmCPackIFWPackage::CompareStruct::CompareStruct() : + Type(CompareNone) +{ +} + +//------------------------------------------------------- DependenceStruct --- +cmCPackIFWPackage::DependenceStruct::DependenceStruct() +{ +} + +//---------------------------------------------------------------------------- +cmCPackIFWPackage::DependenceStruct::DependenceStruct( + const std::string &dependence) +{ + // Search compare section + size_t pos = std::string::npos; + if((pos = dependence.find("<=")) != std::string::npos) + { + Compare.Type = CompareLessOrEqual; + Compare.Value = dependence.substr(pos + 2); + } + else if((pos = dependence.find(">=")) != std::string::npos) + { + Compare.Type = CompareGreaterOrEqual; + Compare.Value = dependence.substr(pos + 2); + } + else if((pos = dependence.find("<")) != std::string::npos) + { + Compare.Type = CompareLess; + Compare.Value = dependence.substr(pos + 1); + } + else if((pos = dependence.find("=")) != std::string::npos) + { + Compare.Type = CompareEqual; + Compare.Value = dependence.substr(pos + 1); + } + else if((pos = dependence.find(">")) != std::string::npos) + { + Compare.Type = CompareGreater; + Compare.Value = dependence.substr(pos + 1); + } + Name = pos == std::string::npos ? dependence : dependence.substr(0, pos); +} + +//---------------------------------------------------------------------------- +std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const +{ + if (Compare.Type == CompareNone) return Name; + + std::string result = Name; + + if (Compare.Type == CompareLessOrEqual) + { + result += "<="; + } + else if (Compare.Type == CompareGreaterOrEqual) + { + result += ">="; + } + else if (Compare.Type == CompareLess) + { + result += "<"; + } + else if (Compare.Type == CompareEqual) + { + result += "="; + } + else if (Compare.Type == CompareGreater) + { + result += ">"; + } + + result += Compare.Value; + + return result; +} + +//------------------------------------------------------ cmCPackIFWPackage --- +cmCPackIFWPackage::cmCPackIFWPackage() : + Generator(0), + Installer(0) +{ +} + +//---------------------------------------------------------------------------- +const char *cmCPackIFWPackage::GetOption(const std::string &op) const +{ + const char *option = Generator ? Generator->GetOption(op) : 0; + return option && *option ? option : 0; +} + +//---------------------------------------------------------------------------- +bool cmCPackIFWPackage::IsOn(const std::string &op) const +{ + return Generator ? Generator->IsOn(op) : false; +} + +//---------------------------------------------------------------------------- +std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent *component) +{ + if (!component) return ""; + const char* option = GetOption( + "CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + + "_NAME"); + return option ? option : component->Name; +} + +//---------------------------------------------------------------------------- +void cmCPackIFWPackage::DefaultConfiguration() +{ + DisplayName = ""; + Description = ""; + Version = ""; + ReleaseDate = ""; + Script = ""; + Licenses.clear(); + SortingPriority = ""; + Default = ""; + Virtual = ""; + ForcedInstallation = ""; +} + +//---------------------------------------------------------------------------- +// Defaul configuration (all in one package) +int cmCPackIFWPackage::ConfigureFromOptions() +{ + // Restore defaul configuration + DefaultConfiguration(); + + // Name + Name = Generator->GetRootPackageName(); + + // Display name + if (const char *option = this->GetOption("CPACK_PACKAGE_NAME")) + { + DisplayName = option; + } + else + { + DisplayName = "Your package"; + } + + // Description + if (const char* option = + this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) + { + Description = option; + } + else + { + Description = "Your package description"; + } + + // Version + if(const char* option = GetOption("CPACK_PACKAGE_VERSION")) + { + Version = option; + } + else + { + Version = "1.0.0"; + } + + ForcedInstallation = "true"; + + return 1; +} + +//---------------------------------------------------------------------------- +int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component) +{ + if(!component) return 0; + + // Restore defaul configuration + DefaultConfiguration(); + + std::string prefix = "CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + + "_"; + + // Display name + DisplayName = component->DisplayName; + + // Description + Description = component->Description; + + // Version + if(const char* optVERSION = GetOption(prefix + "VERSION")) + { + Version = optVERSION; + } + else if(const char* optPACKAGE_VERSION = + GetOption("CPACK_PACKAGE_VERSION")) + { + Version = optPACKAGE_VERSION; + } + else + { + Version = "1.0.0"; + } + + // Script + if (const char* option = GetOption(prefix + "SCRIPT")) + { + Script = option; + } + + // CMake dependencies + if (!component->Dependencies.empty()) + { + std::vector<cmCPackComponent*>::iterator dit; + for(dit = component->Dependencies.begin(); + dit != component->Dependencies.end(); + ++dit) + { + Dependencies.insert(Generator->ComponentPackages[*dit]); + } + } + + // QtIFW dependencies + if(const char* option = this->GetOption(prefix + "DEPENDS")) + { + std::vector<std::string> deps; + cmSystemTools::ExpandListArgument(option, + deps); + for(std::vector<std::string>::iterator + dit = deps.begin(); dit != deps.end(); ++dit) + { + DependenceStruct dep(*dit); + if (!Generator->Packages.count(dep.Name)) + { + bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; + DependenceStruct &depRef = + Generator->DependentPackages[dep.Name]; + if(!hasDep) + { + depRef = dep; + } + AlienDependencies.insert(&depRef); + } + } + } + + // Licenses + if (const char* option = this->GetOption(prefix + "LICENSES")) + { + Licenses.clear(); + cmSystemTools::ExpandListArgument( option, Licenses ); + if ( Licenses.size() % 2 != 0 ) + { + cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES" + << " should contain pairs of <display_name> and <file_path>." + << std::endl); + Licenses.clear(); + } + } + + // Priority + if(const char* option = this->GetOption(prefix + "PRIORITY")) + { + SortingPriority = option; + } + + // Default + Default = component->IsDisabledByDefault ? "false" : "true"; + + // Virtual + Virtual = component->IsHidden ? "true" : ""; + + // ForcedInstallation + ForcedInstallation = component->IsRequired ? "true" : "false"; + + return 1; +} + +//---------------------------------------------------------------------------- +int +cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group) +{ + if(!group) return 0; + + // Restore defaul configuration + DefaultConfiguration(); + + std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(group->Name) + + "_"; + + DisplayName = group->DisplayName; + Description = group->Description; + + // Version + if(const char* optVERSION = GetOption(prefix + "VERSION")) + { + Version = optVERSION; + } + else if(const char* optPACKAGE_VERSION = + GetOption("CPACK_PACKAGE_VERSION")) + { + Version = optPACKAGE_VERSION; + } + else + { + Version = "1.0.0"; + } + + // Script + if (const char* option = GetOption(prefix + "SCRIPT")) + { + Script = option; + } + + // Licenses + if (const char* option = this->GetOption(prefix + "LICENSES")) + { + Licenses.clear(); + cmSystemTools::ExpandListArgument( option, Licenses ); + if ( Licenses.size() % 2 != 0 ) + { + cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES" + << " should contain pairs of <display_name> and <file_path>." + << std::endl); + Licenses.clear(); + } + } + + // Priority + if(const char* option = this->GetOption(prefix + "PRIORITY")) + { + SortingPriority = option; + } + + return 1; +} + +//---------------------------------------------------------------------------- +int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName) +{ + // Group configuration + + cmCPackComponentGroup group; + std::string prefix = "CPACK_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(groupName) + + "_"; + + if (const char *option = GetOption(prefix + "DISPLAY_NAME")) + { + group.DisplayName = option; + } + else + { + group.DisplayName = group.Name; + } + + if (const char* option = GetOption(prefix + "DESCRIPTION")) + { + group.Description = option; + } + group.IsBold = IsOn(prefix + "BOLD_TITLE"); + group.IsExpandedByDefault = IsOn(prefix + "EXPANDED"); + + // Package configuration + + group.Name = groupName; + + if(Generator) + { + Name = Generator->GetGroupPackageName(&group); + } + else + { + Name = group.Name; + } + + return ConfigureFromGroup(&group); +} + +//---------------------------------------------------------------------------- +void cmCPackIFWPackage::GeneratePackageFile() +{ + // Lazy directory initialization + if (Directory.empty()) + { + if(Installer) + { + Directory = Installer->Directory + "/packages/" + Name; + } + else if (Generator) + { + Directory = Generator->toplevel + "/packages/" + Name; + } + } + + // Output stream + cmGeneratedFileStream xout((Directory + "/meta/package.xml").data()); + + xout << "<?xml version=\"1.0\"?>" << std::endl; + xout << "<Package>" << std::endl; + + xout << " <DisplayName>" << DisplayName + << "</DisplayName>" << std::endl; + + xout << " <Description>" << Description + << "</Description>" << std::endl; + + xout << " <Name>" << Name << "</Name>" << std::endl; + + xout << " <Version>" << Version + << "</Version>" << std::endl; + + xout << " <ReleaseDate>"; + if(ReleaseDate.empty()) + { + xout << cmTimestamp().CurrentTime("%Y-%m-%d", true); + } + else + { + xout << ReleaseDate; + } + xout << "</ReleaseDate>" << std::endl; + + // Script (copy to meta dir) + if(!Script.empty()) + { + std::string name = cmSystemTools::GetFilenameName(Script); + std::string path = Directory + "/meta/" + name; + cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data()); + xout << " <Script>" << name << "</Script>" << std::endl; + } + + // Dependencies + std::set<DependenceStruct> compDepSet; + for(std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin(); + ait != AlienDependencies.end(); ++ait) + { + compDepSet.insert(*(*ait)); + } + for(std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin(); + it != Dependencies.end(); ++it) + { + compDepSet.insert(DependenceStruct((*it)->Name)); + } + // Write dependencies + if (!compDepSet.empty()) + { + xout << " <Dependencies>"; + std::set<DependenceStruct>::iterator it = compDepSet.begin(); + xout << it->NameWithCompare(); + ++it; + while(it != compDepSet.end()) + { + xout << "," << it->NameWithCompare(); + ++it; + } + xout << "</Dependencies>" << std::endl; + } + + // Licenses (copy to meta dir) + std::vector<std::string> licenses = Licenses; + for(size_t i = 1; i < licenses.size(); i += 2) + { + std::string name = cmSystemTools::GetFilenameName(licenses[i]); + std::string path = Directory + "/meta/" + name; + cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data()); + licenses[i] = name; + } + if(!licenses.empty()) + { + xout << " <Licenses>" << std::endl; + for(size_t i = 0; i < licenses.size(); i += 2) + { + xout << " <License " + << "name=\"" << licenses[i] << "\" " + << "file=\"" << licenses[i + 1] << "\" " + << "/>" <<std::endl; + } + xout << " </Licenses>" << std::endl; + } + + if (!ForcedInstallation.empty()) + { + xout << " <ForcedInstallation>" << ForcedInstallation + << "</ForcedInstallation>" << std::endl; + } + + if (!Virtual.empty()) + { + xout << " <Virtual>" << Virtual << "</Virtual>" << std::endl; + } + else if (!Default.empty()) + { + xout << " <Default>" << Default << "</Default>" << std::endl; + } + + // Priority + if(!SortingPriority.empty()) + { + xout << " <SortingPriority>" << SortingPriority + << "</SortingPriority>" << std::endl; + } + + xout << "</Package>" << std::endl; +} diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h new file mode 100644 index 0000000..9fc9bd0 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -0,0 +1,133 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackIFWPackage_h +#define cmCPackIFWPackage_h + +#include <cmStandardIncludes.h> + +class cmCPackComponent; +class cmCPackComponentGroup; +class cmCPackIFWInstaller; +class cmCPackIFWGenerator; + +/** \class cmCPackIFWPackage + * \brief A single component to be installed by CPack IFW generator + */ +class cmCPackIFWPackage +{ +public: // Types + enum CompareTypes + { + CompareNone = 0x0, + CompareEqual = 0x1, + CompareLess = 0x2, + CompareLessOrEqual = 0x3, + CompareGreater = 0x4, + CompareGreaterOrEqual = 0x5 + }; + + struct CompareStruct + { + CompareStruct(); + + unsigned int Type; + std::string Value; + }; + + struct DependenceStruct + { + DependenceStruct(); + DependenceStruct(const std::string &dependence); + + std::string Name; + CompareStruct Compare; + + std::string NameWithCompare() const; + + bool operator < (const DependenceStruct &other) const + { + return Name < other.Name; + } + }; + +public: // [Con|De]structor + + /** + * Construct package + */ + cmCPackIFWPackage(); + +public: // Configuration + + /// Human-readable name of the component + std::string DisplayName; + + /// Human-readable description of the component + std::string Description; + + /// Version number of the component + std::string Version; + + /// Date when this component version was released + std::string ReleaseDate; + + /// Domain-like identification for this component + std::string Name; + + /// File name of a script being loaded + std::string Script; + + /// List of license agreements to be accepted by the installing user + std::vector<std::string> Licenses; + + /// Priority of the component in the tree + std::string SortingPriority; + + /// Set to true to preselect the component in the installer + std::string Default; + + /// Set to true to hide the component from the installer + std::string Virtual; + + /// Determines that the package must always be installed + std::string ForcedInstallation; + +public: // Internal implementation + + const char* GetOption(const std::string& op) const; + bool IsOn(const std::string& op) const; + + std::string GetComponentName(cmCPackComponent *component); + + void DefaultConfiguration(); + + int ConfigureFromOptions(); + int ConfigureFromComponent(cmCPackComponent *component); + int ConfigureFromGroup(cmCPackComponentGroup *group); + int ConfigureFromGroup(const std::string &groupName); + + void GeneratePackageFile(); + + // Pointer to generator + cmCPackIFWGenerator* Generator; + // Pointer to installer + cmCPackIFWInstaller* Installer; + // Collection of dependencies + std::set<cmCPackIFWPackage*> Dependencies; + // Collection of unresolved dependencies + std::set<DependenceStruct*> AlienDependencies; + // Patch to package directory + std::string Directory; +}; + +#endif // cmCPackIFWPackage_h diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 43119d6..a2995d1 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. @@ -15,10 +15,14 @@ #include <cmSystemTools.h> #include <cmGeneratedFileStream.h> #include <cmCryptoHash.h> +#include <cmInstalledFile.h> #include <CPack/cmCPackLog.h> #include <CPack/cmCPackComponentGroup.h> #include "cmWIXSourceWriter.h" +#include "cmWIXDirectoriesSourceWriter.h" +#include "cmWIXFeaturesSourceWriter.h" +#include "cmWIXFilesSourceWriter.h" #include "cmWIXRichTextFormatWriter.h" #include <cmsys/SystemTools.hxx> @@ -28,31 +32,32 @@ #include <rpc.h> // for GUID generation -#include <sys/types.h> -#include <sys/stat.h> - cmCPackWIXGenerator::cmCPackWIXGenerator(): - HasDesktopShortcuts(false) + HasDesktopShortcuts(false), + Patch(0) { } +cmCPackWIXGenerator::~cmCPackWIXGenerator() +{ + if(this->Patch) + { + delete this->Patch; + } +} + int cmCPackWIXGenerator::InitializeInternal() { componentPackageMethod = ONE_PACKAGE; + this->Patch = new cmWIXPatch(this->Logger); 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 +86,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 +113,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 +126,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 +187,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 +217,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() { std::string defaultRef = "WixUI_InstallDir"; - if(Components.size()) + if(this->Components.size()) { defaultRef = "WixUI_FeatureTree"; } @@ -221,17 +225,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 +255,8 @@ bool cmCPackWIXGenerator::PackageFilesImpl() return false; } - if(!CreateWiXVariablesIncludeFile()) - { - return false; - } + CreateWiXVariablesIncludeFile(); + CreateWiXPropertiesIncludeFile(); if(!CreateWiXSourceFiles()) { @@ -257,9 +266,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 +291,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 +306,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 +331,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 +373,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 +384,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 +437,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 +471,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 +513,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 +565,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 +576,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 +590,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; - } + featureDefinitions.EmitFeatureForComponent(component); } } 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.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 +658,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 +689,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 +700,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.EmitShortcut(id, shortcut, false); - 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"); - - 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 +738,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 +747,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 +764,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 +812,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 +824,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 +867,18 @@ 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; + cmInstalledFile const* installedFile = + this->GetInstalledFile(relativePath); - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", directoryId); + std::string componentId = fileDefinitions.EmitComponentFile( + directoryId, id, fullPath, *(this->Patch), installedFile); - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", componentId); - fileDefinitions.AddAttribute("Guid", "*"); - - 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 +907,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 +955,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 +974,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 +983,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 +1037,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 +1060,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 +1091,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 +1107,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 +1121,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..8705d40 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 @@ -42,6 +35,7 @@ public: cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator); cmCPackWIXGenerator(); + ~cmCPackWIXGenerator(); protected: virtual int InitializeInternal(); @@ -78,48 +72,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 +112,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 +163,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/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx new file mode 100644 index 0000000..aeec968 --- /dev/null +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -0,0 +1,149 @@ +/*============================================================================ + 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 "cmWIXAccessControlList.h" + +#include <CPack/cmCPackGenerator.h> + +#include <cmSystemTools.h> + +cmWIXAccessControlList::cmWIXAccessControlList( + cmCPackLog *logger, + cmInstalledFile const& installedFile, + cmWIXSourceWriter &sourceWriter): + Logger(logger), + InstalledFile(installedFile), + SourceWriter(sourceWriter) +{ + +} + +bool cmWIXAccessControlList::Apply() +{ + std::vector<std::string> entries; + this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries); + + for(size_t i = 0; i < entries.size(); ++i) + { + this->CreatePermissionElement(entries[i]); + } + + return true; +} + +void cmWIXAccessControlList::CreatePermissionElement( + std::string const& entry) +{ + std::string::size_type pos = entry.find('='); + if(pos == std::string::npos) + { + this->ReportError(entry, "Did not find mandatory '='"); + return; + } + + std::string user_and_domain = entry.substr(0, pos); + std::string permission_string = entry.substr(pos + 1); + + pos = user_and_domain.find('@'); + std::string user; + std::string domain; + if(pos != std::string::npos) + { + user = user_and_domain.substr(0, pos); + domain = user_and_domain.substr(pos + 1); + } + else + { + user = user_and_domain; + } + + std::vector<std::string> permissions = + cmSystemTools::tokenize(permission_string, ","); + + this->SourceWriter.BeginElement("Permission"); + this->SourceWriter.AddAttribute("User", user); + if(domain.size()) + { + this->SourceWriter.AddAttribute("Domain", domain); + } + for(size_t i = 0; i < permissions.size(); ++i) + { + this->EmitBooleanAttribute(entry, + cmSystemTools::TrimWhitespace(permissions[i])); + } + this->SourceWriter.EndElement("Permission"); +} + +void cmWIXAccessControlList::ReportError( + std::string const& entry, + std::string const& message) +{ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed processing ACL entry '" << entry << + "': " << message << std::endl); +} + +bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name) +{ + static const char* validAttributes[] = + { + "Append", + "ChangePermission", + "CreateChild", + "CreateFile", + "CreateLink", + "CreateSubkeys", + "Delete", + "DeleteChild", + "EnumerateSubkeys", + "Execute", + "FileAllRights", + "GenericAll", + "GenericExecute", + "GenericRead", + "GenericWrite", + "Notify", + "Read", + "ReadAttributes", + "ReadExtendedAttributes", + "ReadPermission", + "SpecificRightsAll", + "Synchronize", + "TakeOwnership", + "Traverse", + "Write", + "WriteAttributes", + "WriteExtendedAttributes", + 0 + }; + + size_t i = 0; + while(validAttributes[i]) + { + if(name == validAttributes[i++]) return true; + } + + return false; +} + +void cmWIXAccessControlList::EmitBooleanAttribute( + std::string const& entry, std::string const& name) +{ + if(!this->IsBooleanAttribute(name)) + { + std::stringstream message; + message << "Unknown boolean attribute '" << name << "'"; + this->ReportError(entry, message.str()); + } + + this->SourceWriter.AddAttribute(name, "yes"); +} diff --git a/Source/CPack/WiX/cmWIXAccessControlList.h b/Source/CPack/WiX/cmWIXAccessControlList.h new file mode 100644 index 0000000..20902f7 --- /dev/null +++ b/Source/CPack/WiX/cmWIXAccessControlList.h @@ -0,0 +1,46 @@ +/*============================================================================ + 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 cmWIXAccessControlList_h +#define cmWIXAccessControlList_h + +#include <cmInstalledFile.h> +#include <CPack/cmCPackLog.h> + +#include "cmWIXSourceWriter.h" + +class cmWIXAccessControlList +{ +public: + cmWIXAccessControlList( + cmCPackLog *logger, + cmInstalledFile const& installedFile, + cmWIXSourceWriter &sourceWriter); + + bool Apply(); + +private: + void CreatePermissionElement(std::string const& entry); + + void ReportError(std::string const& entry, std::string const& message); + + bool IsBooleanAttribute(std::string const& name); + + void EmitBooleanAttribute( + std::string const& entry, std::string const& name); + + cmCPackLog* Logger; + cmInstalledFile const& InstalledFile; + cmWIXSourceWriter &SourceWriter; +}; + +#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..0ad5d0c --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -0,0 +1,193 @@ +/*============================================================================ + 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 "cmWIXAccessControlList.h" + +#include <cmInstalledFile.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, + cmInstalledFile const* installedFile) +{ + 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", "*"); + + if(installedFile) + { + if(installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) + { + AddAttribute("NeverOverwrite", "yes"); + } + if(installedFile->GetPropertyAsBool("CPACK_PERMANENT")) + { + AddAttribute("Permanent", "yes"); + } + } + + 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"); + } + + if(installedFile) + { + cmWIXAccessControlList acl(Logger, *installedFile, *this); + acl.Apply(); + } + + 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..23ef561 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -0,0 +1,67 @@ +/*============================================================================ + 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, + cmInstalledFile const* installedFile); + +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..ef67b23 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -34,12 +34,11 @@ cmWIXPatchParser::cmWIXPatchParser( } -void cmWIXPatchParser::StartElement(const char *name, const char **atts) +void cmWIXPatchParser::StartElement(const std::string& name, const char **atts) { - std::string name_str = name; if(State == BEGIN_DOCUMENT) { - if(name_str == "CPackWiXPatch") + if(name == "CPackWiXPatch") { State = BEGIN_FRAGMENTS; } @@ -50,7 +49,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts) } else if(State == BEGIN_FRAGMENTS) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = INSIDE_FRAGMENT; StartFragment(atts); @@ -107,12 +106,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes) } } -void cmWIXPatchParser::EndElement(const char *name) +void cmWIXPatchParser::EndElement(const std::string& name) { - std::string name_str = name; if(State == INSIDE_FRAGMENT) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = BEGIN_FRAGMENTS; ElementStack.clear(); @@ -132,7 +130,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..acfb4c0 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -43,14 +43,14 @@ public: cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); private: - virtual void StartElement(const char *name, const char **atts); + virtual void StartElement(const std::string& name, const char **atts); void StartFragment(const char **attributes); - virtual void EndElement(const char *name); + virtual void EndElement(const std::string& 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..3957d96 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -26,24 +26,27 @@ 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); + +protected: + cmCPackLog* Logger; private: enum State @@ -56,9 +59,7 @@ private: void Indent(size_t count); - static std::string EscapeAttributeValue(const std::string& value); - - cmCPackLog* Logger; + static std::string EscapeAttributeValue(std::string const& value); cmsys::ofstream File; diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx new file mode 100644 index 0000000..ce31ad4 --- /dev/null +++ b/Source/CPack/cmCPack7zGenerator.cxx @@ -0,0 +1,25 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmCPack7zGenerator.h" + +//---------------------------------------------------------------------- +cmCPack7zGenerator::cmCPack7zGenerator() + :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, + cmArchiveWrite::Type7Zip) +{ +} + +//---------------------------------------------------------------------- +cmCPack7zGenerator::~cmCPack7zGenerator() +{ +} diff --git a/Source/CPack/cmCPack7zGenerator.h b/Source/CPack/cmCPack7zGenerator.h new file mode 100644 index 0000000..f5a323f --- /dev/null +++ b/Source/CPack/cmCPack7zGenerator.h @@ -0,0 +1,36 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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 cmCPack7zGenerator_h +#define cmCPack7zGenerator_h + +#include "cmCPackArchiveGenerator.h" + +/** \class cmCPack7zGenerator + * \brief A generator for 7z files + */ +class cmCPack7zGenerator : public cmCPackArchiveGenerator +{ +public: + cmCPackTypeMacro(cmCPack7zGenerator, cmCPackArchiveGenerator); + + /** + * Construct generator + */ + cmCPack7zGenerator(); + virtual ~cmCPack7zGenerator(); + +protected: + virtual const char* GetOutputExtension() { return ".7z"; } +}; + +#endif diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index f93eca8..77f11cb 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -16,7 +16,8 @@ #include <string> //---------------------------------------------------------------------- -unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const +unsigned long cmCPackComponent::GetInstalledSize( + const std::string& installDir) const { if (this->TotalSize != 0) { @@ -37,7 +38,7 @@ unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const //---------------------------------------------------------------------- unsigned long -cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const +cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const { unsigned long result = (GetInstalledSize(installDir) + 512) / 1024; return result? result : 1; diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index abae372..0679638 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -94,11 +94,11 @@ public: /// Get the total installed size of all of the files in this /// component, in bytes. installDir is the directory into which the /// component was installed. - unsigned long GetInstalledSize(const char* installDir) const; + unsigned long GetInstalledSize(const std::string& installDir) const; /// Identical to GetInstalledSize, but returns the result in /// kilobytes. - unsigned long GetInstalledSizeInKbytes(const char* installDir) const; + unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const; private: mutable unsigned long TotalSize; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0162d55..936942b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -403,9 +403,39 @@ int cmCPackDebGenerator::createDeb() if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz data.tar.gz "; + + const char* debian_compression_type = + this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE"); + if(!debian_compression_type) + { + debian_compression_type = "gzip"; + } + + std::string cmake_tar = " ", compression_modifier = "a", compression_suffix; + if(!strcmp(debian_compression_type, "lzma")) { + compression_suffix = ".lzma"; + } else if(!strcmp(debian_compression_type, "xz")) { + compression_suffix = ".xz"; + } else if(!strcmp(debian_compression_type, "bzip2")) { + compression_suffix = ".bz2"; + compression_modifier = "j"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "gzip")) { + compression_suffix = ".gz"; + compression_modifier = "z"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "none")) { + compression_suffix = ""; + compression_modifier = ""; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error unrecognized compression type: " + << debian_compression_type << std::endl); + } + + cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar" + + compression_suffix; // now add all directories which have to be compressed // collect all top level install dirs for that @@ -444,13 +474,13 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -493,9 +523,7 @@ int cmCPackDebGenerator::createDeb() { cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; + cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums"; const char* controlExtra = this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) @@ -506,7 +534,7 @@ int cmCPackDebGenerator::createDeb() controlExtraList.begin(); i != controlExtraList.end(); ++i) { std::string filenamename = - cmsys::SystemTools::GetFilenameName(i->c_str()); + cmsys::SystemTools::GetFilenameName(*i); std::string localcopy = this->GetOption("WDIR"); localcopy += "/"; localcopy += filenamename; @@ -514,7 +542,7 @@ int cmCPackDebGenerator::createDeb() if( cmsys::SystemTools::CopyFileIfDifferent( i->c_str(), localcopy.c_str()) ) { - // debian is picky and need relative to ./ path in the tar.gz + // debian is picky and need relative to ./ path in the tar.* cmd += " ./"; cmd += filenamename; } @@ -528,17 +556,17 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } - // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz + // ar -r your-package-name.deb debian-binary control.tar.* data.tar.* // since debian packages require BSD ar (most Linux distros and even // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. std::vector<std::string> arFiles; @@ -546,7 +574,7 @@ int cmCPackDebGenerator::createDeb() topLevelString += "/"; arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); - arFiles.push_back(topLevelString + "data.tar.gz"); + arFiles.push_back(topLevelString + "data.tar" + compression_suffix); std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); outputFileName += "/"; outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME"); @@ -588,9 +616,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 96491aa..1461bb1 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -254,7 +254,7 @@ int cmCPackGenerator::InstallProject() // If the project is a CMAKE project then run pre-install // and then read the cmake_install script to run it if ( !this->InstallProjectViaInstallCMakeProjects( - setDestDir, bareTempInstallDirectory.c_str()) ) + setDestDir, bareTempInstallDirectory) ) { return 0; } @@ -269,7 +269,7 @@ int cmCPackGenerator::InstallProject() //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void) setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); @@ -285,7 +285,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( it != installCommandsVector.end(); ++it ) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl); std::string output; int retVal = 1; @@ -296,12 +296,12 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << it->c_str() << std::endl + ofs << "# Run command: " << *it << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << it->c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + "Problem running install command: " << *it << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -312,7 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void)setDestDir; (void)tempInstallDirectory; @@ -329,7 +329,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ++it ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, - "Create ignore files regex for: " << it->c_str() << std::endl); + "Create ignore files regex for: " << *it << std::endl); ignoreFilesRegex.push_back(it->c_str()); } } @@ -349,7 +349,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( return 0; } std::vector<std::string>::iterator it; - const char* tempDir = tempInstallDirectory; + const std::string& tempDir = tempInstallDirectory; for ( it = installDirectoriesVector.begin(); it != installDirectoriesVector.end(); ++it ) @@ -357,9 +357,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::list<std::pair<std::string,std::string> > symlinkedFiles; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string top = it->c_str(); + std::string top = *it; it ++; - std::string subdir = it->c_str(); + std::string subdir = *it; std::string findExpr = top; findExpr += "/*"; cmCPackLogger(cmCPackLog::LOG_OUTPUT, @@ -385,7 +385,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( if ( regIt->find(inFile.c_str()) ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); skip = true; } } @@ -397,7 +397,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ if ( cmSystemTools::FileIsSymlink(inFile.c_str())) { @@ -416,7 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); return 0; } } @@ -457,7 +457,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT"); @@ -473,7 +473,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( it != cmakeScriptsVector.end(); ++it ) { - std::string installScript = it->c_str(); + std::string installScript = *it; cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install script: " << installScript << std::endl); @@ -499,7 +499,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } else { - this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory); + this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Using non-DESTDIR install... (this->SetOption)" << std::endl); @@ -509,9 +509,9 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); int res = this->MakefileMap->ReadListFile(0, installScript.c_str()); if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { @@ -524,7 +524,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* baseTempInstallDirectory) + bool setDestDir, const std::string& baseTempInstallDirectory) { const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); @@ -562,13 +562,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << std::endl); return 0; } - std::string installDirectory = it->c_str(); + std::string installDirectory = *it; ++it; - std::string installProjectName = it->c_str(); + std::string installProjectName = *it; ++it; - std::string installComponent = it->c_str(); + std::string installComponent = *it; ++it; - std::string installSubDirectory = it->c_str(); + std::string installSubDirectory = *it; std::string installFile = installDirectory + "/cmake_install.cmake"; std::vector<std::string> componentsVector; @@ -586,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES"; - const char *installTypes = this->GetOption(installTypesVar.c_str()); + const char *installTypes = this->GetOption(installTypesVar); if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; @@ -596,15 +596,15 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( installTypeIt != installTypesVector.end(); ++installTypeIt) { - this->GetInstallationType(installProjectName.c_str(), - installTypeIt->c_str()); + this->GetInstallationType(installProjectName, + *installTypeIt); } } // Determine the set of components that will be used in this project std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent); - const char *components = this->GetOption(componentsVar.c_str()); + const char *components = this->GetOption(componentsVar); if (components && *components) { cmSystemTools::ExpandListArgument(components, componentsVector); @@ -613,7 +613,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( compIt != componentsVector.end(); ++compIt) { - GetComponent(installProjectName.c_str(), compIt->c_str()); + GetComponent(installProjectName, *compIt); } componentInstall = true; } @@ -623,7 +623,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( componentsVector.push_back(installComponent); } - const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG"); + const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); + std::string buildConfig = buildConfigCstr ? buildConfigCstr : ""; cmGlobalGenerator* globalGenerator = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( cmakeGenerator); @@ -636,11 +637,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if ( globalGenerator->GetPreinstallTargetName() ) { globalGenerator->FindMakeProgram(this->MakefileMap); - const char* cmakeMakeProgram - = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); + std::string cmakeMakeProgram + = this->MakefileMap->GetSafeDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> buildCommand; globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, - installProjectName.c_str(), installDirectory.c_str(), + installProjectName, installDirectory, globalGenerator->GetPreinstallTargetName(), buildConfig, false); std::string buildCommandStr = @@ -662,14 +663,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommandStr.c_str() << std::endl - << "# Directory: " << installDirectory.c_str() << std::endl + ofs << "# Run command: " << buildCommandStr << std::endl + << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommandStr.c_str() + "Problem running install command: " << buildCommandStr << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -822,9 +823,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << "'" << std::endl); } - if ( buildConfig && *buildConfig ) + if (!buildConfig.empty()) { - mf->AddDefinition("BUILD_TYPE", buildConfig); + mf->AddDefinition("BUILD_TYPE", buildConfig.c_str()); } std::string installComponentLowerCase = cmSystemTools::LowerCase(installComponent); @@ -931,19 +932,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string absoluteDestFileComponent = std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + GetComponentInstallDirNameSuffix(installComponent); - if (NULL != this->GetOption(absoluteDestFileComponent.c_str())) + if (NULL != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = - this->GetOption(absoluteDestFileComponent.c_str()); + this->GetOption(absoluteDestFileComponent); absoluteDestFilesListComponent +=";"; absoluteDestFilesListComponent += mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); } } @@ -972,7 +973,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOptionIfNotSet(const char* op, +void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { const char* def = this->MakefileMap->GetDefinition(op); @@ -984,12 +985,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op, } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOption(const char* op, const char* value) +void cmCPackGenerator::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { this->MakefileMap->RemoveDefinition(op); @@ -1004,7 +1001,7 @@ void cmCPackGenerator::SetOption(const char* op, const char* value) int cmCPackGenerator::DoPackage() { cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "Create package using " << this->Name.c_str() << std::endl); + "Create package using " << this->Name << std::endl); // Prepare CPack internal name and check // values for many CPACK_xxx vars @@ -1052,7 +1049,6 @@ int cmCPackGenerator::DoPackage() const char* tempPackageFileName = this->GetOption( "CPACK_TEMPORARY_PACKAGE_FILE_NAME"); - const char* packageFileName = this->GetOption("CPACK_OUTPUT_FILE_PATH"); const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); @@ -1092,7 +1088,7 @@ int cmCPackGenerator::DoPackage() * may update this during PackageFiles. * (either putting several names or updating the provided one) */ - packageFileNames.push_back(tempPackageFileName); + packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : ""); toplevel = tempDirectory; if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { @@ -1117,7 +1113,7 @@ int cmCPackGenerator::DoPackage() std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); tempPackageFileName = it->c_str(); tmpPF += "/"+cmSystemTools::GetFilenameName(*it); - packageFileName = tmpPF.c_str(); + const char* packageFileName = tmpPF.c_str(); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): " << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) << " to " @@ -1142,7 +1138,7 @@ int cmCPackGenerator::DoPackage() } //---------------------------------------------------------------------- -int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; @@ -1176,19 +1172,19 @@ int cmCPackGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsSet(const char* name) const +bool cmCPackGenerator::IsSet(const std::string& name) const { return this->MakefileMap->IsSet(name); } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsOn(const char* name) const +bool cmCPackGenerator::IsOn(const std::string& name) const { return cmSystemTools::IsOn(GetOption(name)); } //---------------------------------------------------------------------- -const char* cmCPackGenerator::GetOption(const char* op) const +const char* cmCPackGenerator::GetOption(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); if(!ret) @@ -1202,6 +1198,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; @@ -1266,7 +1268,7 @@ std::string cmCPackGenerator::FindTemplate(const char* name) << (name ? name : "(NULL)") << std::endl); std::string ffile = this->MakefileMap->GetModulesFile(name); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " - << ffile.c_str() << std::endl); + << ffile << std::endl); return ffile; } @@ -1311,6 +1313,14 @@ int cmCPackGenerator::CleanTemporaryDirectory() } //---------------------------------------------------------------------- +cmInstalledFile const* cmCPackGenerator::GetInstalledFile( + std::string const& name) const +{ + cmake const* cm = this->MakefileMap->GetCMakeInstance(); + return cm->GetInstalledFile(name); +} + +//---------------------------------------------------------------------- int cmCPackGenerator::PrepareGroupingKind() { // find a component package method specified by the user @@ -1425,14 +1435,14 @@ std::string cmCPackGenerator::GetComponentPackageFileName( std::string suffix="-"+groupOrComponentName; /* check if we should use DISPLAY name */ std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME"; - if (IsOn(dispNameVar.c_str())) + if (IsOn(dispNameVar)) { /* the component Group case */ if (isGroupName) { std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* groupDispName = GetOption(groupDispVar.c_str()); + const char* groupDispName = GetOption(groupDispVar); if (groupDispName) { suffix = "-"+std::string(groupDispName); @@ -1443,7 +1453,7 @@ std::string cmCPackGenerator::GetComponentPackageFileName( { std::string dispVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* dispName = GetOption(dispVar.c_str()); + const char* dispName = GetOption(dispVar); if(dispName) { suffix = "-"+std::string(dispName); @@ -1480,8 +1490,8 @@ bool cmCPackGenerator::WantsComponentInstallation() const //---------------------------------------------------------------------- cmCPackInstallationType* -cmCPackGenerator::GetInstallationType(const char *projectName, - const char *name) +cmCPackGenerator::GetInstallationType(const std::string& projectName, + const std::string& name) { (void) projectName; bool hasInstallationType = this->InstallationTypes.count(name) != 0; @@ -1494,7 +1504,7 @@ cmCPackGenerator::GetInstallationType(const char *projectName, installType->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { installType->DisplayName = displayName; @@ -1512,7 +1522,8 @@ cmCPackGenerator::GetInstallationType(const char *projectName, //---------------------------------------------------------------------- cmCPackComponent* -cmCPackGenerator::GetComponent(const char *projectName, const char *name) +cmCPackGenerator::GetComponent(const std::string& projectName, + const std::string& name) { bool hasComponent = this->Components.count(name) != 0; cmCPackComponent *component = &this->Components[name]; @@ -1523,7 +1534,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) + cmsys::SystemTools::UpperCase(name); component->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { component->DisplayName = displayName; @@ -1533,23 +1544,23 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) component->DisplayName = component->Name; } component->IsHidden - = this->IsOn((macroPrefix + "_HIDDEN").c_str()); + = this->IsOn(macroPrefix + "_HIDDEN"); component->IsRequired - = this->IsOn((macroPrefix + "_REQUIRED").c_str()); + = this->IsOn(macroPrefix + "_REQUIRED"); component->IsDisabledByDefault - = this->IsOn((macroPrefix + "_DISABLED").c_str()); + = this->IsOn(macroPrefix + "_DISABLED"); component->IsDownloaded - = this->IsOn((macroPrefix + "_DOWNLOADED").c_str()) + = this->IsOn(macroPrefix + "_DOWNLOADED") || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); - const char* archiveFile = this->GetOption((macroPrefix + - "_ARCHIVE_FILE").c_str()); + const char* archiveFile = this->GetOption(macroPrefix + + "_ARCHIVE_FILE"); if (archiveFile && *archiveFile) { component->ArchiveFile = archiveFile; } - const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str()); + const char* groupName = this->GetOption(macroPrefix + "_GROUP"); if (groupName && *groupName) { component->Group = GetComponentGroup(projectName, groupName); @@ -1561,7 +1572,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { component->Description = description; @@ -1569,7 +1580,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) // Determine the installation types. const char *installTypes - = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str()); + = this->GetOption(macroPrefix + "_INSTALL_TYPES"); if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; @@ -1580,12 +1591,12 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) ++installTypesIt) { component->InstallationTypes.push_back( - this->GetInstallationType(projectName, installTypesIt->c_str())); + this->GetInstallationType(projectName, *installTypesIt)); } } // Determine the component dependencies. - const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str()); + const char *depends = this->GetOption(macroPrefix + "_DEPENDS"); if (depends && *depends) { std::vector<std::string> dependsVector; @@ -1596,7 +1607,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) ++dependIt) { cmCPackComponent *child = GetComponent(projectName, - dependIt->c_str()); + *dependIt); component->Dependencies.push_back(child); child->ReverseDependencies.push_back(component); } @@ -1607,7 +1618,8 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) //---------------------------------------------------------------------- cmCPackComponentGroup* -cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) +cmCPackGenerator::GetComponentGroup(const std::string& projectName, + const std::string& name) { (void) projectName; std::string macroPrefix = "CPACK_COMPONENT_GROUP_" @@ -1619,7 +1631,7 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) // Define the group group->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { group->DisplayName = displayName; @@ -1630,17 +1642,17 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { group->Description = description; } group->IsBold - = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str()); + = this->IsOn(macroPrefix + "_BOLD_TITLE"); group->IsExpandedByDefault - = this->IsOn((macroPrefix + "_EXPANDED").c_str()); + = this->IsOn(macroPrefix + "_EXPANDED"); const char* parentGroupName - = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); + = this->GetOption(macroPrefix + "_PARENT_GROUP"); if (parentGroupName && *parentGroupName) { group->ParentGroup = GetComponentGroup(projectName, parentGroupName); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index bb33aa0..ed89b53 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -22,9 +22,10 @@ // Forward declarations are insufficient since we use them in // std::map data members below... -#define cmCPackTypeMacro(class, superclass) \ - cmTypeMacro(class, superclass); \ - static cmCPackGenerator* CreateGenerator() { return new class; } +#define cmCPackTypeMacro(klass, superclass) \ + cmTypeMacro(klass, superclass); \ + static cmCPackGenerator* CreateGenerator() { return new klass; } \ + class cmCPackTypeMacro_UseTrailingSemicolon #define cmCPackLogger(logType, msg) \ do { \ @@ -46,6 +47,7 @@ class cmMakefile; class cmCPackLog; +class cmInstalledFile; /** \class cmCPackGenerator * \brief A superclass of all CPack Generators @@ -90,7 +92,7 @@ public: /** * Initialize generator */ - int Initialize(const char* name, cmMakefile* mf); + int Initialize(const std::string& name, cmMakefile* mf); /** * Construct generator @@ -99,11 +101,12 @@ public: virtual ~cmCPackGenerator(); //! Set and get the options - void SetOption(const char* op, const char* value); - void SetOptionIfNotSet(const char* op, const char* value); - const char* GetOption(const char* op) const; - bool IsSet(const char* name) const; - bool IsOn(const char* name) const; + void SetOption(const std::string& op, const char* value); + void SetOptionIfNotSet(const std::string& op, const char* value); + const char* GetOption(const std::string& op) const; + std::vector<std::string> GetOptions() const; + bool IsSet(const std::string& name) const; + bool IsOn(const std::string& name) const; //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -127,6 +130,8 @@ protected: int CleanTemporaryDirectory(); + cmInstalledFile const* GetInstalledFile(std::string const& name) const; + virtual const char* GetOutputExtension() { return ".cpack"; } virtual const char* GetOutputPostfix() { return 0; } @@ -189,13 +194,13 @@ protected: //! Run install commands if specified virtual int InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); /** * The various level of support of @@ -244,12 +249,14 @@ protected: * @return true if component installation is supported and wanted. */ virtual bool WantsComponentInstallation() const; - virtual cmCPackInstallationType* GetInstallationType(const char *projectName, - const char* name); - virtual cmCPackComponent* GetComponent(const char *projectName, - const char* name); - virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, - const char* name); + virtual cmCPackInstallationType* GetInstallationType( + const std::string& projectName, + const std::string& name); + virtual cmCPackComponent* GetComponent(const std::string& projectName, + const std::string& name); + virtual cmCPackComponentGroup* GetComponentGroup( + const std::string& projectName, + const std::string& name); cmSystemTools::OutputOption GeneratorVerbose; std::string Name; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index b36c2a2..c8737f4 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -14,11 +14,14 @@ #include "cmCPackGenerator.h" #include "cmCPackTGZGenerator.h" +#include "cmCPackTXZGenerator.h" #include "cmCPackTarBZip2Generator.h" #include "cmCPackTarCompressGenerator.h" #include "cmCPackZIPGenerator.h" +#include "cmCPack7zGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackNSISGenerator.h" +#include "IFW/cmCPackIFWGenerator.h" #ifdef __APPLE__ # include "cmCPackDragNDropGenerator.h" @@ -56,6 +59,11 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("TGZ", "Tar GZip compression", cmCPackTGZGenerator::CreateGenerator); } + if (cmCPackTXZGenerator::CanGenerate()) + { + this->RegisterGenerator("TXZ", "Tar XZ compression", + cmCPackTXZGenerator::CreateGenerator); + } if (cmCPackSTGZGenerator::CanGenerate()) { this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", @@ -68,6 +76,11 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)", cmCPackNSISGenerator::CreateGenerator64); } + if (cmCPackIFWGenerator::CanGenerate()) + { + this->RegisterGenerator("IFW", "Qt Installer Framework", + cmCPackIFWGenerator::CreateGenerator); + } #ifdef __CYGWIN__ if (cmCPackCygwinBinaryGenerator::CanGenerate()) { @@ -86,6 +99,11 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("ZIP", "ZIP file format", cmCPackZIPGenerator::CreateGenerator); } + if (cmCPack7zGenerator::CanGenerate()) + { + this->RegisterGenerator("7Z", "7-Zip file format", + cmCPack7zGenerator::CreateGenerator); + } #ifdef _WIN32 if (cmCPackWIXGenerator::CanGenerate()) { @@ -151,7 +169,8 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory() } //---------------------------------------------------------------------- -cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) +cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( + const std::string& name) { cmCPackGenerator* gen = this->NewGeneratorInternal(name); if ( !gen ) @@ -165,12 +184,8 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) //---------------------------------------------------------------------- cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( - const char* name) + const std::string& name) { - if ( !name ) - { - return 0; - } cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it = this->GeneratorCreators.find(name); if ( it == this->GeneratorCreators.end() ) @@ -181,11 +196,11 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( } //---------------------------------------------------------------------- -void cmCPackGeneratorFactory::RegisterGenerator(const char* name, +void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator) { - if ( !name || !createGenerator ) + if ( !createGenerator ) { cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR, "Cannot register generator" << std::endl); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index dff2e49..010777f 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -31,26 +31,26 @@ public: ~cmCPackGeneratorFactory(); //! Get the generator - cmCPackGenerator* NewGenerator(const char* name); + cmCPackGenerator* NewGenerator(const std::string& name); void DeleteGenerator(cmCPackGenerator* gen); typedef cmCPackGenerator* CreateGeneratorCall(); - void RegisterGenerator(const char* name, + void RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator); void SetLogger(cmCPackLog* logger) { this->Logger = logger; } - typedef std::map<cmStdString, cmStdString> DescriptionsMap; + typedef std::map<std::string, std::string> DescriptionsMap; const DescriptionsMap& GetGeneratorsList() const { return this->GeneratorDescriptions; } private: - cmCPackGenerator* NewGeneratorInternal(const char* name); + cmCPackGenerator* NewGeneratorInternal(const std::string& name); std::vector<cmCPackGenerator*> Generators; - typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap; + typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; cmCPackLog* Logger; diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 4e8bf0f..7befca0 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -169,27 +169,27 @@ void cmCPackLog::Log(int tag, const char* file, int line, { if ( error && !this->ErrorPrefix.empty() ) { - *this->DefaultError << this->ErrorPrefix.c_str(); + *this->DefaultError << this->ErrorPrefix; } else if ( warning && !this->WarningPrefix.empty() ) { - *this->DefaultError << this->WarningPrefix.c_str(); + *this->DefaultError << this->WarningPrefix; } else if ( output && !this->OutputPrefix.empty() ) { - *this->DefaultOutput << this->OutputPrefix.c_str(); + *this->DefaultOutput << this->OutputPrefix; } else if ( verbose && !this->VerbosePrefix.empty() ) { - *this->DefaultOutput << this->VerbosePrefix.c_str(); + *this->DefaultOutput << this->VerbosePrefix; } else if ( debug && !this->DebugPrefix.empty() ) { - *this->DefaultOutput << this->DebugPrefix.c_str(); + *this->DefaultOutput << this->DebugPrefix; } else if ( !this->Prefix.empty() ) { - *this->DefaultOutput << this->Prefix.c_str(); + *this->DefaultOutput << this->Prefix; } if ( useFileAndLine ) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 62bfa91..a5eee6b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -83,10 +83,10 @@ int cmCPackNSISGenerator::PackageFiles() fileN = fileN.substr(fileN.find('/')+1, std::string::npos); } cmSystemTools::ReplaceString(fileN, "/", "\\"); - str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl; } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " - << str.str().c_str() << std::endl); + << str.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector<std::string> dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); @@ -117,14 +117,14 @@ int cmCPackNSISGenerator::PackageFiles() } } cmSystemTools::ReplaceString(fileN, "/", "\\"); - dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl; if (!componentName.empty()) { this->Components[componentName].Directories.push_back(fileN); } } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " - << dstr.str().c_str() << std::endl); + << dstr.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); @@ -320,7 +320,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisCmd = "\""; nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); nsisCmd += "\" \"" + nsisFileName + "\""; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl); std::string output; int retVal = 1; @@ -329,12 +329,12 @@ int cmCPackNSISGenerator::PackageFiles() if ( !res || retVal ) { cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } return 1; @@ -427,7 +427,7 @@ int cmCPackNSISGenerator::InitializeInternal() std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION"; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " - << nsisCmd.c_str() << std::endl); + << nsisCmd << std::endl); std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), @@ -442,13 +442,13 @@ int cmCPackNSISGenerator::InitializeInternal() std::string tmpFile = topDir ? topDir : "."; tmpFile += "/NSISOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } if ( versionRex.find(output)) @@ -470,7 +470,7 @@ int cmCPackNSISGenerator::InitializeInternal() { // No version check for NSIS cvs build cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS " - << versionRexCVS.match(1).c_str() << std::endl); + << versionRexCVS.match(1) << std::endl); } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); @@ -588,8 +588,8 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, return; } - cmsys::RegularExpression urlRegex; - urlRegex.compile("^(mailto:|(ftps?|https?|news)://).*$"); + static cmsys::RegularExpression + urlRegex("^(mailto:|(ftps?|https?|news)://).*$"); std::vector<std::string>::iterator it; for ( it = cpackMenuLinksVector.begin(); @@ -629,7 +629,7 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, // if so add a desktop link std::string desktop = "CPACK_CREATE_DESKTOP_LINK_"; desktop += linkName; - if(this->IsSet(desktop.c_str())) + if(this->IsSet(desktop)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" @@ -844,12 +844,12 @@ CreateComponentDescription(cmCPackComponent *component, std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/CompressZip.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return ""; } @@ -891,7 +891,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " Delete \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } for (pathIt = component->Directories.begin(); @@ -901,7 +901,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " RMDir \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } macrosOut << " noremove_" << component->Name << ":\n"; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 76e15fb..28c7f1d 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -227,7 +227,7 @@ int cmCPackOSXX11Generator::InitializeInternal() //---------------------------------------------------------------------- /* -bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) +bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -271,8 +271,8 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) */ //---------------------------------------------------------------------- -bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, - const char* dir, const char* outputFileName /* = 0 */, +bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name, + const std::string& dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { std::string inFName = "CPack."; @@ -288,7 +288,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, if ( !outputFileName ) { - outputFileName = name; + outputFileName = name.c_str(); } std::string destFileName = dir; diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index b7bd243..9d0a6d1 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -37,8 +37,9 @@ protected: virtual const char* GetPackagingInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } - //bool CopyCreateResourceFile(const char* name, const char* dir); - bool CopyResourcePlistFile(const char* name, const char* dir, + //bool CopyCreateResourceFile(const std::string& name, + // const std::string& dir); + bool CopyResourcePlistFile(const std::string& name, const std::string& dir, const char* outputFileName = 0, bool copyOnly = false); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index c5b9c6f..d736948 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -43,14 +43,14 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, - const char* script, - const char* name) +int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name) { std::string dst = resdir; dst += "/"; dst += name; - cmSystemTools::CopyFileAlways(script, dst.c_str()); + cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str()); cmSystemTools::SetPermissions(dst.c_str(),0777); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : " << script << "\ninto " << dst.c_str() << @@ -553,8 +553,9 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, - const char* dirName) +bool cmCPackPackageMakerGenerator::CopyCreateResourceFile( + const std::string& name, + const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -563,7 +564,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str() << " not specified. It should point to " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "<empty>") << ".rtf, " << name << ".html, or " << name << ".txt file" << std::endl); return false; @@ -571,7 +572,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, if ( !cmSystemTools::FileExists(inFileName) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "<empty>") << " resource file: " << inFileName << std::endl); return false; } @@ -600,12 +601,13 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, return true; } -bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name, - const char* outName) +bool cmCPackPackageMakerGenerator::CopyResourcePlistFile( + const std::string& name, + const char* outName) { if (!outName) { - outName = name; + outName = name.c_str(); } std::string inFName = "CPack."; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index ba3d968..e350a60 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -38,9 +38,9 @@ public: virtual bool SupportsComponentInstallation() const; protected: - int CopyInstallScript(const char* resdir, - const char* script, - const char* name); + int CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name); virtual int InitializeInternal(); int PackageFiles(); virtual const char* GetOutputExtension() { return ".dmg"; } @@ -51,8 +51,9 @@ protected: // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased // version of name) specifies the input file to use for this file, // which will be configured via ConfigureFile. - bool CopyCreateResourceFile(const char* name, const char *dirName); - bool CopyResourcePlistFile(const char* name, const char* outName = 0); + bool CopyCreateResourceFile(const std::string& name, + const std::string& dirName); + bool CopyResourcePlistFile(const std::string& name, const char* outName = 0); // Run PackageMaker with the given command line, which will (if // successful) produce the given package file. Returns true if diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 66a4194..c6171dc 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -272,9 +272,9 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 8342fee..6c1d201 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -43,7 +43,7 @@ int cmCPackSTGZGenerator::InitializeInternal() if ( inFile.empty() ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); @@ -134,6 +134,6 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmSystemTools::ReplaceString(res, headerLengthTag, buffer); // Write in file - *os << res.c_str(); + *os << res; return this->Superclass::GenerateHeader(os); } diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx new file mode 100644 index 0000000..ecfc177 --- /dev/null +++ b/Source/CPack/cmCPackTXZGenerator.cxx @@ -0,0 +1,25 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmCPackTXZGenerator.h" + +//---------------------------------------------------------------------- +cmCPackTXZGenerator::cmCPackTXZGenerator() + :cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, + cmArchiveWrite::TypeTAR) +{ +} + +//---------------------------------------------------------------------- +cmCPackTXZGenerator::~cmCPackTXZGenerator() +{ +} diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h new file mode 100644 index 0000000..bf8152f --- /dev/null +++ b/Source/CPack/cmCPackTXZGenerator.h @@ -0,0 +1,35 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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 cmCPackTXZGenerator_h +#define cmCPackTXZGenerator_h + +#include "cmCPackArchiveGenerator.h" + +/** \class cmCPackTXZGenerator + * \brief A generator for TXZ files + * + */ +class cmCPackTXZGenerator : public cmCPackArchiveGenerator +{ +public: + cmCPackTypeMacro(cmCPackTXZGenerator, cmCPackArchiveGenerator); + /** + * Construct generator + */ + cmCPackTXZGenerator(); + virtual ~cmCPackTXZGenerator(); +protected: + virtual const char* GetOutputExtension() { return ".tar.xz"; } +}; + +#endif diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a19b778..c57028d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -26,6 +26,7 @@ #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> #include <cmsys/Encoding.hxx> +#include <locale.h> //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -68,7 +69,7 @@ int cpackUnknownArgument(const char*, void*) //---------------------------------------------------------------------------- struct cpackDefinitions { - typedef std::map<cmStdString, cmStdString> MapType; + typedef std::map<std::string, std::string> MapType; MapType Map; cmCPackLog *Log; }; @@ -91,7 +92,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, value = value.c_str() + pos + 1; def->Map[key] = value; cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " - << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl); + << key << " to \"" << value << "\"" << std::endl); return 1; } @@ -100,6 +101,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, // this is CPack. int main (int argc, char const* const* argv) { + setlocale(LC_CTYPE, ""); cmsys::Encoding::CommandLineArguments args = cmsys::Encoding::CommandLineArguments::Main(argc, argv); argc = args.argc(); @@ -195,7 +197,7 @@ int main (int argc, char const* const* argv) } cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack config file: " << cpackConfigFile.c_str() << std::endl); + "Read CPack config file: " << cpackConfigFile << std::endl); cmake cminst; cminst.RemoveUnscriptableCommands(); @@ -257,26 +259,31 @@ int main (int argc, char const* const* argv) return 1; } + if ( !cpackBuildConfig.empty() ) + { + globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); + } + if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) { cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack configuration file: " << cpackConfigFile.c_str() + "Read CPack configuration file: " << cpackConfigFile << std::endl); if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" - << cpackConfigFile.c_str() << "\"" << std::endl); + << cpackConfigFile << "\"" << std::endl); return 1; } } else if ( cpackConfigFileSpecified ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, - "Cannot find CPack config file: \"" << cpackConfigFile.c_str() - << "\"" << std::endl); + "Cannot find CPack config file: \"" << + cpackConfigFile << "\"" << std::endl); return 1; } @@ -317,16 +324,12 @@ int main (int argc, char const* const* argv) cpackProjectDirectory.c_str()); } } - if ( !cpackBuildConfig.empty() ) - { - globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); - } cpackDefinitions::MapType::iterator cdit; for ( cdit = definitions.Map.begin(); cdit != definitions.Map.end(); ++cdit ) { - globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str()); + globalMF->AddDefinition(cdit->first, cdit->second.c_str()); } const char* cpackModulesPath = @@ -340,7 +343,6 @@ int main (int argc, char const* const* argv) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl); - parsed = 0; } else { |