diff options
author | Matthias Maennich <matthias@maennich.net> | 2017-09-21 21:06:05 (GMT) |
---|---|---|
committer | Matthias Maennich <matthias@maennich.net> | 2017-09-25 22:07:19 (GMT) |
commit | f0489856e30b1b5236d1897071ea38dfde438fc7 (patch) | |
tree | f2a786e0c3fe5e9d234f62c3ca3cacfdbd70ef8f /Source/CPack | |
parent | eae3765b67b653d3f00afa44a60719a387262af8 (diff) | |
download | CMake-f0489856e30b1b5236d1897071ea38dfde438fc7.zip CMake-f0489856e30b1b5236d1897071ea38dfde438fc7.tar.gz CMake-f0489856e30b1b5236d1897071ea38dfde438fc7.tar.bz2 |
Retire std::auto_ptr and its macro CM_AUTO_PTR
Signed-off-by: Matthias Maennich <matthias@maennich.net>
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 50 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 52 |
2 files changed, 49 insertions, 53 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index f56b5fa..ecb5adb 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -6,6 +6,7 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include <algorithm> +#include <memory> // IWYU pragma: keep #include <utility> #include "cmCPackComponentGroup.h" @@ -17,7 +18,6 @@ #include "cmStateSnapshot.h" #include "cmWorkingDirectory.h" #include "cmXMLSafe.h" -#include "cm_auto_ptr.hxx" #include "cmake.h" #if defined(__HAIKU__) @@ -156,7 +156,7 @@ int cmCPackGenerator::PrepareNames() } const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM"); if (algoSignature) { - if (cmCryptoHash::New(algoSignature).get() == nullptr) { + if (!cmCryptoHash::New(algoSignature)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: " << algoSignature << std::endl); return 0; @@ -610,8 +610,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); - CM_AUTO_PTR<cmMakefile> mf( - new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmMakefile mf(&gg, cm.GetCurrentSnapshot()); if (!installSubDirectory.empty() && installSubDirectory != "/" && installSubDirectory != ".") { tempInstallDirectory += installSubDirectory; @@ -657,11 +656,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if (this->GetOption("CPACK_INSTALL_PREFIX")) { dir += this->GetOption("CPACK_INSTALL_PREFIX"); } - mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str()); + mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str()); cmCPackLogger( cmCPackLog::LOG_DEBUG, - "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)" + "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)" << std::endl); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" @@ -698,8 +697,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( return 0; } } else { - mf->AddDefinition("CMAKE_INSTALL_PREFIX", - tempInstallDirectory.c_str()); + mf.AddDefinition("CMAKE_INSTALL_PREFIX", + tempInstallDirectory.c_str()); if (!cmsys::SystemTools::MakeDirectory( tempInstallDirectory.c_str())) { @@ -710,7 +709,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Using non-DESTDIR install... (mf->AddDefinition)" + "- Using non-DESTDIR install... (mf.AddDefinition)" << std::endl); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Setting CMAKE_INSTALL_PREFIX to '" @@ -718,19 +717,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } if (!buildConfig.empty()) { - mf->AddDefinition("BUILD_TYPE", buildConfig.c_str()); + mf.AddDefinition("BUILD_TYPE", buildConfig.c_str()); } std::string installComponentLowerCase = cmSystemTools::LowerCase(installComponent); if (installComponentLowerCase != "all") { - mf->AddDefinition("CMAKE_INSTALL_COMPONENT", - installComponent.c_str()); + mf.AddDefinition("CMAKE_INSTALL_COMPONENT", + installComponent.c_str()); } // strip on TRUE, ON, 1, one or several file names, but not on // FALSE, OFF, 0 and an empty string if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) { - mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); + mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } // Remember the list of files before installation // of the current component (if we are in component install) @@ -750,7 +749,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION // then forward request to cmake_install.cmake script if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) { - mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); + mf.AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } // If current CPack generator does support // ABSOLUTE INSTALL DESTINATION or CPack has been asked for @@ -758,18 +757,17 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // as soon as it occurs (before installing file) if (!SupportsAbsoluteDestination() || this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) { - mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", - "1"); + mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } // do installation - int res = mf->ReadListFile(installFile.c_str()); + int res = mf.ReadListFile(installFile.c_str()); // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES // to CPack (may be used by generators like CPack RPM or DEB) // in order to transparently handle ABSOLUTE PATH - if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) { - mf->AddDefinition( + if (mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) { + mf.AddDefinition( "CPACK_ABSOLUTE_DESTINATION_FILES", - mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")); + mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")); } // Now rebuild the list of files after installation @@ -803,12 +801,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } } - if (nullptr != mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { + if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (!absoluteDestFiles.empty()) { absoluteDestFiles += ";"; } absoluteDestFiles += - mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); + mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles << std::endl); @@ -822,13 +820,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( this->GetOption(absoluteDestFileComponent); absoluteDestFilesListComponent += ";"; absoluteDestFilesListComponent += - mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); + mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { this->SetOption( absoluteDestFileComponent, - mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); + mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); } } } @@ -964,7 +962,7 @@ int cmCPackGenerator::DoPackage() /* Prepare checksum algorithm*/ const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM"); - CM_AUTO_PTR<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : ""); + std::unique_ptr<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : ""); /* * Copy the generated packages to final destination @@ -997,7 +995,7 @@ int cmCPackGenerator::DoPackage() << packageFileName << " generated." << std::endl); /* Generate checksum file */ - if (crypto.get() != nullptr) { + if (crypto) { std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); hashFile += "/" + filename; hashFile += "." + cmSystemTools::LowerCase(algo); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index cc51c60..f2c54fc 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -5,6 +5,7 @@ #include "cmsys/Encoding.hxx" #include <iostream> #include <map> +#include <memory> // IWYU pragma: keep #include <sstream> #include <stddef.h> #include <string> @@ -24,7 +25,6 @@ #include "cmMakefile.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" -#include "cm_auto_ptr.hxx" #include "cmake.h" static const char* cmDocumentationName[][2] = { @@ -192,8 +192,7 @@ int main(int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator cmgg(&cminst); - CM_AUTO_PTR<cmMakefile> globalMF( - new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); + cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot()); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif @@ -225,16 +224,16 @@ int main(int argc, char const* const* argv) // find out which system cpack is running on, so it can setup the search // paths, so FIND_XXX() commands can be used in scripts std::string systemFile = - globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); - if (!globalMF->ReadListFile(systemFile.c_str())) { + globalMF.GetModulesFile("CMakeDetermineSystem.cmake"); + if (!globalMF.ReadListFile(systemFile.c_str())) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeDetermineSystem.cmake" << std::endl); return 1; } systemFile = - globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); - if (!globalMF->ReadListFile(systemFile.c_str())) { + globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake"); + if (!globalMF.ReadListFile(systemFile.c_str())) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeSystemSpecificInformation.cmake" << std::endl); @@ -242,7 +241,7 @@ int main(int argc, char const* const* argv) } if (!cpackBuildConfig.empty()) { - globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); + globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); } if (cmSystemTools::FileExists(cpackConfigFile.c_str())) { @@ -250,7 +249,7 @@ int main(int argc, char const* const* argv) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile << std::endl); - if (!globalMF->ReadListFile(cpackConfigFile.c_str())) { + if (!globalMF.ReadListFile(cpackConfigFile.c_str())) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" << cpackConfigFile << "\"" << std::endl); @@ -264,45 +263,44 @@ int main(int argc, char const* const* argv) } if (!generator.empty()) { - globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str()); + globalMF.AddDefinition("CPACK_GENERATOR", generator.c_str()); } if (!cpackProjectName.empty()) { - globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str()); + globalMF.AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str()); } if (!cpackProjectVersion.empty()) { - globalMF->AddDefinition("CPACK_PACKAGE_VERSION", - cpackProjectVersion.c_str()); + globalMF.AddDefinition("CPACK_PACKAGE_VERSION", + cpackProjectVersion.c_str()); } if (!cpackProjectVendor.empty()) { - globalMF->AddDefinition("CPACK_PACKAGE_VENDOR", - cpackProjectVendor.c_str()); + globalMF.AddDefinition("CPACK_PACKAGE_VENDOR", + cpackProjectVendor.c_str()); } // if this is not empty it has been set on the command line // go for it. Command line override values set in config file. if (!cpackProjectDirectory.empty()) { - globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", - cpackProjectDirectory.c_str()); + globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", + cpackProjectDirectory.c_str()); } // The value has not been set on the command line else { // get a default value (current working directory) cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory(); // use default value iff no value has been provided by the config file - if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) { - globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", - cpackProjectDirectory.c_str()); + if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) { + globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", + cpackProjectDirectory.c_str()); } } for (auto const& cd : definitions.Map) { - globalMF->AddDefinition(cd.first, cd.second.c_str()); + globalMF.AddDefinition(cd.first, cd.second.c_str()); } - const char* cpackModulesPath = - globalMF->GetDefinition("CPACK_MODULE_PATH"); + const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH"); if (cpackModulesPath) { - globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath); + globalMF.AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath); } - const char* genList = globalMF->GetDefinition("CPACK_GENERATOR"); + const char* genList = globalMF.GetDefinition("CPACK_GENERATOR"); if (!genList) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl); @@ -310,8 +308,8 @@ int main(int argc, char const* const* argv) std::vector<std::string> generatorsVector; cmSystemTools::ExpandListArgument(genList, generatorsVector); for (std::string const& gen : generatorsVector) { - cmMakefile::ScopePushPop raii(globalMF.get()); - cmMakefile* mf = globalMF.get(); + cmMakefile::ScopePushPop raii(&globalMF); + cmMakefile* mf = &globalMF; cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) { |