From fb5affe0859ae1bc07d059fc11cee3daca4d8780 Mon Sep 17 00:00:00 2001 From: Regina Pfeifer Date: Thu, 12 Sep 2019 10:18:01 +0200 Subject: cmInstallFilesCommand: Port away from cmCommand Ref: #19499 --- Source/cmCommands.cxx | 3 +-- Source/cmInstallFilesCommand.cxx | 23 ++++++++++++----------- Source/cmInstallFilesCommand.h | 30 ++---------------------------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 6f01bea..49f7c93 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -236,8 +236,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("include_regular_expression", cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique()); - state->AddBuiltinCommand("install_files", - cm::make_unique()); + state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cm::make_unique()); state->AddBuiltinCommand("link_directories", diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 4eb5f24..d623943 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallFilesCommand.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" @@ -11,8 +12,6 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - static std::string FindInstallSource(cmMakefile& makefile, const char* name); static void CreateInstallGenerator(cmMakefile& makefile, std::string const& dest, @@ -20,16 +19,18 @@ static void CreateInstallGenerator(cmMakefile& makefile, static void FinalAction(cmMakefile& makefile, std::string const& dest, std::vector const& args); -bool cmInstallFilesCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmInstallFilesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Enable the install target. - this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); + mf.GetGlobalGenerator()->EnableInstallTarget(); std::string const& dest = args[0]; @@ -37,18 +38,18 @@ bool cmInstallFilesCommand::InitialPass(std::vector const& args, std::vector files; for (std::string const& arg : cmMakeRange(args).advance(2)) { // Find the source location for each file listed. - files.push_back(FindInstallSource(*this->Makefile, arg.c_str())); + files.push_back(FindInstallSource(mf, arg.c_str())); } - CreateInstallGenerator(*this->Makefile, dest, files); + CreateInstallGenerator(mf, dest, files); } else { std::vector finalArgs(args.begin() + 1, args.end()); - this->Makefile->AddFinalAction([dest, finalArgs](cmMakefile& makefile) { + mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) { FinalAction(makefile, dest, finalArgs); }); } - this->Makefile->GetGlobalGenerator()->AddInstallComponent( - this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); + mf.GetGlobalGenerator()->AddInstallComponent( + mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index f9b84fd..f4ebbde 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmInstallFilesCommand - * \brief Specifies where to install some files - * - * cmInstallFilesCommand specifies the relative path where a list of - * files should be installed. - */ -class cmInstallFilesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallFilesCommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12