Retire std::auto_ptr and its macro CM_AUTO_PTR

Signed-off-by: Matthias Maennich <matthias@maennich.net>
This commit is contained in:
Matthias Maennich 2017-09-21 23:06:05 +02:00
parent eae3765b67
commit f0489856e3
54 changed files with 353 additions and 573 deletions

View File

@ -10,7 +10,6 @@ modernize-*,\
-modernize-deprecated-headers,\ -modernize-deprecated-headers,\
-modernize-pass-by-value,\ -modernize-pass-by-value,\
-modernize-raw-string-literal,\ -modernize-raw-string-literal,\
-modernize-replace-auto-ptr,\
-modernize-use-auto,\ -modernize-use-auto,\
-modernize-use-default-member-init,\ -modernize-use-default-member-init,\
-modernize-use-emplace,\ -modernize-use-emplace,\

View File

@ -26,11 +26,9 @@ C++ Subset Permitted
CMake requires compiling as C++11 or above. However, in order to support CMake requires compiling as C++11 or above. However, in order to support
building on older toolchains some constructs need to be handled with care: building on older toolchains some constructs need to be handled with care:
* Do not use ``CM_AUTO_PTR`` or ``std::auto_ptr``. * Do not use ``std::auto_ptr``.
The ``std::auto_ptr`` template is deprecated in C++11. The ``CM_AUTO_PTR`` The ``std::auto_ptr`` template is deprecated in C++11. Use ``std::unique_ptr``.
macro remains leftover from C++98 support until its uses can be ported to
``std::unique_ptr``. Do not add new uses of the macro.
* Use ``CM_EQ_DELETE;`` instead of ``= delete;``. * Use ``CM_EQ_DELETE;`` instead of ``= delete;``.

View File

@ -587,7 +587,6 @@ set(SRCS
cmWriteFileCommand.cxx cmWriteFileCommand.cxx
cmWriteFileCommand.h cmWriteFileCommand.h
cm_auto_ptr.hxx
cm_get_date.h cm_get_date.h
cm_get_date.c cm_get_date.c
cm_utf8.h cm_utf8.h

View File

@ -6,6 +6,7 @@
#include "cmsys/Glob.hxx" #include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <algorithm> #include <algorithm>
#include <memory> // IWYU pragma: keep
#include <utility> #include <utility>
#include "cmCPackComponentGroup.h" #include "cmCPackComponentGroup.h"
@ -17,7 +18,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmWorkingDirectory.h" #include "cmWorkingDirectory.h"
#include "cmXMLSafe.h" #include "cmXMLSafe.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#if defined(__HAIKU__) #if defined(__HAIKU__)
@ -156,7 +156,7 @@ int cmCPackGenerator::PrepareNames()
} }
const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM"); const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
if (algoSignature) { if (algoSignature) {
if (cmCryptoHash::New(algoSignature).get() == nullptr) { if (!cmCryptoHash::New(algoSignature)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: " cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: "
<< algoSignature << std::endl); << algoSignature << std::endl);
return 0; return 0;
@ -610,8 +610,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.AddCMakePaths(); cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this); cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
CM_AUTO_PTR<cmMakefile> mf( cmMakefile mf(&gg, cm.GetCurrentSnapshot());
new cmMakefile(&gg, cm.GetCurrentSnapshot()));
if (!installSubDirectory.empty() && installSubDirectory != "/" && if (!installSubDirectory.empty() && installSubDirectory != "/" &&
installSubDirectory != ".") { installSubDirectory != ".") {
tempInstallDirectory += installSubDirectory; tempInstallDirectory += installSubDirectory;
@ -657,11 +656,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
if (this->GetOption("CPACK_INSTALL_PREFIX")) { if (this->GetOption("CPACK_INSTALL_PREFIX")) {
dir += 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( cmCPackLogger(
cmCPackLog::LOG_DEBUG, cmCPackLog::LOG_DEBUG,
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)" "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)"
<< std::endl); << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
@ -698,8 +697,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
return 0; return 0;
} }
} else { } else {
mf->AddDefinition("CMAKE_INSTALL_PREFIX", mf.AddDefinition("CMAKE_INSTALL_PREFIX",
tempInstallDirectory.c_str()); tempInstallDirectory.c_str());
if (!cmsys::SystemTools::MakeDirectory( if (!cmsys::SystemTools::MakeDirectory(
tempInstallDirectory.c_str())) { tempInstallDirectory.c_str())) {
@ -710,7 +709,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
} }
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using non-DESTDIR install... (mf->AddDefinition)" "- Using non-DESTDIR install... (mf.AddDefinition)"
<< std::endl); << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '" "- Setting CMAKE_INSTALL_PREFIX to '"
@ -718,19 +717,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
} }
if (!buildConfig.empty()) { if (!buildConfig.empty()) {
mf->AddDefinition("BUILD_TYPE", buildConfig.c_str()); mf.AddDefinition("BUILD_TYPE", buildConfig.c_str());
} }
std::string installComponentLowerCase = std::string installComponentLowerCase =
cmSystemTools::LowerCase(installComponent); cmSystemTools::LowerCase(installComponent);
if (installComponentLowerCase != "all") { if (installComponentLowerCase != "all") {
mf->AddDefinition("CMAKE_INSTALL_COMPONENT", mf.AddDefinition("CMAKE_INSTALL_COMPONENT",
installComponent.c_str()); installComponent.c_str());
} }
// strip on TRUE, ON, 1, one or several file names, but not on // strip on TRUE, ON, 1, one or several file names, but not on
// FALSE, OFF, 0 and an empty string // FALSE, OFF, 0 and an empty string
if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) { 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 // Remember the list of files before installation
// of the current component (if we are in component install) // 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 // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
// then forward request to cmake_install.cmake script // then forward request to cmake_install.cmake script
if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) { 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 // If current CPack generator does support
// ABSOLUTE INSTALL DESTINATION or CPack has been asked for // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
@ -758,18 +757,17 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// as soon as it occurs (before installing file) // as soon as it occurs (before installing file)
if (!SupportsAbsoluteDestination() || if (!SupportsAbsoluteDestination() ||
this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) { this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
"1");
} }
// do installation // do installation
int res = mf->ReadListFile(installFile.c_str()); int res = mf.ReadListFile(installFile.c_str());
// forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
// to CPack (may be used by generators like CPack RPM or DEB) // to CPack (may be used by generators like CPack RPM or DEB)
// in order to transparently handle ABSOLUTE PATH // in order to transparently handle ABSOLUTE PATH
if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) { if (mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
mf->AddDefinition( mf.AddDefinition(
"CPACK_ABSOLUTE_DESTINATION_FILES", "CPACK_ABSOLUTE_DESTINATION_FILES",
mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")); mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
} }
// Now rebuild the list of files after installation // 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()) { if (!absoluteDestFiles.empty()) {
absoluteDestFiles += ";"; absoluteDestFiles += ";";
} }
absoluteDestFiles += absoluteDestFiles +=
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Got some ABSOLUTE DESTINATION FILES: " "Got some ABSOLUTE DESTINATION FILES: "
<< absoluteDestFiles << std::endl); << absoluteDestFiles << std::endl);
@ -822,13 +820,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
this->GetOption(absoluteDestFileComponent); this->GetOption(absoluteDestFileComponent);
absoluteDestFilesListComponent += ";"; absoluteDestFilesListComponent += ";";
absoluteDestFilesListComponent += absoluteDestFilesListComponent +=
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
this->SetOption(absoluteDestFileComponent, this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str()); absoluteDestFilesListComponent.c_str());
} else { } else {
this->SetOption( this->SetOption(
absoluteDestFileComponent, absoluteDestFileComponent,
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
} }
} }
} }
@ -964,7 +962,7 @@ int cmCPackGenerator::DoPackage()
/* Prepare checksum algorithm*/ /* Prepare checksum algorithm*/
const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM"); 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 * Copy the generated packages to final destination
@ -997,7 +995,7 @@ int cmCPackGenerator::DoPackage()
<< packageFileName << " generated." << std::endl); << packageFileName << " generated." << std::endl);
/* Generate checksum file */ /* Generate checksum file */
if (crypto.get() != nullptr) { if (crypto) {
std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
hashFile += "/" + filename; hashFile += "/" + filename;
hashFile += "." + cmSystemTools::LowerCase(algo); hashFile += "." + cmSystemTools::LowerCase(algo);

View File

@ -5,6 +5,7 @@
#include "cmsys/Encoding.hxx" #include "cmsys/Encoding.hxx"
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stddef.h> #include <stddef.h>
#include <string> #include <string>
@ -24,7 +25,6 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
static const char* cmDocumentationName[][2] = { static const char* cmDocumentationName[][2] = {
@ -192,8 +192,7 @@ int main(int argc, char const* const* argv)
cminst.SetHomeOutputDirectory(""); cminst.SetHomeOutputDirectory("");
cminst.GetCurrentSnapshot().SetDefaultDefinitions(); cminst.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator cmgg(&cminst); cmGlobalGenerator cmgg(&cminst);
CM_AUTO_PTR<cmMakefile> globalMF( cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot());
new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif #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 // find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts // paths, so FIND_XXX() commands can be used in scripts
std::string systemFile = std::string systemFile =
globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
if (!globalMF->ReadListFile(systemFile.c_str())) { if (!globalMF.ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeDetermineSystem.cmake" << std::endl); "Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1; return 1;
} }
systemFile = systemFile =
globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
if (!globalMF->ReadListFile(systemFile.c_str())) { if (!globalMF.ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeSystemSpecificInformation.cmake" "Error reading CMakeSystemSpecificInformation.cmake"
<< std::endl); << std::endl);
@ -242,7 +241,7 @@ int main(int argc, char const* const* argv)
} }
if (!cpackBuildConfig.empty()) { 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())) { if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
@ -250,7 +249,7 @@ int main(int argc, char const* const* argv)
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile "Read CPack configuration file: " << cpackConfigFile
<< std::endl); << std::endl);
if (!globalMF->ReadListFile(cpackConfigFile.c_str())) { if (!globalMF.ReadListFile(cpackConfigFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Problem reading CPack config file: \"" "Problem reading CPack config file: \""
<< cpackConfigFile << "\"" << std::endl); << cpackConfigFile << "\"" << std::endl);
@ -264,45 +263,44 @@ int main(int argc, char const* const* argv)
} }
if (!generator.empty()) { if (!generator.empty()) {
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str()); globalMF.AddDefinition("CPACK_GENERATOR", generator.c_str());
} }
if (!cpackProjectName.empty()) { if (!cpackProjectName.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str()); globalMF.AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
} }
if (!cpackProjectVersion.empty()) { if (!cpackProjectVersion.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_VERSION", globalMF.AddDefinition("CPACK_PACKAGE_VERSION",
cpackProjectVersion.c_str()); cpackProjectVersion.c_str());
} }
if (!cpackProjectVendor.empty()) { if (!cpackProjectVendor.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR", globalMF.AddDefinition("CPACK_PACKAGE_VENDOR",
cpackProjectVendor.c_str()); cpackProjectVendor.c_str());
} }
// if this is not empty it has been set on the command line // if this is not empty it has been set on the command line
// go for it. Command line override values set in config file. // go for it. Command line override values set in config file.
if (!cpackProjectDirectory.empty()) { if (!cpackProjectDirectory.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str()); cpackProjectDirectory.c_str());
} }
// The value has not been set on the command line // The value has not been set on the command line
else { else {
// get a default value (current working directory) // get a default value (current working directory)
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory(); cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
// use default value iff no value has been provided by the config file // use default value iff no value has been provided by the config file
if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) { if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) {
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str()); cpackProjectDirectory.c_str());
} }
} }
for (auto const& cd : definitions.Map) { 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 = const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
globalMF->GetDefinition("CPACK_MODULE_PATH");
if (cpackModulesPath) { 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) { if (!genList) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
<< std::endl); << std::endl);
@ -310,8 +308,8 @@ int main(int argc, char const* const* argv)
std::vector<std::string> generatorsVector; std::vector<std::string> generatorsVector;
cmSystemTools::ExpandListArgument(genList, generatorsVector); cmSystemTools::ExpandListArgument(genList, generatorsVector);
for (std::string const& gen : generatorsVector) { for (std::string const& gen : generatorsVector) {
cmMakefile::ScopePushPop raii(globalMF.get()); cmMakefile::ScopePushPop raii(&globalMF);
cmMakefile* mf = globalMF.get(); cmMakefile* mf = &globalMF;
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl); "Specified generator: " << gen << std::endl);
if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) { if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {

View File

@ -6,6 +6,7 @@
#include "cmsys/Process.h" #include "cmsys/Process.h"
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <iostream> #include <iostream>
#include <memory> // IWYU pragma: keep
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -17,7 +18,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#ifdef _WIN32 #ifdef _WIN32
@ -626,12 +626,12 @@ void cmCTestLaunch::LoadConfig()
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
std::string fname = this->LogDir; std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake"; fname += "CTestLaunchConfig.cmake";
if (cmSystemTools::FileExists(fname.c_str()) && if (cmSystemTools::FileExists(fname.c_str()) &&
mf->ReadListFile(fname.c_str())) { mf.ReadListFile(fname.c_str())) {
this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
cmSystemTools::ConvertToUnixSlashes(this->SourceDir); cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
} }
} }

View File

@ -8,6 +8,7 @@
#include <functional> #include <functional>
#include <iomanip> #include <iomanip>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
@ -28,7 +29,6 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmWorkingDirectory.h" #include "cmWorkingDirectory.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx"
#include "cm_utf8.h" #include "cm_utf8.h"
#include "cmake.h" #include "cmake.h"
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
@ -1636,9 +1636,9 @@ void cmCTestTestHandler::GetListOfTests()
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
mf->AddDefinition("CTEST_CONFIGURATION_TYPE", mf.AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str()); this->CTest->GetConfigType().c_str());
// Add handler for ADD_TEST // Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
@ -1678,7 +1678,7 @@ void cmCTestTestHandler::GetListOfTests()
return; return;
} }
if (!mf->ReadListFile(testFilename)) { if (!mf.ReadListFile(testFilename)) {
return; return;
} }
if (cmSystemTools::GetErrorOccuredFlag()) { if (cmSystemTools::GetErrorOccuredFlag()) {

View File

@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUpdateHandler.h" #include "cmCTestUpdateHandler.h"
#include "cmAlgorithms.h"
#include "cmCLocaleEnvironmentScope.h" #include "cmCLocaleEnvironmentScope.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestBZR.h" #include "cmCTestBZR.h"
@ -16,7 +17,7 @@
#include "cmVersion.h" #include "cmVersion.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx" #include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
static const char* cmCTestUpdateHandlerUpdateStrings[] = { static const char* cmCTestUpdateHandlerUpdateStrings[] = {
@ -134,28 +135,28 @@ int cmCTestUpdateHandler::ProcessHandler()
, this->Quiet); , this->Quiet);
// Create an object to interact with the VCS tool. // Create an object to interact with the VCS tool.
CM_AUTO_PTR<cmCTestVC> vc; std::unique_ptr<cmCTestVC> vc;
switch (this->UpdateType) { switch (this->UpdateType) {
case e_CVS: case e_CVS:
vc.reset(new cmCTestCVS(this->CTest, ofs)); vc = cm::make_unique<cmCTestCVS>(this->CTest, ofs);
break; break;
case e_SVN: case e_SVN:
vc.reset(new cmCTestSVN(this->CTest, ofs)); vc = cm::make_unique<cmCTestSVN>(this->CTest, ofs);
break; break;
case e_BZR: case e_BZR:
vc.reset(new cmCTestBZR(this->CTest, ofs)); vc = cm::make_unique<cmCTestBZR>(this->CTest, ofs);
break; break;
case e_GIT: case e_GIT:
vc.reset(new cmCTestGIT(this->CTest, ofs)); vc = cm::make_unique<cmCTestGIT>(this->CTest, ofs);
break; break;
case e_HG: case e_HG:
vc.reset(new cmCTestHG(this->CTest, ofs)); vc = cm::make_unique<cmCTestHG>(this->CTest, ofs);
break; break;
case e_P4: case e_P4:
vc.reset(new cmCTestP4(this->CTest, ofs)); vc = cm::make_unique<cmCTestP4>(this->CTest, ofs);
break; break;
default: default:
vc.reset(new cmCTestVC(this->CTest, ofs)); vc = cm::make_unique<cmCTestVC>(this->CTest, ofs);
break; break;
} }
vc->SetCommandLineTool(this->UpdateCommand); vc->SetCommandLineTool(this->UpdateCommand);

View File

@ -15,6 +15,7 @@
#include <ctype.h> #include <ctype.h>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -50,7 +51,6 @@
#include "cmVersion.h" #include "cmVersion.h"
#include "cmVersionConfig.h" #include "cmVersionConfig.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#if defined(__BEOS__) || defined(__HAIKU__) #if defined(__BEOS__) || defined(__HAIKU__)
@ -421,9 +421,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), &mf)) {
mf.get())) {
cmCTestOptionalLog( cmCTestOptionalLog(
this, DEBUG, "Cannot find custom configuration file tree" << std::endl, this, DEBUG, "Cannot find custom configuration file tree" << std::endl,
quiet); quiet);
@ -1123,9 +1122,9 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
*log << "* Run internal CTest" << std::endl; *log << "* Run internal CTest" << std::endl;
} }
CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv; std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) { if (modifyEnv) {
saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment); saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment); cmSystemTools::AppendEnv(*environment);
} }
@ -1150,9 +1149,9 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
output->clear(); output->clear();
} }
CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv; std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) { if (modifyEnv) {
saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment); saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment); cmSystemTools::AppendEnv(*environment);
} }

View File

@ -2,11 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCryptoHash.h" #include "cmCryptoHash.h"
#include "cmAlgorithms.h"
#include "cm_kwiml.h" #include "cm_kwiml.h"
#include "cm_rhash.h" #include "cm_rhash.h"
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include <string.h> #include <string.h>
#include <memory> // IWYU pragma: keep
static unsigned int const cmCryptoHashAlgoToId[] = { static unsigned int const cmCryptoHashAlgoToId[] = {
/* clang-format needs this comment to break after the opening brace */ /* clang-format needs this comment to break after the opening brace */
RHASH_MD5, // RHASH_MD5, //
@ -43,39 +46,39 @@ cmCryptoHash::~cmCryptoHash()
rhash_free(this->CTX); rhash_free(this->CTX);
} }
CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo) std::unique_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
{ {
if (strcmp(algo, "MD5") == 0) { if (strcmp(algo, "MD5") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoMD5)); return cm::make_unique<cmCryptoHash>(AlgoMD5);
} }
if (strcmp(algo, "SHA1") == 0) { if (strcmp(algo, "SHA1") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA1)); return cm::make_unique<cmCryptoHash>(AlgoSHA1);
} }
if (strcmp(algo, "SHA224") == 0) { if (strcmp(algo, "SHA224") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA224)); return cm::make_unique<cmCryptoHash>(AlgoSHA224);
} }
if (strcmp(algo, "SHA256") == 0) { if (strcmp(algo, "SHA256") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA256)); return cm::make_unique<cmCryptoHash>(AlgoSHA256);
} }
if (strcmp(algo, "SHA384") == 0) { if (strcmp(algo, "SHA384") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA384)); return cm::make_unique<cmCryptoHash>(AlgoSHA384);
} }
if (strcmp(algo, "SHA512") == 0) { if (strcmp(algo, "SHA512") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA512)); return cm::make_unique<cmCryptoHash>(AlgoSHA512);
} }
if (strcmp(algo, "SHA3_224") == 0) { if (strcmp(algo, "SHA3_224") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_224)); return cm::make_unique<cmCryptoHash>(AlgoSHA3_224);
} }
if (strcmp(algo, "SHA3_256") == 0) { if (strcmp(algo, "SHA3_256") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_256)); return cm::make_unique<cmCryptoHash>(AlgoSHA3_256);
} }
if (strcmp(algo, "SHA3_384") == 0) { if (strcmp(algo, "SHA3_384") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_384)); return cm::make_unique<cmCryptoHash>(AlgoSHA3_384);
} }
if (strcmp(algo, "SHA3_512") == 0) { if (strcmp(algo, "SHA3_512") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512)); return cm::make_unique<cmCryptoHash>(AlgoSHA3_512);
} }
return CM_AUTO_PTR<cmCryptoHash>(nullptr); return std::unique_ptr<cmCryptoHash>(nullptr);
} }
bool cmCryptoHash::IntFromHexDigit(char input, char& output) bool cmCryptoHash::IntFromHexDigit(char input, char& output)

View File

@ -5,12 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep #include "cmConfigure.h" // IWYU pragma: keep
#include <memory> // IWYU pragma: keep
#include <stddef.h> #include <stddef.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include "cm_auto_ptr.hxx"
/** /**
* @brief Abstract base class for cryptographic hash generators * @brief Abstract base class for cryptographic hash generators
*/ */
@ -42,7 +41,7 @@ public:
/// SHA3_224, SHA3_256, SHA3_384, SHA3_512 /// SHA3_224, SHA3_256, SHA3_384, SHA3_512
/// @return A valid auto pointer if algo is supported or /// @return A valid auto pointer if algo is supported or
/// an invalid/NULL pointer otherwise /// an invalid/NULL pointer otherwise
static CM_AUTO_PTR<cmCryptoHash> New(const char* algo); static std::unique_ptr<cmCryptoHash> New(const char* algo);
/// @brief Converts a hex character to its binary value (4 bits) /// @brief Converts a hex character to its binary value (4 bits)
/// @arg input Hex character [0-9a-fA-F]. /// @arg input Hex character [0-9a-fA-F].

View File

@ -11,8 +11,8 @@
#include "cmOutputConverter.h" #include "cmOutputConverter.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include <memory> // IWYU pragma: keep
#include <stddef.h> #include <stddef.h>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
@ -29,7 +29,8 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
for (cmCustomCommandLine const& cmdline : cmdlines) { for (cmCustomCommandLine const& cmdline : cmdlines) {
cmCustomCommandLine argv; cmCustomCommandLine argv;
for (std::string const& clarg : cmdline) { for (std::string const& clarg : cmdline) {
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(clarg); std::unique_ptr<cmCompiledGeneratorExpression> cge =
this->GE->Parse(clarg);
std::string parsed_arg = cge->Evaluate(this->LG, this->Config); std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
if (this->CC.GetCommandExpandLists()) { if (this->CC.GetCommandExpandLists()) {
std::vector<std::string> ExpandedArg; std::vector<std::string> ExpandedArg;
@ -44,7 +45,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
std::vector<std::string> depends = this->CC.GetDepends(); std::vector<std::string> depends = this->CC.GetDepends();
for (std::string const& d : depends) { for (std::string const& d : depends) {
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(d); std::unique_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(d);
std::vector<std::string> result; std::vector<std::string> result;
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
result); result);

View File

@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmELF.h" #include "cmELF.h"
#include "cm_auto_ptr.hxx"
#include "cm_kwiml.h" #include "cm_kwiml.h"
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stddef.h> #include <stddef.h>
#include <utility> #include <utility>
@ -108,7 +108,7 @@ public:
}; };
// Construct and take ownership of the file stream object. // Construct and take ownership of the file stream object.
cmELFInternal(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin, cmELFInternal(cmELF* external, std::unique_ptr<cmsys::ifstream>& fin,
ByteOrderType order) ByteOrderType order)
: External(external) : External(external)
, Stream(*fin.release()) , Stream(*fin.release())
@ -231,7 +231,7 @@ public:
typedef typename Types::tagtype tagtype; typedef typename Types::tagtype tagtype;
// Construct with a stream and byte swap indicator. // Construct with a stream and byte swap indicator.
cmELFInternalImpl(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin, cmELFInternalImpl(cmELF* external, std::unique_ptr<cmsys::ifstream>& fin,
ByteOrderType order); ByteOrderType order);
// Return the number of sections as specified by the ELF header. // Return the number of sections as specified by the ELF header.
@ -424,9 +424,8 @@ private:
}; };
template <class Types> template <class Types>
cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external, cmELFInternalImpl<Types>::cmELFInternalImpl(
CM_AUTO_PTR<cmsys::ifstream>& fin, cmELF* external, std::unique_ptr<cmsys::ifstream>& fin, ByteOrderType order)
ByteOrderType order)
: cmELFInternal(external, fin, order) : cmELFInternal(external, fin, order)
{ {
// Read the main header. // Read the main header.
@ -682,7 +681,7 @@ cmELF::cmELF(const char* fname)
: Internal(nullptr) : Internal(nullptr)
{ {
// Try to open the file. // Try to open the file.
CM_AUTO_PTR<cmsys::ifstream> fin(new cmsys::ifstream(fname)); std::unique_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened. // Quit now if the file could not be opened.
if (!fin.get() || !*fin) { if (!fin.get() || !*fin) {

View File

@ -3,6 +3,7 @@
#include "cmExportBuildAndroidMKGenerator.h" #include "cmExportBuildAndroidMKGenerator.h"
#include <algorithm> #include <algorithm>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <utility> #include <utility>
@ -15,7 +16,6 @@
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator() cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator()
@ -126,7 +126,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
// evaluate any generator expressions with the current // evaluate any generator expressions with the current
// build type of the makefile // build type of the makefile
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(lib); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(lib);
std::string evaluated = std::string evaluated =
cge->Evaluate(target->GetLocalGenerator(), config); cge->Evaluate(target->GetLocalGenerator(), config);
bool relpath = false; bool relpath = false;

View File

@ -17,9 +17,9 @@
#include "cmTargetExport.h" #include "cmTargetExport.h"
#include "cmake.h" #include "cmake.h"
#include "cm_auto_ptr.hxx"
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include <assert.h> #include <assert.h>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
#include <utility> #include <utility>
@ -65,18 +65,17 @@ const char* cmExportFileGenerator::GetMainExportFileName() const
bool cmExportFileGenerator::GenerateImportFile() bool cmExportFileGenerator::GenerateImportFile()
{ {
// Open the output file to generate it. // Open the output file to generate it.
CM_AUTO_PTR<cmsys::ofstream> foutPtr; std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->AppendMode) { if (this->AppendMode) {
// Open for append. // Open for append.
CM_AUTO_PTR<cmsys::ofstream> ap( foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app)); std::ios::app);
foutPtr = ap;
} else { } else {
// Generate atomically and with copy-if-different. // Generate atomically and with copy-if-different.
CM_AUTO_PTR<cmGeneratedFileStream> ap( std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->MainImportFile.c_str(), true)); new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
ap->SetCopyIfDifferent(true); ap->SetCopyIfDifferent(true);
foutPtr = ap; foutPtr = std::move(ap);
} }
if (!foutPtr.get() || !*foutPtr) { if (!foutPtr.get() || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError(); std::string se = cmSystemTools::GetLastSystemError();
@ -372,7 +371,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
std::string dirs = cmGeneratorExpression::Preprocess( std::string dirs = cmGeneratorExpression::Preprocess(
tei->InterfaceIncludeDirectories, preprocessRule, true); tei->InterfaceIncludeDirectories, preprocessRule, true);
this->ReplaceInstallPrefix(dirs); this->ReplaceInstallPrefix(dirs);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
std::string exportDirs = std::string exportDirs =
cge->Evaluate(target->GetLocalGenerator(), "", false, target); cge->Evaluate(target->GetLocalGenerator(), "", false, target);

View File

@ -4,8 +4,10 @@
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <utility> #include <utility>
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
@ -13,7 +15,6 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmTargetLinkLibraryType.h" #include "cmTargetLinkLibraryType.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
class cmExecutionStatus; class cmExecutionStatus;
@ -47,16 +48,15 @@ void cmExportLibraryDependenciesCommand::FinalPass()
void cmExportLibraryDependenciesCommand::ConstFinalPass() const void cmExportLibraryDependenciesCommand::ConstFinalPass() const
{ {
// Use copy-if-different if not appending. // Use copy-if-different if not appending.
CM_AUTO_PTR<cmsys::ofstream> foutPtr; std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->Append) { if (this->Append) {
CM_AUTO_PTR<cmsys::ofstream> ap( foutPtr =
new cmsys::ofstream(this->Filename.c_str(), std::ios::app)); cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
foutPtr = ap;
} else { } else {
CM_AUTO_PTR<cmGeneratedFileStream> ap( std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->Filename.c_str(), true)); new cmGeneratedFileStream(this->Filename.c_str(), true));
ap->SetCopyIfDifferent(true); ap->SetCopyIfDifferent(true);
foutPtr = ap; foutPtr = std::move(ap);
} }
std::ostream& fout = *foutPtr; std::ostream& fout = *foutPtr;

View File

@ -11,9 +11,9 @@
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cm_auto_ptr.hxx"
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <utility> #include <utility>
cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
@ -65,7 +65,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, nullptr, cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, nullptr,
nullptr); nullptr);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE, cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE,
cmTarget::VisibilityNormal, tgt->Target->GetMakefile()); cmTarget::VisibilityNormal, tgt->Target->GetMakefile());

View File

@ -10,6 +10,7 @@
#include "cmsys/String.hxx" #include "cmsys/String.hxx"
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -30,7 +31,6 @@
#include "cmPolicies.h" #include "cmPolicies.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTimestamp.h" #include "cmTimestamp.h"
#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h" #include "cm_sys_stat.h"
#include "cmake.h" #include "cmake.h"
@ -368,8 +368,8 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
return false; return false;
} }
CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str())); std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
if (hash.get()) { if (hash) {
std::string out = hash->HashFile(args[1]); std::string out = hash->HashFile(args[1]);
if (!out.empty()) { if (!out.empty()) {
this->Makefile->AddDefinition(args[2], out.c_str()); this->Makefile->AddDefinition(args[2], out.c_str());
@ -2629,7 +2629,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO"); const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
std::string expectedHash; std::string expectedHash;
std::string hashMatchMSG; std::string hashMatchMSG;
CM_AUTO_PTR<cmCryptoHash> hash; std::unique_ptr<cmCryptoHash> hash;
bool showProgress = false; bool showProgress = false;
std::string userpwd; std::string userpwd;
@ -2688,8 +2688,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5."); this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
return false; return false;
} }
hash = hash = cm::make_unique<cmCryptoHash>(cmCryptoHash::AlgoMD5);
CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(cmCryptoHash::AlgoMD5));
hashMatchMSG = "MD5 sum"; hashMatchMSG = "MD5 sum";
expectedHash = cmSystemTools::LowerCase(*i); expectedHash = cmSystemTools::LowerCase(*i);
} else if (*i == "SHOW_PROGRESS") { } else if (*i == "SHOW_PROGRESS") {
@ -2710,7 +2709,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
} }
std::string algo = i->substr(0, pos); std::string algo = i->substr(0, pos);
expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1)); expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1));
hash = CM_AUTO_PTR<cmCryptoHash>(cmCryptoHash::New(algo.c_str())); hash = std::unique_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
if (!hash.get()) { if (!hash.get()) {
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo; err += algo;
@ -2906,7 +2905,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Verify MD5 sum if requested: // Verify MD5 sum if requested:
// //
if (hash.get()) { if (hash) {
std::string actualHash = hash->HashFile(file); std::string actualHash = hash->HashFile(file);
if (actualHash.empty()) { if (actualHash.empty()) {
this->SetError("DOWNLOAD cannot compute hash on downloaded file"); this->SetError("DOWNLOAD cannot compute hash on downloaded file");
@ -3195,15 +3194,15 @@ void cmFileCommand::AddEvaluationFile(const std::string& inputName,
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression outputGe(lfbt); cmGeneratorExpression outputGe(lfbt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputCge = std::unique_ptr<cmCompiledGeneratorExpression> outputCge =
outputGe.Parse(outputExpr); outputGe.Parse(outputExpr);
cmGeneratorExpression conditionGe(lfbt); cmGeneratorExpression conditionGe(lfbt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> conditionCge = std::unique_ptr<cmCompiledGeneratorExpression> conditionCge =
conditionGe.Parse(condition); conditionGe.Parse(condition);
this->Makefile->AddEvaluationFile(inputName, outputCge, conditionCge, this->Makefile->AddEvaluationFile(inputName, std::move(outputCge),
inputIsContent); std::move(conditionCge), inputIsContent);
} }
bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args) bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args)

View File

@ -13,6 +13,7 @@
#include <deque> #include <deque>
#include <functional> #include <functional>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -24,7 +25,6 @@
#include "cmState.h" #include "cmState.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#if defined(__HAIKU__) #if defined(__HAIKU__)
@ -1611,10 +1611,10 @@ protected:
private: private:
bool Search(cmFileList&); bool Search(cmFileList&);
virtual bool Search(std::string const& parent, cmFileList&) = 0; virtual bool Search(std::string const& parent, cmFileList&) = 0;
virtual CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const = 0; virtual std::unique_ptr<cmFileListGeneratorBase> Clone() const = 0;
friend class cmFileList; friend class cmFileList;
cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next); cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next);
CM_AUTO_PTR<cmFileListGeneratorBase> Next; std::unique_ptr<cmFileListGeneratorBase> Next;
}; };
class cmFileList class cmFileList
@ -1638,7 +1638,7 @@ public:
} }
bool Search() bool Search()
{ {
if (this->First.get()) { if (this->First) {
return this->First->Search(*this); return this->First->Search(*this);
} }
return false; return false;
@ -1647,7 +1647,7 @@ public:
private: private:
virtual bool Visit(std::string const& fullPath) = 0; virtual bool Visit(std::string const& fullPath) = 0;
friend class cmFileListGeneratorBase; friend class cmFileListGeneratorBase;
CM_AUTO_PTR<cmFileListGeneratorBase> First; std::unique_ptr<cmFileListGeneratorBase> First;
cmFileListGeneratorBase* Last; cmFileListGeneratorBase* Last;
}; };
@ -1688,7 +1688,7 @@ cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext(
bool cmFileListGeneratorBase::Consider(std::string const& fullPath, bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
cmFileList& listing) cmFileList& listing)
{ {
if (this->Next.get()) { if (this->Next) {
return this->Next->Search(fullPath + "/", listing); return this->Next->Search(fullPath + "/", listing);
} }
return listing.Visit(fullPath + "/"); return listing.Visit(fullPath + "/");
@ -1715,9 +1715,9 @@ private:
std::string fullPath = parent + this->String; std::string fullPath = parent + this->String;
return this->Consider(fullPath, lister); return this->Consider(fullPath, lister);
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g( std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorFixed(*this)); new cmFileListGeneratorFixed(*this));
return g; return g;
} }
@ -1748,9 +1748,9 @@ private:
} }
return false; return false;
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g( std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorEnumerate(*this)); new cmFileListGeneratorEnumerate(*this));
return g; return g;
} }
@ -1820,9 +1820,9 @@ private:
} }
return false; return false;
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g( std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorProject(*this)); new cmFileListGeneratorProject(*this));
return g; return g;
} }
@ -1874,9 +1874,9 @@ private:
} }
return false; return false;
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g( std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorMacProject(*this)); new cmFileListGeneratorMacProject(*this));
return g; return g;
} }
@ -1918,9 +1918,9 @@ private:
} }
return false; return false;
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g( std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorCaseInsensitive(*this)); new cmFileListGeneratorCaseInsensitive(*this));
return g; return g;
} }
@ -1963,10 +1963,9 @@ private:
} }
return false; return false;
} }
CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{ {
CM_AUTO_PTR<cmFileListGeneratorBase> g(new cmFileListGeneratorGlob(*this)); return cm::make_unique<cmFileListGeneratorGlob>(*this);
return g;
} }
}; };

View File

@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h" #include "cmForEachCommand.h"
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -9,7 +10,6 @@
#include "cmExecutionStatus.h" #include "cmExecutionStatus.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf) cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf)
@ -35,7 +35,8 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endofreach for this statement // if this is the endofreach for this statement
if (!this->Depth) { if (!this->Depth) {
// Remove the function blocker for this scope or bail. // Remove the function blocker for this scope or bail.
CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) { if (!fb.get()) {
return false; return false;
} }
@ -181,7 +182,7 @@ bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args) bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
{ {
CM_AUTO_PTR<cmForEachFunctionBlocker> f( std::unique_ptr<cmForEachFunctionBlocker> f(
new cmForEachFunctionBlocker(this->Makefile)); new cmForEachFunctionBlocker(this->Makefile));
f->Args.push_back(args[0]); f->Args.push_back(args[0]);
@ -213,7 +214,7 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
} }
} }
this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass unique_ptr
return true; return true;
} }

View File

@ -3,6 +3,7 @@
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <memory> // IWYU pragma: keep
#include <utility> #include <utility>
#include "assert.h" #include "assert.h"
@ -12,7 +13,6 @@
#include "cmGeneratorExpressionLexer.h" #include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h" #include "cmGeneratorExpressionParser.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
cmGeneratorExpression::cmGeneratorExpression( cmGeneratorExpression::cmGeneratorExpression(
const cmListFileBacktrace& backtrace) const cmListFileBacktrace& backtrace)
@ -20,14 +20,14 @@ cmGeneratorExpression::cmGeneratorExpression(
{ {
} }
CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse( std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
std::string const& input) std::string const& input)
{ {
return CM_AUTO_PTR<cmCompiledGeneratorExpression>( return std::unique_ptr<cmCompiledGeneratorExpression>(
new cmCompiledGeneratorExpression(this->Backtrace, input)); new cmCompiledGeneratorExpression(this->Backtrace, input));
} }
CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse( std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
const char* input) const char* input)
{ {
return this->Parse(std::string(input ? input : "")); return this->Parse(std::string(input ? input : ""));

View File

@ -7,8 +7,8 @@
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cm_auto_ptr.hxx"
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <string> #include <string>
#include <vector> #include <vector>
@ -39,8 +39,9 @@ public:
cmListFileBacktrace const& backtrace = cmListFileBacktrace()); cmListFileBacktrace const& backtrace = cmListFileBacktrace());
~cmGeneratorExpression(); ~cmGeneratorExpression();
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(std::string const& input); std::unique_ptr<cmCompiledGeneratorExpression> Parse(
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(const char* input); std::string const& input);
std::unique_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
enum PreprocessContext enum PreprocessContext
{ {

View File

@ -3,6 +3,7 @@
#include "cmGeneratorExpressionEvaluationFile.h" #include "cmGeneratorExpressionEvaluationFile.h"
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <utility> #include <utility>
@ -13,17 +14,16 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
const std::string& input, const std::string& input,
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent, std::unique_ptr<cmCompiledGeneratorExpression> condition,
cmPolicies::PolicyStatus policyStatusCMP0070) bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070)
: Input(input) : Input(input)
, OutputFileExpr(outputFileExpr) , OutputFileExpr(std::move(outputFileExpr))
, Condition(condition) , Condition(std::move(condition))
, InputIsContent(inputIsContent) , InputIsContent(inputIsContent)
, PolicyStatusCMP0070(policyStatusCMP0070) , PolicyStatusCMP0070(policyStatusCMP0070)
{ {
@ -144,7 +144,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace(); cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
cmGeneratorExpression contentGE(lfbt); cmGeneratorExpression contentGE(lfbt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> inputExpression = std::unique_ptr<cmCompiledGeneratorExpression> inputExpression =
contentGE.Parse(inputContent); contentGE.Parse(inputContent);
std::map<std::string, std::string> outputFiles; std::map<std::string, std::string> outputFiles;

View File

@ -6,12 +6,12 @@
#include "cmConfigure.h" // IWYU pragma: keep #include "cmConfigure.h" // IWYU pragma: keep
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <string> #include <string>
#include <vector> #include <vector>
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cmPolicies.h" #include "cmPolicies.h"
#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h" #include "cm_sys_stat.h"
class cmLocalGenerator; class cmLocalGenerator;
@ -21,9 +21,9 @@ class cmGeneratorExpressionEvaluationFile
public: public:
cmGeneratorExpressionEvaluationFile( cmGeneratorExpressionEvaluationFile(
const std::string& input, const std::string& input,
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr, std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent, std::unique_ptr<cmCompiledGeneratorExpression> condition,
cmPolicies::PolicyStatus policyStatusCMP0070); bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070);
void Generate(cmLocalGenerator* lg); void Generate(cmLocalGenerator* lg);
@ -47,8 +47,8 @@ private:
private: private:
const std::string Input; const std::string Input;
const CM_AUTO_PTR<cmCompiledGeneratorExpression> OutputFileExpr; const std::unique_ptr<cmCompiledGeneratorExpression> OutputFileExpr;
const CM_AUTO_PTR<cmCompiledGeneratorExpression> Condition; const std::unique_ptr<cmCompiledGeneratorExpression> Condition;
std::vector<std::string> Files; std::vector<std::string> Files;
const bool InputIsContent; const bool InputIsContent;
cmPolicies::PolicyStatus PolicyStatusCMP0070; cmPolicies::PolicyStatus PolicyStatusCMP0070;

View File

@ -17,7 +17,6 @@
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
@ -26,6 +25,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
@ -39,7 +39,7 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
cmGeneratorExpressionDAGChecker* dagChecker) cmGeneratorExpressionDAGChecker* dagChecker)
{ {
cmGeneratorExpression ge(context->Backtrace); cmGeneratorExpression ge(context->Backtrace);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem); cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
std::string result = std::string result =
cge->Evaluate(lg, context->Config, context->Quiet, headTarget, cge->Evaluate(lg, context->Config, context->Quiet, headTarget,

View File

@ -7,6 +7,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep
#include <queue> #include <queue>
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
@ -32,7 +33,6 @@
#include "cmTarget.h" #include "cmTarget.h"
#include "cmTargetLinkLibraryType.h" #include "cmTargetLinkLibraryType.h"
#include "cmTargetPropertyComputer.h" #include "cmTargetPropertyComputer.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
class cmMessenger; class cmMessenger;
@ -64,13 +64,13 @@ class cmGeneratorTarget::TargetPropertyEntry
static cmLinkImplItem NoLinkImplItem; static cmLinkImplItem NoLinkImplItem;
public: public:
TargetPropertyEntry(CM_AUTO_PTR<cmCompiledGeneratorExpression> cge, TargetPropertyEntry(std::unique_ptr<cmCompiledGeneratorExpression> cge,
cmLinkImplItem const& item = NoLinkImplItem) cmLinkImplItem const& item = NoLinkImplItem)
: ge(cge) : ge(std::move(cge))
, LinkImplItem(item) , LinkImplItem(item)
{ {
} }
const CM_AUTO_PTR<cmCompiledGeneratorExpression> ge; const std::unique_ptr<cmCompiledGeneratorExpression> ge;
cmLinkImplItem const& LinkImplItem; cmLinkImplItem const& LinkImplItem;
}; };
cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
@ -84,9 +84,10 @@ void CreatePropertyGeneratorExpressions(
for (std::vector<std::string>::const_iterator it = entries.begin(); for (std::vector<std::string>::const_iterator it = entries.begin();
it != entries.end(); ++it, ++btIt) { it != entries.end(); ++it, ++btIt) {
cmGeneratorExpression ge(*btIt); cmGeneratorExpression ge(*btIt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*it); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge)); items.push_back(
new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
} }
} }
@ -309,7 +310,7 @@ std::string cmGeneratorTarget::GetOutputName(
// Now evaluate genex and update the previously-prepared map entry. // Now evaluate genex and update the previously-prepared map entry.
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outName); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
i->second = cge->Evaluate(this->LocalGenerator, config); i->second = cge->Evaluate(this->LocalGenerator, config);
} else if (i->second.empty()) { } else if (i->second.empty()) {
// An empty map entry indicates we have been called recursively // An empty map entry indicates we have been called recursively
@ -333,9 +334,9 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src)
{ {
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
this->SourceEntries.push_back(new TargetPropertyEntry(cge)); this->SourceEntries.push_back(new TargetPropertyEntry(std::move(cge)));
this->ClearSourcesCache(); this->ClearSourcesCache();
} }
@ -359,13 +360,14 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before); this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
// Insert before begin/end // Insert before begin/end
std::vector<TargetPropertyEntry*>::iterator pos = before std::vector<TargetPropertyEntry*>::iterator pos = before
? this->IncludeDirectoriesEntries.begin() ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end(); : this->IncludeDirectoriesEntries.end();
this->IncludeDirectoriesEntries.insert(pos, new TargetPropertyEntry(cge)); this->IncludeDirectoriesEntries.insert(
pos, new TargetPropertyEntry(std::move(cge)));
} }
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends( std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
@ -795,10 +797,10 @@ static void AddInterfaceEntries(
if (lib.Target) { if (lib.Target) {
std::string genex = "$<TARGET_PROPERTY:" + lib + "," + prop + ">"; std::string genex = "$<TARGET_PROPERTY:" + lib + "," + prop + ">";
cmGeneratorExpression ge(lib.Backtrace); cmGeneratorExpression ge(lib.Backtrace);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(genex); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true); cge->SetEvaluateForBuildsystem(true);
entries.push_back( entries.push_back(
new cmGeneratorTarget::TargetPropertyEntry(cge, lib)); new cmGeneratorTarget::TargetPropertyEntry(std::move(cge), lib));
} }
} }
} }
@ -2285,7 +2287,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Check for target references in generator expressions. // Check for target references in generator expressions.
for (std::string const& cl : cCmdLine) { for (std::string const& cl : cCmdLine) {
const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cl); const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true); cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets(); std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
targets.insert(geTargets.begin(), geTargets.end()); targets.insert(geTargets.begin(), geTargets.end());
@ -2570,10 +2572,10 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
libDir = frameworkCheck.match(1); libDir = frameworkCheck.match(1);
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str()); ge.Parse(libDir.c_str());
linkInterfaceIncludeDirectoriesEntries.push_back( linkInterfaceIncludeDirectoriesEntries.push_back(
new cmGeneratorTarget::TargetPropertyEntry(cge)); new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
} }
} }
@ -2781,10 +2783,10 @@ void cmGeneratorTarget::GetCompileDefinitions(
} }
case cmPolicies::OLD: { case cmPolicies::OLD: {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp); ge.Parse(configProp);
linkInterfaceCompileDefinitionsEntries.push_back( linkInterfaceCompileDefinitionsEntries.push_back(
new cmGeneratorTarget::TargetPropertyEntry(cge)); new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
} break; } break;
case cmPolicies::NEW: case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
@ -4214,7 +4216,7 @@ void cmGeneratorTarget::ExpandLinkItems(
dagChecker.SetTransitivePropertiesOnly(); dagChecker.SetTransitivePropertiesOnly();
} }
std::vector<std::string> libs; std::vector<std::string> libs;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(value); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config, cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config,
false, headTarget, this, false, headTarget, this,
&dagChecker), &dagChecker),
@ -4484,7 +4486,8 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
if (const char* config_outdir = this->GetProperty(configProp)) { if (const char* config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory. // Use the user-specified per-configuration output directory.
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(config_outdir); std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(config_outdir);
out = cge->Evaluate(this->LocalGenerator, config); out = cge->Evaluate(this->LocalGenerator, config);
// Skip per-configuration subdirectory. // Skip per-configuration subdirectory.
@ -4492,7 +4495,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
} else if (const char* outdir = this->GetProperty(propertyName)) { } else if (const char* outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory. // Use the user-specified output directory.
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outdir); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
out = cge->Evaluate(this->LocalGenerator, config); out = cge->Evaluate(this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a // Skip per-configuration subdirectory if the value contained a
@ -5222,7 +5225,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
cmGeneratorExpressionDAGChecker dagChecker( cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "LINK_LIBRARIES", nullptr, nullptr); this->GetName(), "LINK_LIBRARIES", nullptr, nullptr);
cmGeneratorExpression ge(*btIt); cmGeneratorExpression ge(*btIt);
CM_AUTO_PTR<cmCompiledGeneratorExpression> const cge = ge.Parse(*le); std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
std::string const evaluated = std::string const evaluated =
cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker); cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
cmSystemTools::ExpandListArgument(evaluated, llibs); cmSystemTools::ExpandListArgument(evaluated, llibs);

View File

@ -363,7 +363,7 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
this->GeneratorTarget->GetCreateRuleVariable(language, config); this->GeneratorTarget->GetCreateRuleVariable(language, config);
bool useWatcomQuote = bool useWatcomQuote =
this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE"); this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->GetGlobalGenerator()->CreateLinkLineComputer( this->GetGlobalGenerator()->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));

View File

@ -10,6 +10,7 @@
#include <ctype.h> #include <ctype.h>
#include <functional> #include <functional>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
@ -32,7 +33,6 @@
#include "cmTarget.h" #include "cmTarget.h"
#include "cmTargetDepend.h" #include "cmTargetDepend.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
class cmLinkLineComputer; class cmLinkLineComputer;
@ -1692,9 +1692,10 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld); snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld);
snapshot.GetDirectory().SetRelativePathTopSource(dir_top_src.c_str()); snapshot.GetDirectory().SetRelativePathTopSource(dir_top_src.c_str());
snapshot.GetDirectory().SetRelativePathTopBinary(dir_top_bld.c_str()); snapshot.GetDirectory().SetRelativePathTopBinary(dir_top_bld.c_str());
CM_AUTO_PTR<cmMakefile> mfd(new cmMakefile(this, snapshot)); auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
CM_AUTO_PTR<cmLocalNinjaGenerator> lgd(static_cast<cmLocalNinjaGenerator*>( std::unique_ptr<cmLocalNinjaGenerator> lgd(
this->CreateLocalGenerator(mfd.get()))); static_cast<cmLocalNinjaGenerator*>(
this->CreateLocalGenerator(mfd.get())));
this->Makefiles.push_back(mfd.release()); this->Makefiles.push_back(mfd.release());
this->LocalGenerators.push_back(lgd.release()); this->LocalGenerators.push_back(lgd.release());
} }
@ -1869,7 +1870,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmake cm(cmake::RoleInternal); cmake cm(cmake::RoleInternal);
cm.SetHomeDirectory(dir_top_src); cm.SetHomeDirectory(dir_top_src);
cm.SetHomeOutputDirectory(dir_top_bld); cm.SetHomeOutputDirectory(dir_top_bld);
CM_AUTO_PTR<cmGlobalNinjaGenerator> ggd( std::unique_ptr<cmGlobalNinjaGenerator> ggd(
static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja"))); static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja")));
if (!ggd.get() || if (!ggd.get() ||
!ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld, !ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld,

View File

@ -708,7 +708,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
const char* propertyValue = const char* propertyValue =
target->Target->GetMakefile()->GetDefinition(propertyName); target->Target->GetMakefile()->GetDefinition(propertyName);
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue); ge.Parse(propertyValue);
if (cmSystemTools::IsOn( if (cmSystemTools::IsOn(
cge->Evaluate(target->GetLocalGenerator(), *i))) { cge->Evaluate(target->GetLocalGenerator(), *i))) {

View File

@ -5,10 +5,12 @@
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <assert.h> #include <assert.h>
#include <iomanip> #include <iomanip>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h" #include "cmCustomCommandGenerator.h"
#include "cmDocumentationEntry.h" #include "cmDocumentationEntry.h"
@ -29,7 +31,6 @@
#include "cmXCode21Object.h" #include "cmXCode21Object.h"
#include "cmXCodeObject.h" #include "cmXCodeObject.h"
#include "cmXCodeScheme.h" #include "cmXCodeScheme.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
struct cmLinkImplementation; struct cmLinkImplementation;
@ -197,8 +198,8 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
return nullptr; return nullptr;
} }
CM_AUTO_PTR<cmGlobalXCodeGenerator> gg( auto gg = cm::make_unique<cmGlobalXCodeGenerator>(cm, version_string,
new cmGlobalXCodeGenerator(cm, version_string, version_number)); version_number);
return gg.release(); return gg.release();
#else #else
std::cerr << "CMake should be built with cmake to use Xcode, " std::cerr << "CMake should be built with cmake to use Xcode, "
@ -669,7 +670,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
if (const char* cflags = sf->GetProperty("COMPILE_FLAGS")) { if (const char* cflags = sf->GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
std::string configName = "NO-PER-CONFIG-SUPPORT-IN-XCODE"; std::string configName = "NO-PER-CONFIG-SUPPORT-IN-XCODE";
CM_AUTO_PTR<cmCompiledGeneratorExpression> compiledExpr = ge.Parse(cflags); std::unique_ptr<cmCompiledGeneratorExpression> compiledExpr =
ge.Parse(cflags);
const char* processed = compiledExpr->Evaluate(lg, configName); const char* processed = compiledExpr->Evaluate(lg, configName);
if (compiledExpr->GetHadContextSensitiveCondition()) { if (compiledExpr->GetHadContextSensitiveCondition()) {
std::ostringstream e; std::ostringstream e;

View File

@ -4,6 +4,7 @@
#include <cstddef> #include <cstddef>
#include <iostream> #include <iostream>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <utility> #include <utility>
@ -15,7 +16,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
namespace { namespace {
@ -147,8 +147,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator ggi(&cm); cmGlobalGenerator ggi(&cm);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&ggi, cm.GetCurrentSnapshot())); cmMakefile mf(&ggi, cm.GetCurrentSnapshot());
CM_AUTO_PTR<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get())); std::unique_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(&mf));
const char* inFileName = settingsFileName; const char* inFileName = settingsFileName;
@ -159,7 +159,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
} }
} }
if (!mf->ReadListFile(inFileName)) { if (!mf.ReadListFile(inFileName)) {
cmSystemTools::Error("Problem opening GraphViz options file: ", cmSystemTools::Error("Problem opening GraphViz options file: ",
inFileName); inFileName);
return; return;
@ -169,7 +169,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
#define __set_if_set(var, cmakeDefinition) \ #define __set_if_set(var, cmakeDefinition) \
{ \ { \
const char* value = mf->GetDefinition(cmakeDefinition); \ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \ if (value) { \
(var) = value; \ (var) = value; \
} \ } \
@ -182,9 +182,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
#define __set_bool_if_set(var, cmakeDefinition) \ #define __set_bool_if_set(var, cmakeDefinition) \
{ \ { \
const char* value = mf->GetDefinition(cmakeDefinition); \ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \ if (value) { \
(var) = mf->IsOn(cmakeDefinition); \ (var) = mf.IsOn(cmakeDefinition); \
} \ } \
} }

View File

@ -8,9 +8,10 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmOutputConverter.h" #include "cmOutputConverter.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#include <memory> // IWYU pragma: keep
static std::string cmIfCommandError( static std::string cmIfCommandError(
std::vector<cmExpandedCommandArgument> const& args) std::vector<cmExpandedCommandArgument> const& args)
{ {
@ -36,7 +37,8 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endif for this if statement, then start executing // if this is the endif for this if statement, then start executing
if (!this->ScopeDepth) { if (!this->ScopeDepth) {
// Remove the function blocker for this scope or bail. // Remove the function blocker for this scope or bail.
CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) { if (!fb.get()) {
return false; return false;
} }

View File

@ -7,7 +7,8 @@
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include <memory> // IWYU pragma: keep
cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
std::vector<std::string> const& dirs, const char* dest, std::vector<std::string> const& dirs, const char* dest,
@ -63,7 +64,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig(
std::vector<std::string> dirs; std::vector<std::string> dirs;
cmGeneratorExpression ge; cmGeneratorExpression ge;
for (std::string const& d : this->Directories) { for (std::string const& d : this->Directories) {
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(d); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(d);
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), dirs); cge->Evaluate(this->LocalGenerator, config), dirs);
} }

View File

@ -5,7 +5,8 @@
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cmInstallType.h" #include "cmInstallType.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include <memory> // IWYU pragma: keep
class cmLocalGenerator; class cmLocalGenerator;
@ -82,7 +83,7 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(
std::vector<std::string> files; std::vector<std::string> files;
cmGeneratorExpression ge; cmGeneratorExpression ge;
for (std::string const& f : this->Files) { for (std::string const& f : this->Files) {
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(f); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(f);
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), files); cge->Evaluate(this->LocalGenerator, config), files);
} }

View File

@ -6,9 +6,9 @@
#include "cmConfigure.h" // IWYU pragma: keep #include "cmConfigure.h" // IWYU pragma: keep
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cm_auto_ptr.hxx"
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <string> #include <string>
#include <vector> #include <vector>
@ -22,7 +22,7 @@ class cmMakefile;
class cmInstalledFile class cmInstalledFile
{ {
public: public:
typedef CM_AUTO_PTR<cmCompiledGeneratorExpression> typedef std::unique_ptr<cmCompiledGeneratorExpression>
CompiledGeneratorExpressionPtrType; CompiledGeneratorExpressionPtrType;
typedef std::vector<cmCompiledGeneratorExpression*> ExpressionVectorType; typedef std::vector<cmCompiledGeneratorExpression*> ExpressionVectorType;

View File

@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <utility> #include <utility>
@ -22,7 +23,6 @@
#include "cmState.h" #include "cmState.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
@ -505,7 +505,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
std::string launcher = property_value; std::string launcher = property_value;
launcher += " "; launcher += " ";
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander()); this->CreateRulePlaceholderExpander());
rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars); rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);

View File

@ -5,6 +5,7 @@
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h" #include "cmsys/Terminal.h"
#include <algorithm> #include <algorithm>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <utility> #include <utility>
@ -28,7 +29,6 @@
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
// Include dependency scanners for supported languages. Only the // Include dependency scanners for supported languages. Only the
@ -121,9 +121,9 @@ void cmLocalUnixMakefileGenerator3::Generate()
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue; continue;
} }
CM_AUTO_PTR<cmMakefileTargetGenerator> tg( std::unique_ptr<cmMakefileTargetGenerator> tg(
cmMakefileTargetGenerator::New(target)); cmMakefileTargetGenerator::New(target));
if (tg.get()) { if (tg) {
tg->WriteRuleFiles(); tg->WriteRuleFiles();
gg->RecordTargetProgress(tg.get()); gg->RecordTargetProgress(tg.get());
} }
@ -930,7 +930,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
*content << dir; *content << dir;
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander()); this->CreateRulePlaceholderExpander());
// Add each command line to the set of commands. // Add each command line to the set of commands.

View File

@ -1453,7 +1453,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
} }
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) { if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
fc.CompileFlags = cge->Evaluate(lg, *i); fc.CompileFlags = cge->Evaluate(lg, *i);
needfc = true; needfc = true;
} }
@ -1849,7 +1849,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(
if (!addedPrelink) { if (!addedPrelink) {
event.Write(target->GetPreLinkCommands()); event.Write(target->GetPreLinkCommands());
} }
CM_AUTO_PTR<cmCustomCommand> pcc( std::unique_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target, configName, this->FortranProject)); this->MaybeCreateImplibDir(target, configName, this->FortranProject));
if (pcc.get()) { if (pcc.get()) {
event.Write(*pcc); event.Write(*pcc);

View File

@ -78,12 +78,12 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
} }
} }
CM_AUTO_PTR<cmCustomCommand> std::unique_ptr<cmCustomCommand>
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
const std::string& config, const std::string& config,
bool isFortran) bool isFortran)
{ {
CM_AUTO_PTR<cmCustomCommand> pcc; std::unique_ptr<cmCustomCommand> pcc;
// If an executable exports symbols then VS wants to create an // If an executable exports symbols then VS wants to create an
// import library but forgets to create the output directory. // import library but forgets to create the output directory.

View File

@ -6,12 +6,11 @@
#include "cmConfigure.h" // IWYU pragma: keep #include "cmConfigure.h" // IWYU pragma: keep
#include <map> #include <map>
#include <memory> #include <memory> // IWYU pragma: keep
#include <string> #include <string>
#include "cmGlobalVisualStudioGenerator.h" #include "cmGlobalVisualStudioGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cm_auto_ptr.hxx"
class cmCustomCommand; class cmCustomCommand;
class cmCustomCommandGenerator; class cmCustomCommandGenerator;
@ -56,9 +55,8 @@ protected:
virtual bool CustomCommandUseLocal() const { return false; } virtual bool CustomCommandUseLocal() const { return false; }
/** Construct a custom command to make exe import lib dir. */ /** Construct a custom command to make exe import lib dir. */
CM_AUTO_PTR<cmCustomCommand> MaybeCreateImplibDir(cmGeneratorTarget* target, std::unique_ptr<cmCustomCommand> MaybeCreateImplibDir(
const std::string& config, cmGeneratorTarget* target, const std::string& config, bool isFortran);
bool isFortran);
}; };
#endif #endif

View File

@ -7,6 +7,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -37,7 +38,6 @@
#include "cmTestGenerator.h" // IWYU pragma: keep #include "cmTestGenerator.h" // IWYU pragma: keep
#include "cmVersion.h" #include "cmVersion.h"
#include "cmWorkingDirectory.h" #include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h" #include "cm_sys_stat.h"
#include "cmake.h" #include "cmake.h"
@ -264,7 +264,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
// Lookup the command prototype. // Lookup the command prototype.
if (cmCommand* proto = this->GetState()->GetCommand(name)) { if (cmCommand* proto = this->GetState()->GetCommand(name)) {
// Clone the prototype. // Clone the prototype.
CM_AUTO_PTR<cmCommand> pcmd(proto->Clone()); std::unique_ptr<cmCommand> pcmd(proto->Clone());
pcmd->SetMakefile(this); pcmd->SetMakefile(this);
// Decide whether to invoke the command. // Decide whether to invoke the command.
@ -584,11 +584,12 @@ void cmMakefile::EnforceDirectoryLevelRules() const
void cmMakefile::AddEvaluationFile( void cmMakefile::AddEvaluationFile(
const std::string& inputFile, const std::string& inputFile,
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName, std::unique_ptr<cmCompiledGeneratorExpression> outputName,
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent) std::unique_ptr<cmCompiledGeneratorExpression> condition,
bool inputIsContent)
{ {
this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile( this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
inputFile, outputName, condition, inputIsContent, inputFile, std::move(outputName), std::move(condition), inputIsContent,
this->GetPolicyStatus(cmPolicies::CMP0070))); this->GetPolicyStatus(cmPolicies::CMP0070)));
} }
@ -2874,7 +2875,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
FunctionBlockersType::size_type barrier = FunctionBlockersType::size_type barrier =
this->FunctionBlockerBarriers.back(); this->FunctionBlockerBarriers.back();
while (this->FunctionBlockers.size() > barrier) { while (this->FunctionBlockers.size() > barrier) {
CM_AUTO_PTR<cmFunctionBlocker> fb(this->FunctionBlockers.back()); std::unique_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
this->FunctionBlockers.pop_back(); this->FunctionBlockers.pop_back();
if (reportError) { if (reportError) {
// Report the context in which the unclosed block was opened. // Report the context in which the unclosed block was opened.
@ -3009,7 +3010,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
this->FunctionBlockers.push_back(fb); this->FunctionBlockers.push_back(fb);
} }
CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker( std::unique_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
cmFunctionBlocker* fb, const cmListFileFunction& lff) cmFunctionBlocker* fb, const cmListFileFunction& lff)
{ {
// Find the function blocker stack barrier for the current scope. // Find the function blocker stack barrier for the current scope.
@ -3042,11 +3043,11 @@ CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
} }
cmFunctionBlocker* b = *pos; cmFunctionBlocker* b = *pos;
this->FunctionBlockers.erase(pos); this->FunctionBlockers.erase(pos);
return CM_AUTO_PTR<cmFunctionBlocker>(b); return std::unique_ptr<cmFunctionBlocker>(b);
} }
} }
return CM_AUTO_PTR<cmFunctionBlocker>(); return std::unique_ptr<cmFunctionBlocker>();
} }
const char* cmMakefile::GetHomeDirectory() const const char* cmMakefile::GetHomeDirectory() const
@ -3747,7 +3748,7 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
bool global) bool global)
{ {
// Create the target. // Create the target.
CM_AUTO_PTR<cmTarget> target( std::unique_ptr<cmTarget> target(
new cmTarget(name, type, global ? cmTarget::VisibilityImportedGlobally new cmTarget(name, type, global ? cmTarget::VisibilityImportedGlobally
: cmTarget::VisibilityImported, : cmTarget::VisibilityImported,
this)); this));

View File

@ -8,6 +8,7 @@
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <deque> #include <deque>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <stack> #include <stack>
#include <stddef.h> #include <stddef.h>
@ -23,7 +24,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
@ -93,7 +93,7 @@ public:
* Remove the function blocker whose scope ends with the given command. * Remove the function blocker whose scope ends with the given command.
* This returns ownership of the function blocker object. * This returns ownership of the function blocker object.
*/ */
CM_AUTO_PTR<cmFunctionBlocker> RemoveFunctionBlocker( std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker(
cmFunctionBlocker* fb, const cmListFileFunction& lff); cmFunctionBlocker* fb, const cmListFileFunction& lff);
/** /**
@ -782,10 +782,11 @@ public:
void EnforceDirectoryLevelRules() const; void EnforceDirectoryLevelRules() const;
void AddEvaluationFile(const std::string& inputFile, void AddEvaluationFile(
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName, const std::string& inputFile,
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, std::unique_ptr<cmCompiledGeneratorExpression> outputName,
bool inputIsContent); std::unique_ptr<cmCompiledGeneratorExpression> condition,
bool inputIsContent);
std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const; std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const;
std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators() std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators()

View File

@ -3,6 +3,7 @@
#include "cmMakefileExecutableTargetGenerator.h" #include "cmMakefileExecutableTargetGenerator.h"
#include <algorithm> #include <algorithm>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@ -23,7 +24,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
@ -193,7 +193,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Set path conversion for link script shells. // Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript); this->LocalGenerator->SetLinkScriptShell(useLinkScript);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmLinkLineDeviceComputer( new cmLinkLineDeviceComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -251,7 +251,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander()); this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands. // Expand placeholders in the commands.
@ -448,7 +448,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
{ {
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer( this->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -538,7 +538,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Set path conversion for link script shells. // Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript); this->LocalGenerator->SetLinkScriptShell(useLinkScript);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer( this->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -632,7 +632,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander()); this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands. // Expand placeholders in the commands.

View File

@ -3,6 +3,7 @@
#include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileLibraryTargetGenerator.h"
#include <algorithm> #include <algorithm>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <vector> #include <vector>
@ -22,7 +23,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
@ -199,7 +199,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags( this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer( this->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -248,7 +248,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags( this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer( this->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -348,7 +348,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
std::string linkLibs; std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmLinkLineDeviceComputer( new cmLinkLineDeviceComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander()); this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders. // Construct the main link rule and expand placeholders.
@ -754,7 +754,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string linkLibs; std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer( this->CreateLinkLineComputer(
this->LocalGenerator, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory())); this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@ -873,7 +873,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander()); this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders. // Construct the main link rule and expand placeholders.
rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport); rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport);

View File

@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileTargetGenerator.h" #include "cmMakefileTargetGenerator.h"
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <utility> #include <utility>
@ -27,7 +28,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
@ -134,7 +134,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
if (const char* additional_clean_files = if (const char* additional_clean_files =
this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(additional_clean_files); ge.Parse(additional_clean_files);
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
@ -434,7 +434,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Add flags from source file properties. // Add flags from source file properties.
if (const char* cflags = source.GetProperty("COMPILE_FLAGS")) { if (const char* cflags = source.GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config, const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
false, this->GeneratorTarget); false, this->GeneratorTarget);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags); this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
@ -570,7 +570,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
bool const lang_has_assembly = lang_has_preprocessor; bool const lang_has_assembly = lang_has_preprocessor;
bool const lang_can_export_cmds = lang_has_preprocessor; bool const lang_can_export_cmds = lang_has_preprocessor;
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander()); this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the compile rules. // Construct the compile rules.

View File

@ -6,6 +6,7 @@
#include <assert.h> #include <assert.h>
#include <iterator> #include <iterator>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <set> #include <set>
#include <sstream> #include <sstream>
@ -29,7 +30,6 @@
#include "cmStateSnapshot.h" #include "cmStateSnapshot.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
class cmCustomCommand; class cmCustomCommand;
@ -241,7 +241,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander()); this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable. // Rule for linking library/executable.
@ -365,7 +365,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
launcher += " "; launcher += " ";
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander()); this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable. // Rule for linking library/executable.
@ -636,7 +636,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
vars["TARGET_FILE"] = vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL); localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmNinjaLinkLineDeviceComputer( new cmNinjaLinkLineDeviceComputer(
this->GetLocalGenerator(), this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory(), this->GetLocalGenerator()->GetStateSnapshot().GetDirectory(),
@ -839,7 +839,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["TARGET_FILE"] = vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL); localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->GetGlobalGenerator()->CreateLinkLineComputer( this->GetGlobalGenerator()->CreateLinkLineComputer(
this->GetLocalGenerator(), this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory())); this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));

View File

@ -8,6 +8,7 @@
#include <assert.h> #include <assert.h>
#include <iterator> #include <iterator>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
@ -29,7 +30,6 @@
#include "cmState.h" #include "cmState.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target) cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
@ -138,7 +138,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
if (const char* cflags = source->GetProperty("COMPILE_FLAGS")) { if (const char* cflags = source->GetProperty("COMPILE_FLAGS")) {
std::string config = this->LocalGenerator->GetConfigName(); std::string config = this->LocalGenerator->GetConfigName();
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config, const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
false, this->GeneratorTarget); false, this->GeneratorTarget);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags); this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
@ -463,7 +463,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.Flags = flags.c_str(); vars.Flags = flags.c_str();
vars.DependencyFile = depfile.c_str(); vars.DependencyFile = depfile.c_str();
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander()); this->GetLocalGenerator()->CreateRulePlaceholderExpander());
std::string const tdi = this->GetLocalGenerator()->ConvertToOutputFormat( std::string const tdi = this->GetLocalGenerator()->ConvertToOutputFormat(
@ -1077,7 +1077,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
cmSystemTools::ExpandListArgument(compileCmd, compileCmds); cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
} }
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander( std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander()); this->GetLocalGenerator()->CreateRulePlaceholderExpander());
for (std::string& i : compileCmds) { for (std::string& i : compileCmds) {

View File

@ -4,6 +4,7 @@
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <ctype.h> #include <ctype.h>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -15,7 +16,6 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTimestamp.h" #include "cmTimestamp.h"
#include "cmUuid.h" #include "cmUuid.h"
#include "cm_auto_ptr.hxx"
class cmExecutionStatus; class cmExecutionStatus;
@ -108,8 +108,8 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
return false; return false;
} }
CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str())); std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
if (hash.get()) { if (hash) {
std::string out = hash->HashString(args[2]); std::string out = hash->HashString(args[2]);
this->Makefile->AddDefinition(args[1], out.c_str()); this->Makefile->AddDefinition(args[1], out.c_str());
return true; return true;

View File

@ -15,7 +15,7 @@
#include "cmVisualStudioGeneratorOptions.h" #include "cmVisualStudioGeneratorOptions.h"
#include "windows.h" #include "windows.h"
#include "cm_auto_ptr.hxx" #include <memory> // IWYU pragma: keep
static std::string cmVS10EscapeXML(std::string arg) static std::string cmVS10EscapeXML(std::string arg)
{ {
@ -1722,7 +1722,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
if (!deployContent.empty()) { if (!deployContent.empty()) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent); std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis // Deployment location cannot be set on a configuration basis
if (!deployLocation.empty()) { if (!deployLocation.empty()) {
this->WriteString("<Link>", 3); this->WriteString("<Link>", 3);
@ -2089,7 +2090,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} }
if (configDependentFlags) { if (configDependentFlags) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(flags); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
std::string evaluatedFlags = std::string evaluatedFlags =
cge->Evaluate(this->LocalGenerator, *config); cge->Evaluate(this->LocalGenerator, *config);
clOptions.Parse(evaluatedFlags.c_str()); clOptions.Parse(evaluatedFlags.c_str());
@ -2297,16 +2298,16 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions; std::unique_ptr<Options> pOptions;
switch (this->ProjectType) { switch (this->ProjectType) {
case vcxproj: case vcxproj:
pOptions = CM_AUTO_PTR<Options>(new Options( pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::Compiler, gg->GetClFlagTable())); this->LocalGenerator, Options::Compiler, gg->GetClFlagTable());
break; break;
case csproj: case csproj:
pOptions = CM_AUTO_PTR<Options>(new Options(this->LocalGenerator, pOptions =
Options::CSharpCompiler, cm::make_unique<Options>(this->LocalGenerator, Options::CSharpCompiler,
gg->GetCSharpFlagTable())); gg->GetCSharpFlagTable());
break; break;
} }
Options& clOptions = *pOptions; Options& clOptions = *pOptions;
@ -2520,8 +2521,8 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable())); this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable());
Options& rcOptions = *pOptions; Options& rcOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName); std::string CONFIG = cmSystemTools::UpperCase(configName);
@ -2581,8 +2582,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable())); this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaOptions = *pOptions; Options& cudaOptions = *pOptions;
// Get compile flags for CUDA in this directory. // Get compile flags for CUDA in this directory.
@ -2689,8 +2690,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable())); this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaLinkOptions = *pOptions; Options& cudaLinkOptions = *pOptions;
// Determine if we need to do a device link // Determine if we need to do a device link
@ -2760,8 +2761,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable())); this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable());
Options& masmOptions = *pOptions; Options& masmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName); std::string CONFIG = cmSystemTools::UpperCase(configName);
@ -2818,8 +2819,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions = cm::make_unique<Options>(
this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable())); this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable());
Options& nasmOptions = *pOptions; Options& nasmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName); std::string CONFIG = cmSystemTools::UpperCase(configName);
@ -2980,7 +2981,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
if (const char* nativeLibDirectoriesExpression = if (const char* nativeLibDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) { this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(nativeLibDirectoriesExpression); ge.Parse(nativeLibDirectoriesExpression);
std::string nativeLibDirs = std::string nativeLibDirs =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
@ -2993,7 +2994,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
this->GeneratorTarget->GetProperty( this->GeneratorTarget->GetProperty(
"ANDROID_NATIVE_LIB_DEPENDENCIES")) { "ANDROID_NATIVE_LIB_DEPENDENCIES")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(nativeLibDependenciesExpression); ge.Parse(nativeLibDependenciesExpression);
std::string nativeLibDeps = std::string nativeLibDeps =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
@ -3012,7 +3013,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
if (const char* jarDirectoriesExpression = if (const char* jarDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) { this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(jarDirectoriesExpression); ge.Parse(jarDirectoriesExpression);
std::string jarDirectories = std::string jarDirectories =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
@ -3074,8 +3075,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
{ {
cmGlobalVisualStudio10Generator* gg = cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options( auto pOptions =
this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), 0, this)); cm::make_unique<Options>(this->LocalGenerator, Options::Linker,
gg->GetLinkFlagTable(), nullptr, this);
Options& linkOptions = *pOptions; Options& linkOptions = *pOptions;
cmGeneratorTarget::LinkClosure const* linkClosure = cmGeneratorTarget::LinkClosure const* linkClosure =

View File

@ -7,9 +7,10 @@
#include "cmExpandedCommandArgument.h" #include "cmExpandedCommandArgument.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#include <memory> // IWYU pragma: keep
cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf) cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
: Makefile(mf) : Makefile(mf)
, Depth(0) , Depth(0)
@ -34,7 +35,8 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endwhile for this while loop then execute // if this is the endwhile for this while loop then execute
if (!this->Depth) { if (!this->Depth) {
// Remove the function blocker for this scope or bail. // Remove the function blocker for this scope or bail.
CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) { if (!fb.get()) {
return false; return false;
} }

View File

@ -1,220 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef CM_AUTO_PTR_HXX
#define CM_AUTO_PTR_HXX
#include "cmConfigure.h"
#ifdef CMake_HAVE_CXX_AUTO_PTR
#include <memory>
#define CM_AUTO_PTR std::auto_ptr
#else
#define CM_AUTO_PTR cm::auto_ptr
// The HP compiler cannot handle the conversions necessary to use
// auto_ptr_ref to pass an auto_ptr returned from one function
// directly to another function as in use_auto_ptr(get_auto_ptr()).
// We instead use const_cast to achieve the syntax on those platforms.
// We do not use const_cast on other platforms to maintain the C++
// standard design and guarantee that if an auto_ptr is bound
// to a reference-to-const then ownership will be maintained.
#if defined(__HP_aCC)
#define cm_AUTO_PTR_REF 0
#define cm_AUTO_PTR_CONST const
#define cm_AUTO_PTR_CAST(a) cast(a)
#else
#define cm_AUTO_PTR_REF 1
#define cm_AUTO_PTR_CONST
#define cm_AUTO_PTR_CAST(a) a
#endif
// In C++11, clang will warn about using dynamic exception specifications
// as they are deprecated. But as this class is trying to faithfully
// mimic std::auto_ptr, we want to keep the 'throw()' decorations below.
// So we suppress the warning.
#if defined(__clang__) && defined(__has_warning)
#if __has_warning("-Wdeprecated")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
#endif
namespace cm {
template <class X>
class auto_ptr;
#if cm_AUTO_PTR_REF
namespace detail {
// The auto_ptr_ref template is supposed to be a private member of
// auto_ptr but Borland 5.8 cannot handle it. Instead put it in
// a private namespace.
template <class Y>
struct auto_ptr_ref
{
Y* p_;
// The extra constructor argument prevents implicit conversion to
// auto_ptr_ref from auto_ptr through the constructor. Normally
// this should be done with the explicit keyword but Borland 5.x
// generates code in the conversion operator to call itself
// infinately.
auto_ptr_ref(Y* p, int)
: p_(p)
{
}
};
}
#endif
/** C++98 Standard Section 20.4.5 - Template class auto_ptr. */
template <class X>
class auto_ptr
{
#if !cm_AUTO_PTR_REF
template <typename Y>
static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
{
return const_cast<auto_ptr<Y>&>(a);
}
#endif
/** The pointer to the object held. */
X* x_;
public:
/** The type of object held by the auto_ptr. */
typedef X element_type;
/** Construct from an auto_ptr holding a compatible object. This
transfers ownership to the newly constructed auto_ptr. */
template <class Y>
auto_ptr(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw()
: x_(cm_AUTO_PTR_CAST(a).release())
{
}
/** Assign from an auto_ptr holding a compatible object. This
transfers ownership to the left-hand-side of the assignment. */
template <class Y>
auto_ptr& operator=(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw() // NOLINT
{
this->reset(cm_AUTO_PTR_CAST(a).release());
return *this; // NOLINT
}
/**
* Explicitly construct from a raw pointer. This is typically
* called with the result of operator new. For example:
*
* auto_ptr<X> ptr(new X());
*/
explicit auto_ptr(X* p = nullptr) throw()
: x_(p)
{
}
/** Construct from another auto_ptr holding an object of the same
type. This transfers ownership to the newly constructed
auto_ptr. */
auto_ptr(auto_ptr cm_AUTO_PTR_CONST& a) throw()
: x_(cm_AUTO_PTR_CAST(a).release())
{
}
/** Assign from another auto_ptr holding an object of the same type.
This transfers ownership to the newly constructed auto_ptr. */
auto_ptr& operator=(auto_ptr cm_AUTO_PTR_CONST& a) throw() // NOLINT
{
this->reset(cm_AUTO_PTR_CAST(a).release());
return *this; // NOLINT
}
/** Destruct and delete the object held. */
~auto_ptr() throw()
{
// Assume object destructor is nothrow.
delete this->x_;
}
/** Dereference and return a reference to the object held. */
X& operator*() const throw() { return *this->x_; }
/** Return a pointer to the object held. */
X* operator->() const throw() { return this->x_; }
/** Return a pointer to the object held. */
X* get() const throw() { return this->x_; }
/** Return a pointer to the object held and reset to hold no object.
This transfers ownership to the caller. */
X* release() throw()
{
X* x = this->x_;
this->x_ = nullptr;
return x;
}
/** Assume ownership of the given object. The object previously
held is deleted. */
void reset(X* p = 0) throw()
{
if (this->x_ != p) {
// Assume object destructor is nothrow.
delete this->x_;
this->x_ = p;
}
}
/** Convert to an auto_ptr holding an object of a compatible type.
This transfers ownership to the returned auto_ptr. */
template <class Y>
operator auto_ptr<Y>() throw()
{
return auto_ptr<Y>(this->release());
}
#if cm_AUTO_PTR_REF
/** Construct from an auto_ptr_ref. This is used when the
constructor argument is a call to a function returning an
auto_ptr. */
auto_ptr(detail::auto_ptr_ref<X> r) throw()
: x_(r.p_)
{
}
/** Assign from an auto_ptr_ref. This is used when a function
returning an auto_ptr is passed on the right-hand-side of an
assignment. */
auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
{
this->reset(r.p_);
return *this; // NOLINT
}
/** Convert to an auto_ptr_ref. This is used when a function
returning an auto_ptr is the argument to the constructor of
another auto_ptr. */
template <class Y>
operator detail::auto_ptr_ref<Y>() throw()
{
return detail::auto_ptr_ref<Y>(this->release(), 1);
}
#endif
};
} // namespace cm
// Undo warning suppression.
#if defined(__clang__) && defined(__has_warning)
#if __has_warning("-Wdeprecated")
#pragma clang diagnostic pop
#endif
#endif
#endif
#endif

View File

@ -24,7 +24,6 @@
#include "cmUtils.hxx" #include "cmUtils.hxx"
#include "cmVersionConfig.h" #include "cmVersionConfig.h"
#include "cmWorkingDirectory.h" #include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h" #include "cm_sys_stat.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
@ -111,6 +110,7 @@
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -482,15 +482,15 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
snapshot.GetDirectory().SetCurrentSource( snapshot.GetDirectory().SetCurrentSource(
cmSystemTools::GetCurrentWorkingDirectory()); cmSystemTools::GetCurrentWorkingDirectory());
snapshot.SetDefaultDefinitions(); snapshot.SetDefaultDefinitions();
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(gg, snapshot)); cmMakefile mf(gg, snapshot);
if (this->GetWorkingMode() != NORMAL_MODE) { if (this->GetWorkingMode() != NORMAL_MODE) {
std::string file(cmSystemTools::CollapseFullPath(path)); std::string file(cmSystemTools::CollapseFullPath(path));
cmSystemTools::ConvertToUnixSlashes(file); cmSystemTools::ConvertToUnixSlashes(file);
mf->SetScriptModeFile(file.c_str()); mf.SetScriptModeFile(file.c_str());
mf->SetArgcArgv(args); mf.SetArgcArgv(args);
} }
if (!mf->ReadListFile(path)) { if (!mf.ReadListFile(path)) {
cmSystemTools::Error("Error processing file: ", path); cmSystemTools::Error("Error processing file: ", path);
} }
this->SetHomeDirectory(homeDir); this->SetHomeDirectory(homeDir);
@ -1874,8 +1874,8 @@ int cmake::CheckBuildSystem()
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
if (!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || if (!mf.ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag()) { cmSystemTools::GetErrorOccuredFlag()) {
if (verbose) { if (verbose) {
std::ostringstream msg; std::ostringstream msg;
@ -1889,25 +1889,25 @@ int cmake::CheckBuildSystem()
if (this->ClearBuildSystem) { if (this->ClearBuildSystem) {
// Get the generator used for this build system. // Get the generator used for this build system.
const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR"); const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR");
if (!genName || genName[0] == '\0') { if (!genName || genName[0] == '\0') {
genName = "Unix Makefiles"; genName = "Unix Makefiles";
} }
// Create the generator and use it to clear the dependencies. // Create the generator and use it to clear the dependencies.
CM_AUTO_PTR<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName)); std::unique_ptr<cmGlobalGenerator> ggd(
if (ggd.get()) { this->CreateGlobalGenerator(genName));
if (ggd) {
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
CM_AUTO_PTR<cmMakefile> mfd( cmMakefile mfd(ggd.get(), cm.GetCurrentSnapshot());
new cmMakefile(ggd.get(), cm.GetCurrentSnapshot())); std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mfd));
CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mfd.get())); lgd->ClearDependencies(&mfd, verbose);
lgd->ClearDependencies(mfd.get(), verbose);
} }
} }
// If any byproduct of makefile generation is missing we must re-run. // If any byproduct of makefile generation is missing we must re-run.
std::vector<std::string> products; std::vector<std::string> products;
if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) { if (const char* productStr = mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
cmSystemTools::ExpandListArgument(productStr, products); cmSystemTools::ExpandListArgument(productStr, products);
} }
for (std::string const& p : products) { for (std::string const& p : products) {
@ -1925,8 +1925,8 @@ int cmake::CheckBuildSystem()
// Get the set of dependencies and outputs. // Get the set of dependencies and outputs.
std::vector<std::string> depends; std::vector<std::string> depends;
std::vector<std::string> outputs; std::vector<std::string> outputs;
const char* dependsStr = mf->GetDefinition("CMAKE_MAKEFILE_DEPENDS"); const char* dependsStr = mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS");
const char* outputsStr = mf->GetDefinition("CMAKE_MAKEFILE_OUTPUTS"); const char* outputsStr = mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
if (dependsStr && outputsStr) { if (dependsStr && outputsStr) {
cmSystemTools::ExpandListArgument(dependsStr, depends); cmSystemTools::ExpandListArgument(dependsStr, depends);
cmSystemTools::ExpandListArgument(outputsStr, outputs); cmSystemTools::ExpandListArgument(outputsStr, outputs);
@ -2039,19 +2039,18 @@ void cmake::MarkCliAsUsed(const std::string& variable)
void cmake::GenerateGraphViz(const char* fileName) const void cmake::GenerateGraphViz(const char* fileName) const
{ {
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
CM_AUTO_PTR<cmGraphVizWriter> gvWriter( cmGraphVizWriter gvWriter(this->GetGlobalGenerator()->GetLocalGenerators());
new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
std::string settingsFile = this->GetHomeOutputDirectory(); std::string settingsFile = this->GetHomeOutputDirectory();
settingsFile += "/CMakeGraphVizOptions.cmake"; settingsFile += "/CMakeGraphVizOptions.cmake";
std::string fallbackSettingsFile = this->GetHomeDirectory(); std::string fallbackSettingsFile = this->GetHomeDirectory();
fallbackSettingsFile += "/CMakeGraphVizOptions.cmake"; fallbackSettingsFile += "/CMakeGraphVizOptions.cmake";
gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str()); gvWriter.ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str());
gvWriter->WritePerTargetFiles(fileName); gvWriter.WritePerTargetFiles(fileName);
gvWriter->WriteTargetDependersFiles(fileName); gvWriter.WriteTargetDependersFiles(fileName);
gvWriter->WriteGlobalFile(fileName); gvWriter.WriteGlobalFile(fileName);
#endif #endif
} }
@ -2357,7 +2356,7 @@ int cmake::Build(const std::string& dir, const std::string& target,
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n"; std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
return 1; return 1;
} }
CM_AUTO_PTR<cmGlobalGenerator> gen( std::unique_ptr<cmGlobalGenerator> gen(
this->CreateGlobalGenerator(cachedGenerator)); this->CreateGlobalGenerator(cachedGenerator));
if (!gen.get()) { if (!gen.get()) {
std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator

View File

@ -12,7 +12,6 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmUtils.hxx" #include "cmUtils.hxx"
#include "cmVersion.h" #include "cmVersion.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h" #include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
@ -37,6 +36,7 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <memory> // IWYU pragma: keep
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -928,8 +928,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmStateSnapshot snapshot = cm.GetCurrentSnapshot(); cmStateSnapshot snapshot = cm.GetCurrentSnapshot();
snapshot.GetDirectory().SetCurrentBinary(startOutDir); snapshot.GetDirectory().SetCurrentBinary(startOutDir);
snapshot.GetDirectory().SetCurrentSource(startDir); snapshot.GetDirectory().SetCurrentSource(startDir);
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(ggd, snapshot)); cmMakefile mf(ggd, snapshot);
CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mf.get())); std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf));
// Actually scan dependencies. // Actually scan dependencies.
return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0 return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0

View File

@ -49,12 +49,6 @@
#{ symbol: [ "std::pair", private, "<map>", public ] }, #{ symbol: [ "std::pair", private, "<map>", public ] },
#{ symbol: [ "std::pair", private, "<set>", public ] }, #{ symbol: [ "std::pair", private, "<set>", public ] },
# IWYU wrongly suggests to include "cm_auto_ptr.hxx" in some places. This
# might be a misinterpretation of a template specialization in <utility>.
# As a workaround, map the symbol auto_ptr to "cmConfigure.h".
# This will still correctly require "cm_auto_ptr.hxx" for CM_AUTO_PTR.
{ symbol: [ "cm::auto_ptr", private, "\"cmConfigure.h\"", public ] },
# __decay_and_strip is used internally in the C++11 standard library. # __decay_and_strip is used internally in the C++11 standard library.
# IWYU does not classify it as internal and suggests to add <type_traits>. # IWYU does not classify it as internal and suggests to add <type_traits>.
# To ignore it, we simply map it to a file that is included anyway. # To ignore it, we simply map it to a file that is included anyway.