mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 22:00:10 -05:00
Ninja: In cmNinjaTargetGenerator use std::unique_ptr to manage new instances
This commit is contained in:
@@ -83,14 +83,13 @@ void cmLocalNinjaGenerator::Generate()
|
||||
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
||||
continue;
|
||||
}
|
||||
cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(target);
|
||||
auto tg = cmNinjaTargetGenerator::New(target);
|
||||
if (tg) {
|
||||
tg->Generate();
|
||||
// Add the target to "all" if required.
|
||||
if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) {
|
||||
this->GetGlobalNinjaGenerator()->AddDependencyToAll(target);
|
||||
}
|
||||
delete tg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
|
||||
std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New(
|
||||
cmGeneratorTarget* target)
|
||||
{
|
||||
switch (target->GetType()) {
|
||||
case cmStateEnums::EXECUTABLE:
|
||||
@@ -41,14 +42,14 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
|
||||
case cmStateEnums::STATIC_LIBRARY:
|
||||
case cmStateEnums::MODULE_LIBRARY:
|
||||
case cmStateEnums::OBJECT_LIBRARY:
|
||||
return new cmNinjaNormalTargetGenerator(target);
|
||||
return cm::make_unique<cmNinjaNormalTargetGenerator>(target);
|
||||
|
||||
case cmStateEnums::UTILITY:
|
||||
case cmStateEnums::GLOBAL_TARGET:
|
||||
return new cmNinjaUtilityTargetGenerator(target);
|
||||
return cm::make_unique<cmNinjaUtilityTargetGenerator>(target);
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
return std::unique_ptr<cmNinjaTargetGenerator>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "cmOSXBundleGenerator.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory> // IWYU pragma: keep
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -26,7 +27,8 @@ class cmNinjaTargetGenerator : public cmCommonTargetGenerator
|
||||
{
|
||||
public:
|
||||
/// Create a cmNinjaTargetGenerator according to the @a target's type.
|
||||
static cmNinjaTargetGenerator* New(cmGeneratorTarget* target);
|
||||
static std::unique_ptr<cmNinjaTargetGenerator> New(
|
||||
cmGeneratorTarget* target);
|
||||
|
||||
/// Build a NinjaTargetGenerator.
|
||||
cmNinjaTargetGenerator(cmGeneratorTarget* target);
|
||||
|
||||
Reference in New Issue
Block a user