summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Eiband <daniel.eiband@brainlab.com>2019-10-17 13:40:09 (GMT)
committerDaniel Eiband <daniel.eiband@brainlab.com>2019-11-24 19:13:23 (GMT)
commitbf76a6b801597da424f1fe0f10adc0e8d559adc3 (patch)
treed4d9d2843633944af271b6718f89fc92b2064a07
parentadc50529ac163889c0353756706a7ffddb4ed957 (diff)
downloadCMake-bf76a6b801597da424f1fe0f10adc0e8d559adc3.zip
CMake-bf76a6b801597da424f1fe0f10adc0e8d559adc3.tar.gz
CMake-bf76a6b801597da424f1fe0f10adc0e8d559adc3.tar.bz2
cmMakefile: Delay CheckTargetProperties and FinalPass to generate time
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx9
-rw-r--r--Source/cmFLTKWrapUICommand.cxx16
-rw-r--r--Source/cmGlobalGenerator.cxx35
-rw-r--r--Source/cmInstallFilesCommand.cxx10
-rw-r--r--Source/cmInstallProgramsCommand.cxx10
-rw-r--r--Source/cmLoadCommandCommand.cxx9
-rw-r--r--Source/cmMakefile.cxx17
-rw-r--r--Source/cmMakefile.h25
-rw-r--r--Source/cmVariableWatchCommand.cxx6
9 files changed, 83 insertions, 54 deletions
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 89093e9..dfc8de5 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -12,6 +12,7 @@
#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
@@ -20,6 +21,8 @@
#include "cmTargetLinkLibraryType.h"
#include "cmake.h"
+class cmListFileBacktrace;
+
static void FinalAction(cmMakefile& makefile, std::string const& filename,
bool append)
{
@@ -150,9 +153,9 @@ bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
std::string const& filename = args[0];
bool const append = args.size() > 1 && args[1] == "APPEND";
- status.GetMakefile().AddFinalAction(
- [filename, append](cmMakefile& makefile) {
- FinalAction(makefile, filename, append);
+ status.GetMakefile().AddGeneratorAction(
+ [filename, append](cmLocalGenerator& lg, const cmListFileBacktrace&) {
+ FinalAction(*lg.GetMakefile(), filename, append);
});
return true;
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 11844e4..d88617a 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -6,15 +6,20 @@
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
+#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmake.h"
class cmTarget;
-static void FinalAction(cmMakefile& makefile, std::string const& name)
+static void FinalAction(cmMakefile& makefile, std::string const& name,
+ const cmListFileBacktrace& lfbt)
{
// 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
@@ -26,7 +31,8 @@ static void FinalAction(cmMakefile& makefile, std::string const& name)
". The problem was found while processing the source directory: ",
makefile.GetCurrentSourceDirectory(),
". This FLTK_WRAP_UI call will be ignored.");
- cmSystemTools::Message(msg, "Warning");
+ makefile.GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_ERROR, msg,
+ lfbt);
}
}
@@ -116,7 +122,9 @@ bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
std::string const varName = target + "_FLTK_UI_SRCS";
mf.AddDefinition(varName, sourceListValue);
- mf.AddFinalAction(
- [target](cmMakefile& makefile) { FinalAction(makefile, target); });
+ mf.AddGeneratorAction(
+ [target](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
+ FinalAction(*lg.GetMakefile(), target, lfbt);
+ });
return true;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index e38066f..965ee6d 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -34,6 +34,7 @@
#include "cmGeneratorTarget.h"
#include "cmInstallGenerator.h"
#include "cmLinkLineComputer.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMSVC60LinkLineComputer.h"
#include "cmMakefile.h"
@@ -1262,10 +1263,6 @@ void cmGlobalGenerator::Configure()
"number of local generators",
cmStateEnums::INTERNAL);
- // check for link libraries and include directories containing "NOTFOUND"
- // and for infinite loops
- this->CheckTargetProperties();
-
if (this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) {
std::ostringstream msg;
if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -1288,6 +1285,10 @@ void cmGlobalGenerator::Configure()
void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
{
this->CreateLocalGenerators();
+ // Commit side effects only if we are actually generating
+ if (this->GetConfigureDoneCMP0026()) {
+ this->CheckTargetProperties();
+ }
this->CreateGeneratorTargets(targetTypes);
this->ComputeBuildFileGenerators();
}
@@ -1464,6 +1465,8 @@ void cmGlobalGenerator::Generate()
this->ProcessEvaluationFiles();
+ this->CMakeInstance->UpdateProgress("Generating", 0.1f);
+
// Generate project files
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile());
@@ -1475,8 +1478,9 @@ void cmGlobalGenerator::Generate()
this->LocalGenerators[i]->GenerateTestFiles();
this->CMakeInstance->UpdateProgress(
"Generating",
- (static_cast<float>(i) + 1.0f) /
- static_cast<float>(this->LocalGenerators.size()));
+ 0.1f +
+ 0.9f * (static_cast<float>(i) + 1.0f) /
+ static_cast<float>(this->LocalGenerators.size()));
}
this->SetCurrentMakefile(nullptr);
@@ -1714,12 +1718,12 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(
void cmGlobalGenerator::CheckTargetProperties()
{
+ // check for link libraries and include directories containing "NOTFOUND"
+ // and for infinite loops
std::map<std::string, std::string> notFoundMap;
- // std::set<std::string> notFoundMap;
- // after it is all done do a ConfigureFinalPass
cmState* state = this->GetCMakeInstance()->GetState();
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- this->Makefiles[i]->ConfigureFinalPass();
+ this->Makefiles[i]->Generate(*this->LocalGenerators[i]);
for (auto const& target : this->Makefiles[i]->GetTargets()) {
if (target.second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
@@ -1763,11 +1767,6 @@ void cmGlobalGenerator::CheckTargetProperties()
}
}
}
- this->CMakeInstance->UpdateProgress(
- "Configuring",
- 0.9f +
- 0.1f * (static_cast<float>(i) + 1.0f) /
- static_cast<float>(this->Makefiles.size()));
}
if (!notFoundMap.empty()) {
@@ -2017,10 +2016,10 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
}
int numGen = atoi(numGenC->c_str());
- float prog = 0.9f * static_cast<float>(this->Makefiles.size()) /
- static_cast<float>(numGen);
- if (prog > 0.9f) {
- prog = 0.9f;
+ float prog =
+ static_cast<float>(this->Makefiles.size()) / static_cast<float>(numGen);
+ if (prog > 1.0f) {
+ prog = 1.0f;
}
this->CMakeInstance->UpdateProgress("Configuring", prog);
}
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index d623943..efbcb98 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -7,11 +7,14 @@
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallGenerator.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+class cmListFileBacktrace;
+
static std::string FindInstallSource(cmMakefile& makefile, const char* name);
static void CreateInstallGenerator(cmMakefile& makefile,
std::string const& dest,
@@ -43,9 +46,10 @@ bool cmInstallFilesCommand(std::vector<std::string> const& args,
CreateInstallGenerator(mf, dest, files);
} else {
std::vector<std::string> finalArgs(args.begin() + 1, args.end());
- mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
- FinalAction(makefile, dest, finalArgs);
- });
+ mf.AddGeneratorAction(
+ [dest, finalArgs](cmLocalGenerator& lg, const cmListFileBacktrace&) {
+ FinalAction(*lg.GetMakefile(), dest, finalArgs);
+ });
}
mf.GetGlobalGenerator()->AddInstallComponent(
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 6bb4409..2088eae 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -7,10 +7,13 @@
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallGenerator.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+class cmListFileBacktrace;
+
static void FinalAction(cmMakefile& makefile, std::string const& dest,
std::vector<std::string> const& args);
static std::string FindInstallSource(cmMakefile& makefile, const char* name);
@@ -33,9 +36,10 @@ bool cmInstallProgramsCommand(std::vector<std::string> const& args,
std::string const& dest = args[0];
std::vector<std::string> const finalArgs(args.begin() + 1, args.end());
- mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
- FinalAction(makefile, dest, finalArgs);
- });
+ mf.AddGeneratorAction(
+ [dest, finalArgs](cmLocalGenerator& lg, const cmListFileBacktrace&) {
+ FinalAction(*lg.GetMakefile(), dest, finalArgs);
+ });
return true;
}
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 23ace64..92258e2 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -14,6 +14,7 @@
#include "cmCommand.h"
#include "cmDynamicLoader.h"
#include "cmExecutionStatus.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
@@ -25,6 +26,8 @@
# include <malloc.h> /* for malloc/free on QNX */
#endif
+class cmListFileBacktrace;
+
namespace {
const char* LastName = nullptr;
@@ -158,8 +161,10 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
if (result) {
if (this->Impl->FinalPass) {
auto impl = this->Impl;
- this->Makefile->AddFinalAction(
- [impl](cmMakefile& makefile) { impl->DoFinalPass(&makefile); });
+ this->Makefile->AddGeneratorAction(
+ [impl](cmLocalGenerator& lg, const cmListFileBacktrace&) {
+ impl->DoFinalPass(lg.GetMakefile());
+ });
}
return true;
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index bf488b1..41dabbd 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -36,6 +36,7 @@
#include "cmInstallGenerator.h" // IWYU pragma: keep
#include "cmInstallSubdirectoryGenerator.h"
#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSourceFile.h"
@@ -780,21 +781,23 @@ struct file_not_persistent
};
}
-void cmMakefile::AddFinalAction(FinalAction action)
+void cmMakefile::AddGeneratorAction(GeneratorAction action)
{
- this->FinalActions.push_back(std::move(action));
+ assert(!this->GeneratorActionsInvoked);
+ this->GeneratorActions.emplace_back(std::move(action), this->Backtrace);
}
-void cmMakefile::FinalPass()
+void cmMakefile::DoGenerate(cmLocalGenerator& lg)
{
// do all the variable expansions here
this->ExpandVariablesCMP0019();
// give all the commands a chance to do something
// after the file has been parsed before generation
- for (FinalAction& action : this->FinalActions) {
- action(*this);
+ for (const BT<GeneratorAction>& action : this->GeneratorActions) {
+ action.Value(lg, action.Backtrace);
}
+ this->GeneratorActionsInvoked = true;
// go through all configured files and see which ones still exist.
// we don't want cmake to re-run if a configured file is created and deleted
@@ -809,9 +812,9 @@ void cmMakefile::FinalPass()
}
// Generate the output file
-void cmMakefile::ConfigureFinalPass()
+void cmMakefile::Generate(cmLocalGenerator& lg)
{
- this->FinalPass();
+ this->DoGenerate(lg);
const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
if (oldValue &&
cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 6e59494..83a99f6 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -49,6 +49,7 @@ class cmGeneratorExpressionEvaluationFile;
class cmGlobalGenerator;
class cmImplicitDependsList;
class cmInstallGenerator;
+class cmLocalGenerator;
class cmMessenger;
class cmSourceFile;
class cmState;
@@ -151,23 +152,19 @@ public:
bool EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom = false) const;
- using FinalAction = std::function<void(cmMakefile&)>;
+ using GeneratorAction =
+ std::function<void(cmLocalGenerator&, const cmListFileBacktrace&)>;
/**
- * Register an action that is executed during FinalPass
+ * Register an action that is executed during Generate
*/
- void AddFinalAction(FinalAction action);
+ void AddGeneratorAction(GeneratorAction action);
/**
- * Perform FinalPass, Library dependency analysis etc before output of the
- * makefile.
+ * Perform generate actions, Library dependency analysis etc before output of
+ * the makefile.
*/
- void ConfigureFinalPass();
-
- /**
- * run all FinalActions.
- */
- void FinalPass();
+ void Generate(cmLocalGenerator& lg);
/**
* Get the target for PRE_BUILD, PRE_LINK, or POST_BUILD commands.
@@ -1001,7 +998,6 @@ protected:
size_t ObjectLibrariesSourceGroupIndex;
#endif
- std::vector<FinalAction> FinalActions;
cmGlobalGenerator* GlobalGenerator;
bool IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status);
@@ -1011,6 +1007,8 @@ private:
cmListFileBacktrace Backtrace;
int RecursionDepth;
+ void DoGenerate(cmLocalGenerator& lg);
+
void ReadListFile(cmListFile const& listFile,
const std::string& filenametoread);
@@ -1113,6 +1111,9 @@ private:
bool uses_terminal, bool command_expand_lists,
const std::string& job_pool);
+ std::vector<BT<GeneratorAction>> GeneratorActions;
+ bool GeneratorActionsInvoked = false;
+
/**
* See LinearGetSourceFileWithOutput for background information
*/
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 039f1ba..35b9a1d 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -15,6 +15,8 @@
#include "cmVariableWatch.h"
#include "cmake.h"
+class cmLocalGenerator;
+
namespace {
struct cmVariableWatchCallbackData
{
@@ -91,7 +93,7 @@ public:
{
}
- void operator()(cmMakefile&) const {}
+ void operator()(cmLocalGenerator&, const cmListFileBacktrace&) const {}
private:
struct Impl
@@ -145,7 +147,7 @@ bool cmVariableWatchCommand(std::vector<std::string> const& args,
return false;
}
- status.GetMakefile().AddFinalAction(
+ status.GetMakefile().AddGeneratorAction(
FinalAction{ &status.GetMakefile(), variable });
return true;
}