summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r--Source/cmInstallCommand.cxx141
1 files changed, 71 insertions, 70 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 0c52cc5..54b85cd 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -85,7 +85,7 @@ public:
std::string DefaultComponentName;
};
-cmInstallTargetGenerator* CreateInstallTargetGenerator(
+std::unique_ptr<cmInstallTargetGenerator> CreateInstallTargetGenerator(
cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
cmListFileBacktrace const& backtrace, const std::string& destination,
bool forceOpt = false, bool namelink = false)
@@ -95,16 +95,16 @@ cmInstallTargetGenerator* CreateInstallTargetGenerator(
target.SetHaveInstallRule(true);
const char* component = namelink ? args.GetNamelinkComponent().c_str()
: args.GetComponent().c_str();
- auto g = new cmInstallTargetGenerator(
+ auto g = cm::make_unique<cmInstallTargetGenerator>(
target.GetName(), destination.c_str(), impLib,
args.GetPermissions().c_str(), args.GetConfigurations(), component,
message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
backtrace);
- target.AddInstallGenerator(g);
+ target.AddInstallGenerator(g.get());
return g;
}
-cmInstallTargetGenerator* CreateInstallTargetGenerator(
+std::unique_ptr<cmInstallTargetGenerator> CreateInstallTargetGenerator(
cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
cmListFileBacktrace const& backtrace, bool forceOpt = false,
bool namelink = false)
@@ -114,20 +114,20 @@ cmInstallTargetGenerator* CreateInstallTargetGenerator(
namelink);
}
-cmInstallFilesGenerator* CreateInstallFilesGenerator(
+std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator(
cmMakefile* mf, const std::vector<std::string>& absFiles,
const cmInstallCommandArguments& args, bool programs,
const std::string& destination)
{
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(mf);
- return new cmInstallFilesGenerator(
+ return cm::make_unique<cmInstallFilesGenerator>(
absFiles, destination.c_str(), programs, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(), message,
args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional());
}
-cmInstallFilesGenerator* CreateInstallFilesGenerator(
+std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator(
cmMakefile* mf, const std::vector<std::string>& absFiles,
const cmInstallCommandArguments& args, bool programs)
{
@@ -196,13 +196,15 @@ bool HandleScriptMode(std::vector<std::string> const& args,
status.SetError("given a directory as value of SCRIPT argument.");
return false;
}
- helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
- script.c_str(), false, component.c_str(), exclude_from_all));
+ helper.Makefile->AddInstallGenerator(
+ cm::make_unique<cmInstallScriptGenerator>(
+ script.c_str(), false, component.c_str(), exclude_from_all));
} else if (doing_code) {
doing_code = false;
std::string const& code = arg;
- helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
- code.c_str(), true, component.c_str(), exclude_from_all));
+ helper.Makefile->AddInstallGenerator(
+ cm::make_unique<cmInstallScriptGenerator>(
+ code.c_str(), true, component.c_str(), exclude_from_all));
}
}
@@ -449,16 +451,16 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
for (cmTarget* ti : targets) {
// Handle each target type.
cmTarget& target = *ti;
- cmInstallTargetGenerator* archiveGenerator = nullptr;
- cmInstallTargetGenerator* libraryGenerator = nullptr;
- cmInstallTargetGenerator* namelinkGenerator = nullptr;
- cmInstallTargetGenerator* runtimeGenerator = nullptr;
- cmInstallTargetGenerator* objectGenerator = nullptr;
- cmInstallTargetGenerator* frameworkGenerator = nullptr;
- cmInstallTargetGenerator* bundleGenerator = nullptr;
- cmInstallFilesGenerator* privateHeaderGenerator = nullptr;
- cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
- cmInstallFilesGenerator* resourceGenerator = nullptr;
+ std::unique_ptr<cmInstallTargetGenerator> archiveGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> libraryGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> namelinkGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> runtimeGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> objectGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> frameworkGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> bundleGenerator;
+ std::unique_ptr<cmInstallFilesGenerator> privateHeaderGenerator;
+ std::unique_ptr<cmInstallFilesGenerator> publicHeaderGenerator;
+ std::unique_ptr<cmInstallFilesGenerator> resourceGenerator;
// Track whether this is a namelink-only rule.
bool namelinkOnly = false;
@@ -485,7 +487,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
runtimeGenerator = CreateInstallTargetGenerator(
target, runtimeArgs, false, helper.Makefile->GetBacktrace());
}
- if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
+ if (!archiveGenerator && !runtimeGenerator) {
archiveGenerator = CreateInstallTargetGenerator(
target, archiveArgs, true, helper.Makefile->GetBacktrace(),
helper.GetArchiveDestination(nullptr));
@@ -712,43 +714,18 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
}
}
- // Keep track of whether we're installing anything in each category
- installsArchive = installsArchive || archiveGenerator != nullptr;
- installsLibrary = installsLibrary || libraryGenerator != nullptr;
- installsNamelink = installsNamelink || namelinkGenerator != nullptr;
- installsRuntime = installsRuntime || runtimeGenerator != nullptr;
- installsObject = installsObject || objectGenerator != nullptr;
- installsFramework = installsFramework || frameworkGenerator != nullptr;
- installsBundle = installsBundle || bundleGenerator != nullptr;
- installsPrivateHeader =
- installsPrivateHeader || privateHeaderGenerator != nullptr;
- installsPublicHeader =
- installsPublicHeader || publicHeaderGenerator != nullptr;
- installsResource = installsResource || resourceGenerator;
-
- helper.Makefile->AddInstallGenerator(archiveGenerator);
- helper.Makefile->AddInstallGenerator(libraryGenerator);
- helper.Makefile->AddInstallGenerator(namelinkGenerator);
- helper.Makefile->AddInstallGenerator(runtimeGenerator);
- helper.Makefile->AddInstallGenerator(objectGenerator);
- helper.Makefile->AddInstallGenerator(frameworkGenerator);
- helper.Makefile->AddInstallGenerator(bundleGenerator);
- helper.Makefile->AddInstallGenerator(privateHeaderGenerator);
- helper.Makefile->AddInstallGenerator(publicHeaderGenerator);
- helper.Makefile->AddInstallGenerator(resourceGenerator);
-
// Add this install rule to an export if one was specified and
// this is not a namelink-only rule.
if (!exports.empty() && !namelinkOnly) {
auto te = cm::make_unique<cmTargetExport>();
te->TargetName = target.GetName();
- te->ArchiveGenerator = archiveGenerator;
- te->BundleGenerator = bundleGenerator;
- te->FrameworkGenerator = frameworkGenerator;
- te->HeaderGenerator = publicHeaderGenerator;
- te->LibraryGenerator = libraryGenerator;
- te->RuntimeGenerator = runtimeGenerator;
- te->ObjectsGenerator = objectGenerator;
+ te->ArchiveGenerator = archiveGenerator.get();
+ te->BundleGenerator = bundleGenerator.get();
+ te->FrameworkGenerator = frameworkGenerator.get();
+ te->HeaderGenerator = publicHeaderGenerator.get();
+ te->LibraryGenerator = libraryGenerator.get();
+ te->RuntimeGenerator = runtimeGenerator.get();
+ te->ObjectsGenerator = objectGenerator.get();
te->InterfaceIncludeDirectories =
cmJoin(includesArgs.GetIncludeDirs(), ";");
@@ -756,6 +733,29 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
->GetExportSets()[exports]
.AddTargetExport(std::move(te));
}
+
+ // Keep track of whether we're installing anything in each category
+ installsArchive = installsArchive || archiveGenerator;
+ installsLibrary = installsLibrary || libraryGenerator;
+ installsNamelink = installsNamelink || namelinkGenerator;
+ installsRuntime = installsRuntime || runtimeGenerator;
+ installsObject = installsObject || objectGenerator;
+ installsFramework = installsFramework || frameworkGenerator;
+ installsBundle = installsBundle || bundleGenerator;
+ installsPrivateHeader = installsPrivateHeader || privateHeaderGenerator;
+ installsPublicHeader = installsPublicHeader || publicHeaderGenerator;
+ installsResource = installsResource || resourceGenerator;
+
+ helper.Makefile->AddInstallGenerator(std::move(archiveGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(libraryGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(namelinkGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(runtimeGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(objectGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(frameworkGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(bundleGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(privateHeaderGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(publicHeaderGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(resourceGenerator));
}
// Tell the global generator about any installation component names
@@ -1200,10 +1200,11 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
cmInstallGenerator::SelectMessageLevel(helper.Makefile, message_never);
// Create the directory install generator.
- helper.Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator(
- dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
- configurations, component.c_str(), message, exclude_from_all,
- literal_args.c_str(), optional));
+ helper.Makefile->AddInstallGenerator(
+ cm::make_unique<cmInstallDirectoryGenerator>(
+ dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
+ configurations, component.c_str(), message, exclude_from_all,
+ literal_args.c_str(), optional));
// Tell the global generator about any installation component names
// specified.
@@ -1291,12 +1292,12 @@ bool HandleExportAndroidMKMode(std::vector<std::string> const& args,
cmInstallGenerator::SelectMessageLevel(helper.Makefile);
// Create the export install generator.
- cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
- ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
- true);
- helper.Makefile->AddInstallGenerator(exportGenerator);
+ helper.Makefile->AddInstallGenerator(
+ cm::make_unique<cmInstallExportGenerator>(
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ ica.GetConfigurations(), ica.GetComponent().c_str(), message,
+ ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
+ true));
return true;
#else
@@ -1405,12 +1406,12 @@ bool HandleExportMode(std::vector<std::string> const& args,
cmInstallGenerator::SelectMessageLevel(helper.Makefile);
// Create the export install generator.
- cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
- ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
- false);
- helper.Makefile->AddInstallGenerator(exportGenerator);
+ helper.Makefile->AddInstallGenerator(
+ cm::make_unique<cmInstallExportGenerator>(
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ ica.GetConfigurations(), ica.GetComponent().c_str(), message,
+ ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
+ false));
return true;
}