summaryrefslogtreecommitdiff
path: root/Source/cmake.h
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-10-25 14:30:25 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2022-10-26 17:54:08 -0400
commit3d6a8d7eac588e42ae60231409fc763a6bc41e9b (patch)
treef6ed617d3f41c61caa5a6a4228b5b6f4c4981ded /Source/cmake.h
parentfd57ced75a72cd73d2fd01ec0dd9c5cd552f029d (diff)
downloadcmake-3d6a8d7eac588e42ae60231409fc763a6bc41e9b.tar.gz
cmMakefileProfilingData: Refactor to use RAII
And add a more generic StartEntry() method.
Diffstat (limited to 'Source/cmake.h')
-rw-r--r--Source/cmake.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/cmake.h b/Source/cmake.h
index 5b5425cb1f..a9a8bf24bd 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -33,6 +33,7 @@
# include <cm3p/json/value.h>
# include "cmCMakePresetsGraph.h"
+# include "cmMakefileProfilingData.h"
#endif
class cmExternalMakefileProjectGeneratorFactory;
@@ -41,9 +42,6 @@ class cmFileTimeCache;
class cmGlobalGenerator;
class cmGlobalGeneratorFactory;
class cmMakefile;
-#if !defined(CMAKE_BOOTSTRAP)
-class cmMakefileProfilingData;
-#endif
class cmMessenger;
class cmVariableWatch;
struct cmBuildOptions;
@@ -628,6 +626,17 @@ public:
#if !defined(CMAKE_BOOTSTRAP)
cmMakefileProfilingData& GetProfilingOutput();
bool IsProfilingEnabled() const;
+
+ template <typename... Args>
+ cm::optional<cmMakefileProfilingData::RAII> CreateProfilingEntry(
+ Args&&... args)
+ {
+ if (this->IsProfilingEnabled()) {
+ return cm::make_optional<cmMakefileProfilingData::RAII>(
+ this->GetProfilingOutput(), std::forward<Args>(args)...);
+ }
+ return cm::nullopt;
+ }
#endif
protected: