summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.h')
-rw-r--r--Source/cmMakefile.h55
1 files changed, 36 insertions, 19 deletions
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index d223347..dcc4e77 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -7,8 +7,9 @@
#include "cmsys/RegularExpression.hxx"
#include <deque>
+#include <functional>
#include <map>
-#include <memory> // IWYU pragma: keep
+#include <memory>
#include <set>
#include <stack>
#include <stddef.h>
@@ -16,6 +17,8 @@
#include <unordered_map>
#include <vector>
+#include "cm_string_view.hxx"
+
#include "cmAlgorithms.h"
#include "cmListFileCache.h"
#include "cmMessageType.h"
@@ -24,13 +27,13 @@
#include "cmSourceFileLocationKind.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
# include "cmSourceGroup.h"
#endif
-class cmCommand;
class cmCompiledGeneratorExpression;
class cmCustomCommandLines;
class cmExecutionStatus;
@@ -95,7 +98,7 @@ public:
/**
* Add a function blocker to this makefile
*/
- void AddFunctionBlocker(cmFunctionBlocker* fb);
+ void AddFunctionBlocker(std::unique_ptr<cmFunctionBlocker> fb);
/// @return whether we are processing the top CMakeLists.txt file.
bool IsRootMakefile() const;
@@ -104,8 +107,7 @@ public:
* Remove the function blocker whose scope ends with the given command.
* This returns ownership of the function blocker object.
*/
- std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker(
- cmFunctionBlocker* fb, const cmListFileFunction& lff);
+ std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker();
/**
* Try running cmake and building a file. This is used for dynalically
@@ -125,6 +127,13 @@ public:
bool EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom = false) const;
+ using FinalAction = std::function<void(cmMakefile&)>;
+
+ /**
+ * Register an action that is executed during FinalPass
+ */
+ void AddFinalAction(FinalAction action);
+
/**
* Perform FinalPass, Library dependency analysis etc before output of the
* makefile.
@@ -132,7 +141,7 @@ public:
void ConfigureFinalPass();
/**
- * run the final pass on all commands.
+ * run all FinalActions.
*/
void FinalPass();
@@ -256,18 +265,17 @@ public:
* Add a variable definition to the build. This variable
* can be used in CMake to refer to lists, directories, etc.
*/
- void AddDefinition(const std::string& name, const char* value);
+ void AddDefinition(const std::string& name, cm::string_view value);
+ /**
+ * Add bool variable definition to the build.
+ */
+ void AddDefinitionBool(const std::string& name, bool);
//! Add a definition to this makefile and the global cmake cache.
void AddCacheDefinition(const std::string& name, const char* value,
const char* doc, cmStateEnums::CacheEntryType type,
bool force = false);
/**
- * Add bool variable definition to the build.
- */
- void AddDefinition(const std::string& name, bool);
-
- /**
* Remove a variable definition from the build. This is not valid
* for cache entries, and will only affect the current makefile.
*/
@@ -495,7 +503,7 @@ public:
*/
bool CanIWriteThisFile(std::string const& fileName) const;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
/**
* Get the vector source groups.
*/
@@ -619,6 +627,11 @@ public:
void PrintCommandTrace(const cmListFileFunction& lff) const;
/**
+ * Set a callback that is invoked whenever ExecuteCommand is called.
+ */
+ void OnExecuteCommand(std::function<void()> callback);
+
+ /**
* Execute a single CMake command. Returns true if the command
* succeeded or false if it failed.
*/
@@ -636,7 +649,7 @@ public:
* Get the variable watch. This is used to determine when certain variables
* are accessed.
*/
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* GetVariableWatch() const;
#endif
@@ -932,12 +945,12 @@ protected:
// Track the value of the computed DEFINITIONS property.
std::string DefineFlagsOrig;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::vector<cmSourceGroup> SourceGroups;
size_t ObjectLibrariesSourceGroupIndex;
#endif
- std::vector<cmCommand*> FinalPassCommands;
+ std::vector<FinalAction> FinalActions;
cmGlobalGenerator* GlobalGenerator;
bool IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status);
@@ -955,7 +968,10 @@ private:
bool EnforceUniqueDir(const std::string& srcPath,
const std::string& binPath) const;
- typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
+ std::function<void()> ExecuteCommandCallback;
+ using FunctionBlockerPtr = std::unique_ptr<cmFunctionBlocker>;
+ using FunctionBlockersType =
+ std::stack<FunctionBlockerPtr, std::vector<FunctionBlockerPtr>>;
FunctionBlockersType FunctionBlockers;
std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
void PushFunctionBlockerBarrier();
@@ -986,7 +1002,8 @@ private:
cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
void PopPolicy();
void PopSnapshot(bool reportError = true);
- friend class cmCMakePolicyCommand;
+ friend bool cmCMakePolicyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
class IncludeScope;
friend class IncludeScope;