Browse Source

Merge topic 'cmake_autogen_verbose'

5b85ef5cd0 Autogen: Add release notes for CMAKE_AUTOGEN_VERBOSE
6651aab2ab Autogen: Add documentation for CMAKE_AUTOGEN_VERBOSE
aa7d8a092c Autogen: Enable CMAKE_AUTOGEN_VERBOSE in all tests
e28dc3b1d8 Autogen: Add CMAKE_AUTOGEN_VERBOSE variable support

Acked-by: Kitware Robot <[email protected]>
Merge-request: !2157
Brad King 7 years ago
parent
commit
5e1f519037

+ 1 - 0
Help/manual/cmake-variables.7.rst

@@ -290,6 +290,7 @@ Variables that Control the Build
    /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
    /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG
    /variable/CMAKE_AUTOGEN_PARALLEL
+   /variable/CMAKE_AUTOGEN_VERBOSE
    /variable/CMAKE_AUTOMOC
    /variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES
    /variable/CMAKE_AUTOMOC_DEPEND_FILTERS

+ 6 - 0
Help/release/dev/CMAKE_AUTOGEN_VERBOSE.rst

@@ -0,0 +1,6 @@
+CMAKE_AUTOGEN_VERBOSE
+---------------------
+
+* The new variable :variable:`CMAKE_AUTOGEN_VERBOSE` allows
+  to increase the verbosity of :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and
+  :prop_tgt:`AUTORCC` from within CMakeLists.txt.

+ 13 - 0
Help/variable/CMAKE_AUTOGEN_VERBOSE.rst

@@ -0,0 +1,13 @@
+CMAKE_AUTOGEN_VERBOSE
+---------------------
+
+Sets the verbosity of :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and
+:prop_tgt:`AUTORCC`.  A positive integer value or a true boolean value
+lets the ``AUTO*`` generators output additional processing information.
+
+Setting :variable:`CMAKE_AUTOGEN_VERBOSE` has the same effect
+as setting the ``VERBOSE`` environment variable during
+generation (e.g. by calling ``make VERBOSE=1``).
+The extra verbosity is limited to the ``AUTO*`` generators though.
+
+By default :variable:`CMAKE_AUTOGEN_VERBOSE` is unset.

+ 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

+ 1 - 0
Tests/QtAutogen/RerunMocBasic/CMakeLists.txt

@@ -16,6 +16,7 @@ try_compile(MOC_RERUN
   "${mocBasicSrcDir}"
   MocBasic
   CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+              "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
               "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
   OUTPUT_VARIABLE output
 )

+ 1 - 0
Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt

@@ -19,6 +19,7 @@ try_compile(MOC_PLUGIN
   "${mocPlugSrcDir}"
   MocPlugin
   CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+              "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
               "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
   OUTPUT_VARIABLE output
 )

+ 1 - 0
Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt

@@ -19,6 +19,7 @@ try_compile(RCC_DEPENDS
   "${rccDepSD}"
   RccConfigChange
   CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+              "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
               "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
   OUTPUT_VARIABLE output
 )

+ 1 - 0
Tests/QtAutogen/RerunRccDepends/CMakeLists.txt

@@ -21,6 +21,7 @@ try_compile(RCC_DEPENDS
   "${rccDepSD}"
   RccDepends
   CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+              "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
               "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
   OUTPUT_VARIABLE output
 )

+ 1 - 0
Tests/QtAutogen/TestMacros.cmake

@@ -4,6 +4,7 @@ if(NOT _isMultiConfig)   # Set in Tests/CMakeLists.txt
   list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>")
 endif()
 list(APPEND Autogen_BUILD_OPTIONS
+    "-DCMAKE_AUTOGEN_VERBOSE=1"
     "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
 )