1
0
Эх сурвалжийг харах

Autogen: Add CMAKE_AUTOGEN_VERBOSE variable support

Setting CMAKE_AUTOGEN_VERBOSE enables verbose output during
AUTOMOC, AUTOUIC and AUTORCC generation.
Sebastian Holtermann 7 жил өмнө
parent
commit
e28dc3b1d8

+ 15 - 1
Source/cmQtAutoGenInitializer.cxx

@@ -210,6 +210,19 @@ void cmQtAutoGenInitializer::InitCustomTargets()
   cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
   cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator();
 
+  // Verbosity
+  {
+    this->Verbosity = makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE");
+    if (!this->Verbosity.empty()) {
+      unsigned long iVerb = 0;
+      if (!cmSystemTools::StringToULong(this->Verbosity.c_str(), &iVerb)) {
+        // Non numeric verbosity
+        this->Verbosity =
+          cmSystemTools::IsOn(this->Verbosity.c_str()) ? "1" : "0";
+      }
+    }
+  }
+
   // Configurations
   this->MultiConfig = globalGen->IsMultiConfig();
   this->ConfigDefault = makefile->GetConfigurations(this->ConfigsList);
@@ -944,6 +957,7 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
       ofs << "# Meta\n";
       CWrite("AM_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE");
       CWrite("AM_PARALLEL", this->Parallel);
+      CWrite("AM_VERBOSITY", this->Verbosity);
 
       ofs << "# Directories\n";
       CWrite("AM_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR"));
@@ -1036,7 +1050,7 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
         // Write
         ofs << "# Configurations\n";
         CWrite("ARCC_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE");
-
+        CWrite("ARCC_VERBOSITY", this->Verbosity);
         ofs << "# Settings file\n";
         if (this->MultiConfig) {
           std::map<std::string, std::string> settingsFiles;

+ 1 - 0
Source/cmQtAutoGenInitializer.h

@@ -83,6 +83,7 @@ private:
   std::string ConfigDefault;
   std::vector<std::string> ConfigsList;
   std::string Parallel;
+  std::string Verbosity;
   // Names
   std::string AutogenTargetName;
   std::string AutogenFolder;

+ 19 - 3
Source/cmQtAutoGenerator.cxx

@@ -17,9 +17,14 @@
 
 // -- Class methods
 
-void cmQtAutoGenerator::Logger::SetVerbose(bool value)
+void cmQtAutoGenerator::Logger::RaiseVerbosity(std::string const& value)
 {
-  Verbose_ = value;
+  unsigned long verbosity = 0;
+  if (cmSystemTools::StringToULong(value.c_str(), &verbosity)) {
+    if (this->Verbosity_ < verbosity) {
+      this->Verbosity_ = static_cast<unsigned int>(verbosity);
+    }
+  }
 }
 
 void cmQtAutoGenerator::Logger::SetColorOutput(bool value)
@@ -632,7 +637,18 @@ cmQtAutoGenerator::cmQtAutoGenerator()
   : FileSys_(&Logger_)
 {
   // Initialize logger
-  Logger_.SetVerbose(cmSystemTools::HasEnv("VERBOSE"));
+  {
+    std::string verbose;
+    if (cmSystemTools::GetEnv("VERBOSE", verbose) && !verbose.empty()) {
+      unsigned long iVerbose = 0;
+      if (cmSystemTools::StringToULong(verbose.c_str(), &iVerbose)) {
+        Logger_.SetVerbosity(static_cast<unsigned int>(iVerbose));
+      } else {
+        // Non numeric verbosity
+        Logger_.SetVerbose(cmSystemTools::IsOn(verbose.c_str()));
+      }
+    }
+  }
   {
     std::string colorEnv;
     cmSystemTools::GetEnv("COLOR", colorEnv);

+ 7 - 4
Source/cmQtAutoGenerator.h

@@ -33,8 +33,11 @@ public:
   {
   public:
     // -- Verbosity
-    bool Verbose() const { return this->Verbose_; }
-    void SetVerbose(bool value);
+    unsigned int Verbosity() const { return this->Verbosity_; }
+    void SetVerbosity(unsigned int value) { this->Verbosity_ = value; }
+    void RaiseVerbosity(std::string const& value);
+    bool Verbose() const { return (this->Verbosity_ != 0); }
+    void SetVerbose(bool value) { this->Verbosity_ = value ? 1 : 0; }
     bool ColorOutput() const { return this->ColorOutput_; }
     void SetColorOutput(bool value);
     // -- Log info
@@ -56,8 +59,8 @@ public:
 
   private:
     std::mutex Mutex_;
-    bool volatile Verbose_ = false;
-    bool volatile ColorOutput_ = false;
+    unsigned int Verbosity_ = 0;
+    bool ColorOutput_ = false;
   };
 
   /// @brief Thread safe file system interface

+ 1 - 0
Source/cmQtAutoGeneratorMocUic.cxx

@@ -1222,6 +1222,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
   }
 
   // -- Meta
+  Log().RaiseVerbosity(InfoGet("AM_VERBOSITY"));
   Base_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG");
   {
     unsigned long num = Base_.NumThreads;

+ 1 - 0
Source/cmQtAutoGeneratorRcc.cxx

@@ -70,6 +70,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
   }
 
   // - Configurations
+  Log().RaiseVerbosity(InfoGet("ARCC_VERBOSITY"));
   MultiConfig_ = makefile->IsOn("ARCC_MULTI_CONFIG");
 
   // - Directories