mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-20 22:20:50 -06:00
cmFLTKWrapUICommand: Port away from FinalPass
This commit is contained in:
committed by
Regina Pfeifer
parent
20169f0b8d
commit
6a1a3763ee
@@ -13,6 +13,23 @@
|
|||||||
class cmExecutionStatus;
|
class cmExecutionStatus;
|
||||||
class cmTarget;
|
class cmTarget;
|
||||||
|
|
||||||
|
static void FinalAction(cmMakefile& makefile, std::string const& name)
|
||||||
|
{
|
||||||
|
// people should add the srcs to the target themselves, but the old command
|
||||||
|
// didn't support that, so check and see if they added the files in and if
|
||||||
|
// they didn;t then print a warning and add then anyhow
|
||||||
|
cmTarget* target = makefile.FindLocalNonAliasTarget(name);
|
||||||
|
if (!target) {
|
||||||
|
std::string msg =
|
||||||
|
"FLTK_WRAP_UI was called with a target that was never created: ";
|
||||||
|
msg += name;
|
||||||
|
msg += ". The problem was found while processing the source directory: ";
|
||||||
|
msg += makefile.GetCurrentSourceDirectory();
|
||||||
|
msg += ". This FLTK_WRAP_UI call will be ignored.";
|
||||||
|
cmSystemTools::Message(msg, "Warning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// cmFLTKWrapUICommand
|
// cmFLTKWrapUICommand
|
||||||
bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
||||||
cmExecutionStatus&)
|
cmExecutionStatus&)
|
||||||
@@ -27,8 +44,8 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
std::string const& fluid_exe =
|
std::string const& fluid_exe =
|
||||||
this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
|
this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
|
||||||
|
|
||||||
// get parameter for the command
|
// Target that will use the generated files
|
||||||
this->Target = args[0]; // 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
|
// get the list of GUI files from which .cxx and .h will be generated
|
||||||
std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
|
std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
|
||||||
@@ -41,6 +58,9 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
this->Makefile->AddIncludeDirectories(outputDirectories);
|
this->Makefile->AddIncludeDirectories(outputDirectories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List of produced files.
|
||||||
|
std::vector<cmSourceFile*> generatedSourcesClasses;
|
||||||
|
|
||||||
for (std::string const& arg : cmMakeRange(args).advance(1)) {
|
for (std::string const& arg : cmMakeRange(args).advance(1)) {
|
||||||
cmSourceFile* curr = this->Makefile->GetSource(arg);
|
cmSourceFile* curr = this->Makefile->GetSource(arg);
|
||||||
// if we should use the source GUI
|
// if we should use the source GUI
|
||||||
@@ -84,40 +104,23 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
cmSourceFile* sf = this->Makefile->GetSource(cxxres);
|
cmSourceFile* sf = this->Makefile->GetSource(cxxres);
|
||||||
sf->AddDepend(hname);
|
sf->AddDepend(hname);
|
||||||
sf->AddDepend(origname);
|
sf->AddDepend(origname);
|
||||||
this->GeneratedSourcesClasses.push_back(sf);
|
generatedSourcesClasses.push_back(sf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the variable with the list of sources in it
|
// create the variable with the list of sources in it
|
||||||
size_t lastHeadersClass = this->GeneratedSourcesClasses.size();
|
size_t lastHeadersClass = generatedSourcesClasses.size();
|
||||||
std::string sourceListValue;
|
std::string sourceListValue;
|
||||||
for (size_t classNum = 0; classNum < lastHeadersClass; classNum++) {
|
for (size_t classNum = 0; classNum < lastHeadersClass; classNum++) {
|
||||||
if (classNum) {
|
if (classNum) {
|
||||||
sourceListValue += ";";
|
sourceListValue += ";";
|
||||||
}
|
}
|
||||||
sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath();
|
sourceListValue += generatedSourcesClasses[classNum]->GetFullPath();
|
||||||
}
|
}
|
||||||
std::string varName = this->Target;
|
std::string const varName = target + "_FLTK_UI_SRCS";
|
||||||
varName += "_FLTK_UI_SRCS";
|
|
||||||
this->Makefile->AddDefinition(varName, sourceListValue.c_str());
|
this->Makefile->AddDefinition(varName, sourceListValue.c_str());
|
||||||
|
|
||||||
|
this->Makefile->AddFinalAction(
|
||||||
|
[target](cmMakefile& makefile) { FinalAction(makefile, target); });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmFLTKWrapUICommand::FinalPass()
|
|
||||||
{
|
|
||||||
// people should add the srcs to the target themselves, but the old command
|
|
||||||
// didn't support that, so check and see if they added the files in and if
|
|
||||||
// they didn;t then print a warning and add then anyhow
|
|
||||||
cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
|
|
||||||
if (!target) {
|
|
||||||
std::string msg =
|
|
||||||
"FLTK_WRAP_UI was called with a target that was never created: ";
|
|
||||||
msg += this->Target;
|
|
||||||
msg += ". The problem was found while processing the source directory: ";
|
|
||||||
msg += this->Makefile->GetCurrentSourceDirectory();
|
|
||||||
msg += ". This FLTK_WRAP_UI call will be ignored.";
|
|
||||||
cmSystemTools::Message(msg, "Warning");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "cmCommand.h"
|
#include "cmCommand.h"
|
||||||
|
|
||||||
class cmExecutionStatus;
|
class cmExecutionStatus;
|
||||||
class cmSourceFile;
|
|
||||||
|
|
||||||
/** \class cmFLTKWrapUICommand
|
/** \class cmFLTKWrapUICommand
|
||||||
* \brief Create .h and .cxx files rules for FLTK user interfaces files
|
* \brief Create .h and .cxx files rules for FLTK user interfaces files
|
||||||
@@ -38,27 +37,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool InitialPass(std::vector<std::string> const& args,
|
bool InitialPass(std::vector<std::string> const& args,
|
||||||
cmExecutionStatus& status) override;
|
cmExecutionStatus& status) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called at the end after all the information
|
|
||||||
* specified by the command is accumulated. Most commands do
|
|
||||||
* not implement this method. At this point, reading and
|
|
||||||
* writing to the cache can be done.
|
|
||||||
*/
|
|
||||||
void FinalPass() override;
|
|
||||||
bool HasFinalPass() const override { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* List of produced files.
|
|
||||||
*/
|
|
||||||
std::vector<cmSourceFile*> GeneratedSourcesClasses;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of Fluid files that provide the source
|
|
||||||
* generating .cxx and .h files
|
|
||||||
*/
|
|
||||||
std::string Target;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user