diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-10-25 18:30:25 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-10-26 21:54:08 (GMT) |
commit | 3d6a8d7eac588e42ae60231409fc763a6bc41e9b (patch) | |
tree | f6ed617d3f41c61caa5a6a4228b5b6f4c4981ded /Source/cmake.h | |
parent | fd57ced75a72cd73d2fd01ec0dd9c5cd552f029d (diff) | |
download | CMake-3d6a8d7eac588e42ae60231409fc763a6bc41e9b.zip CMake-3d6a8d7eac588e42ae60231409fc763a6bc41e9b.tar.gz CMake-3d6a8d7eac588e42ae60231409fc763a6bc41e9b.tar.bz2 |
cmMakefileProfilingData: Refactor to use RAII
And add a more generic StartEntry() method.
Diffstat (limited to 'Source/cmake.h')
-rw-r--r-- | Source/cmake.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/cmake.h b/Source/cmake.h index 5b5425c..a9a8bf2 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: |