From 36b939db682a9405790bee76f95673eeaeb445b8 Mon Sep 17 00:00:00 2001 From: Regina Pfeifer Date: Thu, 12 Sep 2019 10:10:28 +0200 Subject: cmFLTKWrapUICommand: Port away from cmCommand Ref: #19499 --- Source/cmCommands.cxx | 3 +-- Source/cmFLTKWrapUICommand.cxx | 39 +++++++++++++++++++-------------------- Source/cmFLTKWrapUICommand.h | 30 ++---------------------------- 3 files changed, 22 insertions(+), 50 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f30fcb5..9ce4c14 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -282,8 +282,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("aux_source_directory", cmAuxSourceDirectoryCommand); state->AddBuiltinCommand("export", cm::make_unique()); - state->AddBuiltinCommand("fltk_wrap_ui", - cm::make_unique()); + state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); state->AddBuiltinCommand( "include_external_msproject", cm::make_unique()); diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index ea9e672..5094c3c 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -5,13 +5,13 @@ #include #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; class cmTarget; static void FinalAction(cmMakefile& makefile, std::string const& name) @@ -30,39 +30,40 @@ static void FinalAction(cmMakefile& makefile, std::string const& name) } } -// cmFLTKWrapUICommand -bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmFLTKWrapUICommand(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(); + // what is the current source dir - std::string cdir = this->Makefile->GetCurrentSourceDirectory(); + std::string cdir = mf.GetCurrentSourceDirectory(); std::string const& fluid_exe = - this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); + mf.GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); // Target that will use the generated files std::string const& target = args[0]; // get the list of GUI files from which .cxx and .h will be generated - std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory(); + std::string outputDirectory = mf.GetCurrentBinaryDirectory(); { // Some of the generated files are *.h so the directory "GUI" // where they are created have to be added to the include path std::vector outputDirectories; outputDirectories.push_back(outputDirectory); - this->Makefile->AddIncludeDirectories(outputDirectories); + mf.AddIncludeDirectories(outputDirectories); } // List of produced files. std::vector generatedSourcesClasses; for (std::string const& arg : cmMakeRange(args).advance(1)) { - cmSourceFile* curr = this->Makefile->GetSource(arg); + cmSourceFile* curr = mf.GetSource(arg); // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) { @@ -91,14 +92,12 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, std::string no_main_dependency; const char* no_comment = nullptr; const char* no_working_dir = nullptr; - this->Makefile->AddCustomCommandToOutput( - cxxres, depends, no_main_dependency, commandLines, no_comment, - no_working_dir); - this->Makefile->AddCustomCommandToOutput( - hname, depends, no_main_dependency, commandLines, no_comment, - no_working_dir); - - cmSourceFile* sf = this->Makefile->GetSource(cxxres); + mf.AddCustomCommandToOutput(cxxres, depends, no_main_dependency, + commandLines, no_comment, no_working_dir); + mf.AddCustomCommandToOutput(hname, depends, no_main_dependency, + commandLines, no_comment, no_working_dir); + + cmSourceFile* sf = mf.GetSource(cxxres); sf->AddDepend(hname); sf->AddDepend(origname); generatedSourcesClasses.push_back(sf); @@ -116,9 +115,9 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, } std::string const varName = target + "_FLTK_UI_SRCS"; - this->Makefile->AddDefinition(varName, sourceListValue); + mf.AddDefinition(varName, sourceListValue); - this->Makefile->AddFinalAction( + mf.AddFinalAction( [target](cmMakefile& makefile) { FinalAction(makefile, target); }); return true; } diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index ea8d401..bb56dbd 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmFLTKWrapUICommand - * \brief Create .h and .cxx files rules for FLTK user interfaces files - * - * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into - * normal C++ - */ -class cmFLTKWrapUICommand : 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 cmFLTKWrapUICommand(std::vector const& args, + cmExecutionStatus& status); #endif -- cgit v0.12