Browse Source

instrumentation: Use auto for variables holding closures

Martin Duffy 8 months ago
parent
commit
45d3ffaa95
3 changed files with 6 additions and 9 deletions
  1. 1 2
      Source/cmCTest.cxx
  2. 4 5
      Source/cmake.cxx
  3. 1 2
      Source/cmakemain.cxx

+ 1 - 2
Source/cmCTest.cxx

@@ -10,7 +10,6 @@
 #include <cstdlib>
 #include <cstring>
 #include <ctime>
-#include <functional>
 #include <initializer_list>
 #include <iostream>
 #include <map>
@@ -2725,7 +2724,7 @@ int cmCTest::ExecuteTests(std::vector<std::string> const& args)
   handler.SetVerbose(this->Impl->Verbose);
 
   cmInstrumentation instrumentation(this->GetBinaryDir());
-  std::function<int()> processHandler = [&handler]() {
+  auto processHandler = [&handler]() -> int {
     return handler.ProcessHandler();
   };
   int ret = instrumentation.InstrumentCommand("ctest", args, processHandler);

+ 4 - 5
Source/cmake.cxx

@@ -2624,7 +2624,7 @@ int cmake::ActualConfigure()
     cmSystemTools::Error(this->Instrumentation->errorMsg);
     return 1;
   }
-  std::function<int()> doConfigure = [this]() -> int {
+  auto doConfigure = [this]() -> int {
     this->GlobalGenerator->Configure();
     return 0;
   };
@@ -3023,7 +3023,7 @@ int cmake::Generate()
   auto startTime = std::chrono::steady_clock::now();
 #if !defined(CMAKE_BOOTSTRAP)
   auto profilingRAII = this->CreateProfilingEntry("project", "generate");
-  std::function<int()> doGenerate = [this]() -> int {
+  auto doGenerate = [this]() -> int {
     if (!this->GlobalGenerator->Compute()) {
       return -1;
     }
@@ -3975,9 +3975,8 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
   // are being executed to the `output` parameter. If CMake is verbose, print
   // this out.
   std::ostream& verbose_ostr = verbose ? std::cout : ostr;
-  std::function<int()> doBuild = [this, jobs, dir, projName, targets,
-                                  &verbose_ostr, config, buildOptions, verbose,
-                                  nativeOptions]() {
+  auto doBuild = [this, jobs, dir, projName, targets, &verbose_ostr, config,
+                  buildOptions, verbose, nativeOptions]() -> int {
     return this->GlobalGenerator->Build(
       jobs, "", dir, projName, targets, verbose_ostr, "", config, buildOptions,
       verbose, cmDuration::zero(), cmSystemTools::OUTPUT_PASSTHROUGH,

+ 1 - 2
Source/cmakemain.cxx

@@ -971,8 +971,7 @@ int do_install(int ac, char const* const* av)
     }
   }
 
-  std::function<int()> doInstall = [&handler, &verbose, &jobs,
-                                    &instrumentation]() -> int {
+  auto doInstall = [&handler, &verbose, &jobs, &instrumentation]() -> int {
     int ret_ = 0;
     if (handler.IsParallel()) {
       ret_ = handler.Install(jobs, instrumentation);