diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:14:03 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:14:03 +0900 |
commit | d140263a497b4a86818ab5e2017a66df43eb83fb (patch) | |
tree | 4acfe8c906ce669c5fc92689df2c3c83a32d881c /Source/CPack | |
parent | e1763ae434c946bd1c1e9a7cc66a905ebe027bbd (diff) | |
download | cmake-d140263a497b4a86818ab5e2017a66df43eb83fb.tar.gz cmake-d140263a497b4a86818ab5e2017a66df43eb83fb.tar.bz2 cmake-d140263a497b4a86818ab5e2017a66df43eb83fb.zip |
Imported Upstream version 3.15.0upstream/3.15.0
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 17 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.h | 3 | ||||
-rw-r--r-- | Source/CPack/OSXScriptLauncher.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CPack/bills-comments.txt | 68 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackFreeBSDGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.h | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackGeneratorFactory.h | 3 | ||||
-rw-r--r-- | Source/CPack/cmCPackLog.h | 3 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 41 | ||||
-rw-r--r-- | Source/CPack/cmCPackOSXX11Generator.cxx | 10 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 60 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackProductBuildGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 5 |
20 files changed, 110 insertions, 167 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 9102e3e20..c1b6eea9a 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -85,8 +85,8 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl @@ -198,8 +198,8 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 01e3ea4a7..a075a17e3 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -152,6 +152,15 @@ void cmCPackIFWInstaller::ConfigureFromOptions() } } + // StyleSheet + if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) { + if (cmSystemTools::FileExists(option)) { + this->StyleSheet = option; + } else { + this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_STYLE_SHEET", option); + } + } + // WizardDefaultWidth if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) { @@ -381,6 +390,14 @@ void cmCPackIFWInstaller::GenerateInstallerFile() xout.Element("WizardStyle", this->WizardStyle); } + // Stylesheet + if (!this->StyleSheet.empty()) { + std::string name = cmSystemTools::GetFilenameName(this->StyleSheet); + std::string path = this->Directory + "/config/" + name; + cmsys::SystemTools::CopyFileIfDifferent(this->StyleSheet, path); + xout.Element("StyleSheet", name); + } + // WizardDefaultWidth if (!this->WizardDefaultWidth.empty()) { xout.Element("WizardDefaultWidth", this->WizardDefaultWidth); diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 37ad339af..be51fa5fb 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -72,6 +72,9 @@ public: /// Wizard style name std::string WizardStyle; + /// Filename for a style sheet + std::string StyleSheet; + /// Wizard width std::string WizardDefaultWidth; diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 4966d09f2..00d272c83 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -73,7 +73,7 @@ int main(int argc, char* argv[]) args.push_back(nullptr); cmsysProcess* cp = cmsysProcess_New(); - cmsysProcess_SetCommand(cp, &*args.begin()); + cmsysProcess_SetCommand(cp, args.data()); cmsysProcess_SetWorkingDirectory(cp, scriptDirectory.c_str()); cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); cmsysProcess_SetTimeout(cp, 0); diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 398ebd399..045d93d87 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -61,9 +61,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) std::string output; int returnValue = 0; - bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, - &output, &returnValue, 0, - cmSystemTools::OUTPUT_NONE); + bool status = cmSystemTools::RunSingleCommand( + command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE); cmsys::ofstream logFile(logFileName.c_str(), std::ios::app); logFile << command << std::endl; @@ -619,7 +618,7 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs"; - if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) { + if (!ConfigureFile(wixTemplate, mainSourceFilePath)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed creating '" << mainSourceFilePath << "'' from template." << std::endl); diff --git a/Source/CPack/bills-comments.txt b/Source/CPack/bills-comments.txt deleted file mode 100644 index 1aaf9af51..000000000 --- a/Source/CPack/bills-comments.txt +++ /dev/null @@ -1,68 +0,0 @@ -cpack.cxx - -cmCPackGenerators -- creates cmCPackGenericGenerator's via NewGenerator - - a cmCPackGenericGenerator factory - - -cmCPackGenericGenerator::Initialize - this->InitializeInternal - CPACK_INCLUDE_TOPLEVEL_DIRECTORY = 0 turns off - - -// binary package run -cmCPackGenericGenerator::ProcessGenerator // DoPackage - cmCPackGenericGenerator::PrepareNames -- sets a bunch of CPACK_vars - cmCPackGenericGenerator::InstallProject - run preinstall (make preinstall/fast) - call ReadListFile(cmake_install.cmake) - glob recurse in install directory to get list of files - this->CompressFiles with the list of files - - -// source package run -cmCPackGenericGenerator::ProcessGenerator // DoPackage - cmCPackGenericGenerator::PrepareNames -- sets a bunch of CPACK_vars - cmCPackGenericGenerator::InstallProject --> - if set CPACK_INSTALLED_DIRECTORIES - glob the files in that directory - copy those files to the tmp install directory _CPack something - glob recurse in install directory to get list of files - this->CompressFiles with the list of files - - -cmCPackGenericGenerator::InstallProject is used for both source and binary -packages. It is controlled based on values set in CPACK_ variables. - - -InstallProject - 1. CPACK_INSTALL_COMMANDS - a list of commands used to install the package - - 2. CPACK_INSTALLED_DIRECTORIES - copy this directory to CPACK_TEMPORARY_DIRECTORY - - 3. CPACK_INSTALL_CMAKE_PROJECTS - a cmake install script - - run make preinstall - - run cmake_install.cmake - - set CMAKE_INSTALL_PREFIX to the temp directory - - CPACK_BUILD_CONFIG check this and set the BUILD_TYPE to it - - ReadListFile on the install script cmake_install.cmake - - run strip on the executables and libraries if CPACK_STRIP_FILES is TRUE - -Recommendations: - -rename cmCPackGenerators to cmCPackGeneratorFactory - -rename cmCPackGenericGenerator --> cmCPackGenerator - -rename cmCPackGenericGenerator::ProcessGenerator -> cmCPackGenerator::DoPackage - - -break up cmCPackGenerator::InstallProject so it calls the following: - -// run user provided install commands - cmCPackGenerator::RunInstallCommands(); -// copy entire directories that need no processing like source trees - cmCPackGenerator::CopyPreInstalledDirectories(); -// run the cmake install scripts if provided - cmCPackGenerator::RunCMakeInstallScripts() - -- diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 2119f782b..49a9f15c3 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -44,10 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles() // to create the file before the super class is called { cmGeneratedFileStream ofs(manifestFile.c_str()); - for (std::vector<std::string>::const_iterator i = files.begin(); - i != files.end(); ++i) { + for (std::string const& file : files) { // remove the temp dir and replace with /usr - ofs << (*i).substr(tempdir.size()) << "\n"; + ofs << file.substr(tempdir.size()) << "\n"; } ofs << manifest << "\n"; } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 635de490a..cfb5efd0e 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -195,7 +195,7 @@ bool DebGenerator::generateDataTar() const // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application // should not add XXX/application orderedFiles.insert(currentPath); - currentPath = cmSystemTools::CollapseCombinedPath(currentPath, ".."); + currentPath = cmSystemTools::CollapseFullPath("..", currentPath); } } diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 013ad8163..7a3742b55 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -244,8 +244,8 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, int exit_code = 1; bool result = cmSystemTools::RunSingleCommand( - command.str().c_str(), output, output, &exit_code, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!result || exit_code) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index fcf8af1f8..9fdafa47b 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -181,7 +181,7 @@ public: { s << "{\n"; for (std::string const& elem : value) { - s << " \"" << elem << "\": {\"origin\": \"" << elem << "\"},\n"; + s << " \"" << elem << R"(": {"origin": ")" << elem << "\"},\n"; } s << '}'; } @@ -325,8 +325,7 @@ int cmCPackFreeBSDGenerator::PackageFiles() ONE_PACKAGE_PER_COMPONENT); } - std::string output_dir = - cmSystemTools::CollapseCombinedPath(toplevel, "../"); + std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel); pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(), manifestname.c_str(), nullptr); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 57c054590..7e07ff488 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -15,6 +15,7 @@ #include "cmCryptoHash.h" #include "cmDuration.h" #include "cmFSPermissions.h" +#include "cmFileTimes.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -43,7 +44,8 @@ cmCPackGenerator::~cmCPackGenerator() this->MakefileMap = nullptr; } -void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress) +void cmCPackGenerator::DisplayVerboseOutput(const std::string& msg, + float progress) { (void)progress; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl); @@ -278,7 +280,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( std::string output; int retVal = 1; bool resB = cmSystemTools::RunSingleCommand( - ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); @@ -387,8 +389,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } /* If it is not a symlink then do a plain copy */ else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) && - cmSystemTools::CopyFileTime(inFile.c_str(), - filePath.c_str()))) { + cmFileTimes::Copy(inFile, filePath))) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " << inFile << " -> " << filePath << std::endl); @@ -647,8 +648,8 @@ int cmCPackGenerator::RunPreinstallTarget( std::string output; int retVal = 1; bool resB = cmSystemTools::RunSingleCommand( - buildCommand.c_str(), &output, &output, &retVal, - installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero()); + buildCommand, &output, &output, &retVal, installDirectory.c_str(), + this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; @@ -689,7 +690,7 @@ int cmCPackGenerator::InstallCMakeProject( cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.AddCMakePaths(); - cm.SetProgressCallback([this](const char* msg, float prog) { + cm.SetProgressCallback([this](const std::string& msg, float prog) { this->DisplayVerboseOutput(msg, prog); }); cm.SetTrace(this->Trace); @@ -1245,7 +1246,8 @@ bool cmCPackGenerator::ConfigureString(const std::string& inString, return true; } -bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName, +bool cmCPackGenerator::ConfigureFile(const std::string& inName, + const std::string& outName, bool copyOnly /* = false */) { return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true, @@ -1254,9 +1256,8 @@ bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName, int cmCPackGenerator::CleanTemporaryDirectory() { - std::string tempInstallDirectoryWithPostfix = + std::string tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); - const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str(); if (cmsys::SystemTools::FileExists(tempInstallDirectory)) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Clean temporary : " << tempInstallDirectory << std::endl); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 4755f942b..3c06d4196 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -96,7 +96,7 @@ public: void SetLogger(cmCPackLog* log) { this->Logger = log; } //! Display verbose information via logger - void DisplayVerboseOutput(const char* msg, float progress); + void DisplayVerboseOutput(const std::string& msg, float progress); bool ReadListFile(const char* moduleName); @@ -169,7 +169,8 @@ protected: virtual const char* GetPackagingInstallPrefix(); virtual std::string FindTemplate(const char* name); - virtual bool ConfigureFile(const char* inName, const char* outName, + virtual bool ConfigureFile(const std::string& inName, + const std::string& outName, bool copyOnly = false); virtual bool ConfigureString(const std::string& input, std::string& output); virtual int InitializeInternal(); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index 7f633e473..972f0f73c 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -22,6 +22,9 @@ public: cmCPackGeneratorFactory(); ~cmCPackGeneratorFactory(); + cmCPackGeneratorFactory(const cmCPackGeneratorFactory&) = delete; + cmCPackGeneratorFactory& operator=(const cmCPackGeneratorFactory&) = delete; + //! Get the generator cmCPackGenerator* NewGenerator(const std::string& name); void DeleteGenerator(cmCPackGenerator* gen); diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 8e9922121..65281e3d8 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -26,6 +26,9 @@ public: cmCPackLog(); ~cmCPackLog(); + cmCPackLog(const cmCPackLog&) = delete; + cmCPackLog& operator=(const cmCPackLog&) = delete; + enum __log_tags { NOTAG = 0, diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 37ea66e76..e2020c5ae 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -182,7 +182,7 @@ int cmCPackNSISGenerator::PackageFiles() this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", ""); this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", ""); this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL", - "File /r \"${INST_DIR}\\*.*\""); + R"(File /r "${INST_DIR}\*.*")"); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", ""); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", ""); this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", ""); @@ -242,7 +242,7 @@ int cmCPackNSISGenerator::PackageFiles() } // Add this component to the various section lists. - sectionList += " !insertmacro \"${MacroName}\" \""; + sectionList += R"( !insertmacro "${MacroName}" ")"; sectionList += comp.first; sectionList += "\"\n"; selectedVarsList += "Var " + comp.first + "_selected\n"; @@ -292,9 +292,8 @@ int cmCPackNSISGenerator::PackageFiles() this->SetOption("CPACK_NSIS_DEFINES", defines.c_str()); } - this->ConfigureFile(nsisInInstallOptions.c_str(), - nsisInstallOptions.c_str()); - this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str()); + this->ConfigureFile(nsisInInstallOptions, nsisInstallOptions); + this->ConfigureFile(nsisInFileName, nsisFileName); std::string nsisCmd = "\""; nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); nsisCmd += "\" \"" + nsisFileName + "\""; @@ -302,8 +301,8 @@ int cmCPackNSISGenerator::PackageFiles() std::string output; int retVal = 1; bool res = cmSystemTools::RunSingleCommand( - nsisCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << nsisCmd << std::endl @@ -407,8 +406,8 @@ int cmCPackNSISGenerator::InitializeInternal() std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand( - nsisCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs"); if (!resS || retVal || @@ -495,10 +494,10 @@ int cmCPackNSISGenerator::InitializeInternal() std::string execName = *it; ++it; std::string linkName = *it; - str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName - << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\" + str << R"( CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName + << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\"" << std::endl; - deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName + deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName << ".lnk\"" << std::endl; // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // if so add a desktop link @@ -508,7 +507,7 @@ int cmCPackNSISGenerator::InitializeInternal() execName) != cpackPackageDesktopLinksVector.end()) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" << linkName - << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\" + << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\"" << std::endl; deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\"" @@ -564,15 +563,15 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str, ++it; std::string linkName = *it; if (!url) { - str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName - << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl; - deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName + str << R"( CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName + << R"(.lnk" "$INSTDIR\)" << sourceName << "\"" << std::endl; + deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName << ".lnk\"" << std::endl; } else { - str << " WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName - << ".url\" \"InternetShortcut\" \"URL\" \"" << sourceName << "\"" + str << R"( WriteINIStr "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName + << R"(.url" "InternetShortcut" "URL" ")" << sourceName << "\"" << std::endl; - deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName + deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName << ".url\"" << std::endl; } // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on @@ -582,7 +581,7 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str, if (this->IsSet(desktop)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" << linkName - << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl; + << R"(.lnk" "$INSTDIR\)" << sourceName << "\"" << std::endl; deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\"" << std::endl; @@ -749,7 +748,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( std::string output; int retVal = -1; int res = cmSystemTools::RunSingleCommand( - cmd.c_str(), &output, &output, &retVal, dirName.c_str(), + cmd, &output, &output, &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, cmDuration::zero()); if (!res || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 486633c90..90e0afe7f 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -83,7 +83,7 @@ int cmCPackOSXX11Generator::PackageFiles() return 0; } std::string destFileName = resourcesDirectory + "/" + iconFileName; - this->ConfigureFile(iconFile, destFileName.c_str(), true); + this->ConfigureFile(iconFile, destFileName, true); this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str()); } @@ -155,8 +155,8 @@ int cmCPackOSXX11Generator::PackageFiles() bool res = false; while (numTries > 0) { res = cmSystemTools::RunSingleCommand( - dmgCmd.str().c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (res && !retVal) { numTries = -1; break; @@ -236,7 +236,7 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? inFileName : "(NULL)") << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName, destFileName.c_str()); + this->ConfigureFile(inFileName, destFileName); return true; } */ @@ -266,7 +266,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly); + this->ConfigureFile(inFileName, destFileName, copyOnly); return true; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index ae227aab1..8c22c65b0 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -66,21 +66,17 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) xout.StartElement("choices-outline"); // Emit the outline for the groups - std::map<std::string, cmCPackComponentGroup>::iterator groupIt; - for (groupIt = this->ComponentGroups.begin(); - groupIt != this->ComponentGroups.end(); ++groupIt) { - if (groupIt->second.ParentGroup == nullptr) { - CreateChoiceOutline(groupIt->second, xout); + for (auto const& group : this->ComponentGroups) { + if (group.second.ParentGroup == nullptr) { + CreateChoiceOutline(group.second, xout); } } // Emit the outline for the non-grouped components - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - if (!compIt->second.Group) { + for (auto const& comp : this->Components) { + if (!comp.second.Group) { xout.StartElement("line"); - xout.Attribute("choice", compIt->first + "Choice"); + xout.Attribute("choice", comp.first + "Choice"); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -94,13 +90,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) xout.EndElement(); // choices-outline> // Create the actual choices - for (groupIt = this->ComponentGroups.begin(); - groupIt != this->ComponentGroups.end(); ++groupIt) { - CreateChoice(groupIt->second, xout); + for (auto const& group : this->ComponentGroups) { + CreateChoice(group.second, xout); } - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - CreateChoice(compIt->second, xout); + for (auto const& comp : this->Components) { + CreateChoice(comp.second, xout); } if (!this->PostFlightComponent.Name.empty()) { @@ -111,7 +105,7 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) // Create the distribution.dist file in the metapackage to turn it // into a distribution package. - this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str()); + this->ConfigureFile(distributionTemplate, distributionFile); } void cmCPackPKGGenerator::CreateChoiceOutline( @@ -119,17 +113,13 @@ void cmCPackPKGGenerator::CreateChoiceOutline( { xout.StartElement("line"); xout.Attribute("choice", group.Name + "Choice"); - std::vector<cmCPackComponentGroup*>::const_iterator groupIt; - for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end(); - ++groupIt) { - CreateChoiceOutline(**groupIt, xout); + for (cmCPackComponentGroup* subgroup : group.Subgroups) { + CreateChoiceOutline(*subgroup, xout); } - std::vector<cmCPackComponent*>::const_iterator compIt; - for (compIt = group.Components.begin(); compIt != group.Components.end(); - ++compIt) { + for (cmCPackComponent* comp : group.Components) { xout.StartElement("line"); - xout.Attribute("choice", (*compIt)->Name + "Choice"); + xout.Attribute("choice", comp->Name + "Choice"); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -238,11 +228,9 @@ void cmCPackPKGGenerator::AddDependencyAttributes( } visited.insert(&component); - std::vector<cmCPackComponent*>::const_iterator dependIt; - for (dependIt = component.Dependencies.begin(); - dependIt != component.Dependencies.end(); ++dependIt) { - out << " && choices['" << (*dependIt)->Name << "Choice'].selected"; - AddDependencyAttributes(**dependIt, visited, out); + for (cmCPackComponent* depend : component.Dependencies) { + out << " && choices['" << depend->Name << "Choice'].selected"; + AddDependencyAttributes(*depend, visited, out); } } @@ -255,11 +243,9 @@ void cmCPackPKGGenerator::AddReverseDependencyAttributes( } visited.insert(&component); - std::vector<cmCPackComponent*>::const_iterator dependIt; - for (dependIt = component.ReverseDependencies.begin(); - dependIt != component.ReverseDependencies.end(); ++dependIt) { - out << " || choices['" << (*dependIt)->Name << "Choice'].selected"; - AddReverseDependencyAttributes(**dependIt, visited, out); + for (cmCPackComponent* depend : component.ReverseDependencies) { + out << " || choices['" << depend->Name << "Choice'].selected"; + AddReverseDependencyAttributes(*depend, visited, out); } } @@ -308,7 +294,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? inFileName : "(NULL)") << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName, destFileName.c_str()); + this->ConfigureFile(inFileName, destFileName); return true; } @@ -336,7 +322,7 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName << " to " << destFileName << std::endl); - this->ConfigureFile(inFileName.c_str(), destFileName.c_str()); + this->ConfigureFile(inFileName, destFileName); return true; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 246178d8f..3d93c48f1 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -295,8 +295,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() bool res = false; while (numTries > 0) { res = cmSystemTools::RunSingleCommand( - dmgCmd.str().c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (res && !retVal) { numTries = -1; break; diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index a556e0c52..94b5b5f7e 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -145,8 +145,8 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command) std::string output; int retVal = 1; bool res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + command, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 0413422b2..58b9e70fa 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -82,7 +82,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 0; } std::string key = value.substr(0, pos); - value = value.c_str() + pos + 1; + value = value.substr(pos + 1); def->Map[key] = value; cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " << key << " to \"" << value << "\"" @@ -90,7 +90,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 1; } -static void cpackProgressCallback(const char* message, float /*unused*/) +static void cpackProgressCallback(const std::string& message, float /*unused*/) { std::cout << "-- " << message << std::endl; } @@ -98,6 +98,7 @@ static void cpackProgressCallback(const char* message, float /*unused*/) // this is CPack. int main(int argc, char const* const* argv) { + cmSystemTools::EnsureStdPipes(); #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) // Replace streambuf so we can output Unicode to console cmsys::ConsoleBuf::Manager consoleOut(std::cout); |