diff options
author | Rose <83477269+AtariDreams@users.noreply.github.com> | 2021-10-27 18:01:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-11-04 13:20:48 (GMT) |
commit | b86b6aaa4a27009af4e1457458cf35185be00dc5 (patch) | |
tree | d8410f37e0df5aeb59bad57a6ded0961b63f1721 /Source/CPack | |
parent | 6251239a1c0f0f8342813ff800c184ca2672935b (diff) | |
download | CMake-b86b6aaa4a27009af4e1457458cf35185be00dc5.zip CMake-b86b6aaa4a27009af4e1457458cf35185be00dc5.tar.gz CMake-b86b6aaa4a27009af4e1457458cf35185be00dc5.tar.bz2 |
Source: Cleanup and simplify some code
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.h | 10 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackComponentGroup.h | 13 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinBinaryGenerator.h | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinSourceGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinSourceGenerator.h | 8 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.h | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackFreeBSDGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackGeneratorFactory.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackLog.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackOSXX11Generator.cxx | 31 | ||||
-rw-r--r-- | Source/CPack/cmCPackOSXX11Generator.h | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.h | 3 | ||||
-rw-r--r-- | Source/CPack/cmCPackRPMGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackRPMGenerator.h | 6 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 2 |
20 files changed, 57 insertions, 69 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index b853e18..86b4993 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -9,13 +9,15 @@ #include <string> #include <vector> -#include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackIFWCommon.h" #include "cmCPackIFWInstaller.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" +class cmCPackComponent; +class cmCPackComponentGroup; + /** \class cmCPackIFWGenerator * \brief A generator for Qt Installer Framework tools * @@ -30,8 +32,6 @@ public: using PackagesMap = std::map<std::string, cmCPackIFWPackage>; using RepositoriesMap = std::map<std::string, cmCPackIFWRepository>; - using ComponentsMap = std::map<std::string, cmCPackComponent>; - using ComponentGoupsMap = std::map<std::string, cmCPackComponentGroup>; using DependenceMap = std::map<std::string, cmCPackIFWPackage::DependenceStruct>; @@ -154,8 +154,8 @@ private: std::string ArchiveFormat; std::string ArchiveCompression; - bool OnlineOnly; - bool ResolveDuplicateNames; + bool OnlineOnly{}; + bool ResolveDuplicateNames{}; std::vector<std::string> PkgsDirsVector; std::vector<std::string> RepoDirsVector; }; diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index 0cc6f2f..350f6b2 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -44,7 +44,7 @@ public: struct DependenceStruct { DependenceStruct(); - DependenceStruct(const std::string& dependence); + explicit DependenceStruct(const std::string& dependence); std::string Name; CompareStruct Compare; diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index 58377d4..6a47b6d 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -35,12 +35,10 @@ class cmCPackComponent { public: cmCPackComponent() - : Group(nullptr) - , IsRequired(true) + : IsRequired(true) , IsHidden(false) , IsDisabledByDefault(false) , IsDownloaded(false) - , TotalSize(0) { } @@ -51,7 +49,7 @@ public: std::string DisplayName; /// The component group that contains this component (if any). - cmCPackComponentGroup* Group; + cmCPackComponentGroup* Group = nullptr; /// Whether this component group must always be installed. bool IsRequired : 1; @@ -103,7 +101,7 @@ public: unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const; private: - mutable unsigned long TotalSize; + mutable unsigned long TotalSize = 0; }; /** \class cmCPackComponentGroup @@ -113,7 +111,8 @@ class cmCPackComponentGroup { public: cmCPackComponentGroup() - : ParentGroup(nullptr) + : IsBold(false) + , IsExpandedByDefault(false) { } @@ -136,7 +135,7 @@ public: std::vector<cmCPackComponent*> Components; /// The parent group of this component group (if any). - cmCPackComponentGroup* ParentGroup; + cmCPackComponentGroup* ParentGroup = nullptr; /// The subgroups of this group. std::vector<cmCPackComponentGroup*> Subgroups; diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 484db00..fabf4c5 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -17,9 +17,7 @@ cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator() { } -cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator() -{ -} +cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator() = default; int cmCPackCygwinBinaryGenerator::InitializeInternal() { @@ -43,7 +41,7 @@ int cmCPackCygwinBinaryGenerator::PackageFiles() // create an extra scope to force the stream // to create the file before the super class is called { - cmGeneratedFileStream ofs(manifestFile.c_str()); + cmGeneratedFileStream ofs(manifestFile); for (std::string const& file : files) { // remove the temp dir and replace with /usr ofs << file.substr(tempdir.size()) << "\n"; diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h index f5f7700..ca8e0b5 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.h +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h @@ -19,8 +19,8 @@ public: ~cmCPackCygwinBinaryGenerator() override; protected: - virtual int InitializeInternal(); - int PackageFiles(); - virtual const char* GetOutputExtension(); + int InitializeInternal() override; + int PackageFiles() override; + const char* GetOutputExtension() override; std::string OutputExtension; }; diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index 59df380..a5863ff 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -26,9 +26,7 @@ cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator() { } -cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator() -{ -} +cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator() = default; int cmCPackCygwinSourceGenerator::InitializeInternal() { @@ -50,7 +48,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles() // Now create a tar file that contains the above .tar.bz2 file // and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY // files - std::string compressOutFile = packageDirFileName; + const std::string& compressOutFile = packageDirFileName; // at this point compressOutFile is the full path to // _CPack_Package/.../package-2.5.0.tar.bz2 // we want to create a tar _CPack_Package/.../package-2.5.0-1-src.tar.bz2 diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h index 964a4d4..2207bde 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.h +++ b/Source/CPack/cmCPackCygwinSourceGenerator.h @@ -19,10 +19,10 @@ public: ~cmCPackCygwinSourceGenerator() override; protected: - const char* GetPackagingInstallPrefix(); - virtual int InitializeInternal(); - int PackageFiles(); - virtual const char* GetOutputExtension(); + const char* GetPackagingInstallPrefix() override; + int InitializeInternal() override; + int PackageFiles() override; + const char* GetOutputExtension() override; std::string InstallPrefix; std::string OutputExtension; }; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index d7aa287..8e5e637 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -203,7 +203,7 @@ bool DebGenerator::generateDataTar() const // uid/gid should be the one of the root user, and this root user has // always uid/gid equal to 0. - data_tar.SetUIDAndGID(0u, 0u); + data_tar.SetUIDAndGID(0U, 0U); data_tar.SetUNAMEAndGNAME("root", "root"); // now add all directories which have to be compressed @@ -902,7 +902,7 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( } if (this->componentPackageMethod == ONE_PACKAGE) { - return std::string("ALL_COMPONENTS_IN_ONE"); + return { "ALL_COMPONENTS_IN_ONE" }; } // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index 61a6616..11561a4 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -29,9 +29,9 @@ public: #ifdef __APPLE__ // on MacOS enable CPackDeb iff dpkg is found std::vector<std::string> locations; - locations.push_back("/sw/bin"); // Fink - locations.push_back("/opt/local/bin"); // MacPorts - return cmSystemTools::FindProgram("dpkg", locations) != "" ? true : false; + locations.emplace_back("/sw/bin"); // Fink + locations.emplace_back("/opt/local/bin"); // MacPorts + return !cmSystemTools::FindProgram("dpkg", locations).empty(); #else // legacy behavior on other systems return true; diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index c96d035..6d1267b 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -33,7 +33,7 @@ protected: bool CopyFile(std::ostringstream& source, std::ostringstream& target); bool CreateEmptyFile(std::ostringstream& target, size_t size); - bool RunCommand(std::ostringstream& command, std::string* output = 0); + bool RunCommand(std::ostringstream& command, std::string* output = nullptr); std::string GetComponentInstallDirNameSuffix( const std::string& componentName) override; diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 30b6b0d..fcd5753 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -205,7 +205,7 @@ std::string cmCPackFreeBSDGenerator::var_lookup(const char* var_name) { cmValue pv = this->GetOption(var_name); if (!pv) { - return std::string(); + return {}; } return *pv; } diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index 0846573..f3e25a6 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -41,5 +41,5 @@ private: using t_GeneratorCreatorsMap = std::map<std::string, CreateGeneratorCall*>; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; - cmCPackLog* Logger; + cmCPackLog* Logger{}; }; diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index aa9a17f..2ab2f8e 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -128,7 +128,7 @@ public: } const char* Data; - size_t Length; + std::streamsize Length; }; inline std::ostream& operator<<(std::ostream& os, const cmCPackLogWrite& c) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index ecc5e08..217f716 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -883,7 +883,7 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription( { // Don't visit a component twice if (visited.count(component)) { - return std::string(); + return {}; } visited.insert(component); @@ -907,7 +907,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription( { // Don't visit a component twice if (visited.count(component)) { - return std::string(); + return {}; } visited.insert(component); @@ -933,7 +933,7 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription( { if (group->Components.empty() && group->Subgroups.empty()) { // Silently skip empty groups. NSIS doesn't support them. - return std::string(); + return {}; } std::string code = "SectionGroup "; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 7bf1dc7..563cba0 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -20,8 +20,6 @@ cmCPackOSXX11Generator::~cmCPackOSXX11Generator() = default; int cmCPackOSXX11Generator::PackageFiles() { - // TODO: Use toplevel ? - // It is used! Is this an obsolete comment? cmValue cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); @@ -147,33 +145,26 @@ int cmCPackOSXX11Generator::PackageFiles() // since we get random dashboard failures with this one // try running it more than once int retVal = 1; - int numTries = 10; bool res = false; - while (numTries > 0) { + for (unsigned numTries = 10; numTries > 0; numTries--) { res = cmSystemTools::RunSingleCommand( dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (res && !retVal) { - numTries = -1; - break; + return 1; } cmSystemTools::Delay(500); - numTries--; - } - if (!res || retVal) { - cmGeneratedFileStream ofs(tmpFile); - ofs << "# Run command: " << dmgCmd.str() << std::endl - << "# Output:" << std::endl - << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running hdiutil command: " - << dmgCmd.str() << std::endl - << "Please check " << tmpFile << " for errors" - << std::endl); - return 0; } - return 1; + cmGeneratedFileStream ofs(tmpFile); + ofs << "# Run command: " << dmgCmd.str() << std::endl + << "# Output:" << std::endl + << output << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running hdiutil command: " + << dmgCmd.str() << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); + return 0; } int cmCPackOSXX11Generator::InitializeInternal() diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 8fae136..6f69af8 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -25,7 +25,7 @@ public: ~cmCPackOSXX11Generator() override; protected: - virtual int InitializeInternal() override; + int InitializeInternal() override; int PackageFiles() override; const char* GetPackagingInstallPrefix() override; const char* GetOutputExtension() override { return ".dmg"; } @@ -33,7 +33,7 @@ protected: // bool CopyCreateResourceFile(const std::string& name, // const std::string& dir); bool CopyResourcePlistFile(const std::string& name, const std::string& dir, - const char* outputFileName = 0, + const char* outputFileName = nullptr, bool copyOnly = false); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h index 17cdcdf..5d97d16 100644 --- a/Source/CPack/cmCPackPKGGenerator.h +++ b/Source/CPack/cmCPackPKGGenerator.h @@ -43,7 +43,8 @@ protected: // which will be configured via ConfigureFile. bool CopyCreateResourceFile(const std::string& name, const std::string& dirName); - bool CopyResourcePlistFile(const std::string& name, const char* outName = 0); + bool CopyResourcePlistFile(const std::string& name, + const char* outName = nullptr); int CopyInstallScript(const std::string& resdir, const std::string& script, const std::string& name); diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 9e50700..3d4d05e 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -329,9 +329,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) if (retval) { this->AddGeneratedPackageNames(); + return retval; } - return retval; + return 0; } int cmCPackRPMGenerator::PackageComponentsAllInOne( @@ -424,7 +425,7 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( } if (this->componentPackageMethod == ONE_PACKAGE) { - return std::string("ALL_COMPONENTS_IN_ONE"); + return { "ALL_COMPONENTS_IN_ONE" }; } // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 0288f2f..886afb1 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -32,9 +32,9 @@ public: #ifdef __APPLE__ // on MacOS enable CPackRPM iff rpmbuild is found std::vector<std::string> locations; - locations.push_back("/sw/bin"); // Fink - locations.push_back("/opt/local/bin"); // MacPorts - return cmSystemTools::FindProgram("rpmbuild") != "" ? true : false; + locations.emplace_back("/sw/bin"); // Fink + locations.emplace_back("/opt/local/bin"); // MacPorts + return !cmSystemTools::FindProgram("rpmbuild").empty(); #else // legacy behavior on other systems return true; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 54fd358..f43642f 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -67,7 +67,7 @@ struct cpackDefinitions { using MapType = std::map<std::string, std::string>; MapType Map; - cmCPackLog* Log; + cmCPackLog* Log{}; }; int cpackDefinitionArgument(const char* argument, const char* cValue, |