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

cmake-gui: Add options to control warning-as-error messages

Add new widgets to the warning messages dialog to control treating
warnings as errors.
Michael Scott 10 жил өмнө
parent
commit
821667018c

+ 20 - 0
Source/QtDialog/QCMake.cxx

@@ -475,6 +475,26 @@ void QCMake::setSuppressDeprecatedWarnings(bool value)
   this->CMakeInstance->SetSuppressDeprecatedWarnings(value);
 }
 
+bool QCMake::getDevWarningsAsErrors()
+{
+  return this->CMakeInstance->GetDevWarningsAsErrors();
+}
+
+void QCMake::setDevWarningsAsErrors(bool value)
+{
+  this->CMakeInstance->SetDevWarningsAsErrors(value);
+}
+
+bool QCMake::getDeprecatedWarningsAsErrors()
+{
+  return this->CMakeInstance->GetDeprecatedWarningsAsErrors();
+}
+
+void QCMake::setDeprecatedWarningsAsErrors(bool value)
+{
+  this->CMakeInstance->SetDeprecatedWarningsAsErrors(value);
+}
+
 void QCMake::setWarnUninitializedMode(bool value)
 {
   this->WarnUninitializedMode = value;

+ 8 - 0
Source/QtDialog/QCMake.h

@@ -99,6 +99,14 @@ public slots:
   bool getSuppressDeprecatedWarnings();
   /// set whether to do suppress deprecated warnings
   void setSuppressDeprecatedWarnings(bool value);
+  /// get whether to treat developer (author) warnings as errors
+  bool getDevWarningsAsErrors();
+  /// set whether to treat developer (author) warnings as errors
+  void setDevWarningsAsErrors(bool value);
+  /// get whether to treat deprecated warnings as errors
+  bool getDeprecatedWarningsAsErrors();
+  /// set whether to treat deprecated warnings as errors
+  void setDeprecatedWarningsAsErrors(bool value);
   /// set whether to run cmake with warnings about uninitialized variables
   void setWarnUninitializedMode(bool value);
   /// set whether to run cmake with warnings about unused variables

+ 56 - 0
Source/QtDialog/WarningMessagesDialog.cxx

@@ -26,12 +26,27 @@ void WarningMessagesDialog::setInitialValues()
     this->cmakeInstance->getSuppressDevWarnings());
   this->suppressDeprecatedWarnings->setChecked(
     this->cmakeInstance->getSuppressDeprecatedWarnings());
+
+  this->developerWarningsAsErrors->setChecked(
+    this->cmakeInstance->getDevWarningsAsErrors());
+  this->deprecatedWarningsAsErrors->setChecked(
+    this->cmakeInstance->getDeprecatedWarningsAsErrors());
 }
 
 void WarningMessagesDialog::setupSignals()
 {
   QObject::connect(this->buttonBox, SIGNAL(accepted()),
                    this, SLOT(doAccept()));
+
+  QObject::connect(this->suppressDeveloperWarnings, SIGNAL(stateChanged(int)),
+                   this, SLOT(doSuppressDeveloperWarningsChanged(int)));
+  QObject::connect(this->suppressDeprecatedWarnings, SIGNAL(stateChanged(int)),
+                   this, SLOT(doSuppressDeprecatedWarningsChanged(int)));
+
+  QObject::connect(this->developerWarningsAsErrors, SIGNAL(stateChanged(int)),
+                   this, SLOT(doDeveloperWarningsAsErrorsChanged(int)));
+  QObject::connect(this->deprecatedWarningsAsErrors, SIGNAL(stateChanged(int)),
+                   this, SLOT(doDeprecatedWarningsAsErrorsChanged(int)));
 }
 
 void WarningMessagesDialog::doAccept()
@@ -40,4 +55,45 @@ void WarningMessagesDialog::doAccept()
     this->suppressDeveloperWarnings->isChecked());
   this->cmakeInstance->setSuppressDeprecatedWarnings(
     this->suppressDeprecatedWarnings->isChecked());
+
+  this->cmakeInstance->setDevWarningsAsErrors(
+    this->developerWarningsAsErrors->isChecked());
+  this->cmakeInstance->setDeprecatedWarningsAsErrors(
+    this->deprecatedWarningsAsErrors->isChecked());
+}
+
+void WarningMessagesDialog::doSuppressDeveloperWarningsChanged(int state)
+{
+  // no warnings implies no errors either
+  if (state)
+    {
+    this->developerWarningsAsErrors->setChecked(false);
+    }
+}
+
+void WarningMessagesDialog::doSuppressDeprecatedWarningsChanged(int state)
+{
+  // no warnings implies no errors either
+  if (state)
+    {
+    this->deprecatedWarningsAsErrors->setChecked(false);
+    }
+}
+
+void WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged(int state)
+{
+  // warnings as errors implies warnings are not suppressed
+  if (state)
+    {
+    this->suppressDeveloperWarnings->setChecked(false);
+    }
+}
+
+void WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged(int state)
+{
+  // warnings as errors implies warnings are not suppressed
+  if (state)
+    {
+    this->suppressDeprecatedWarnings->setChecked(false);
+    }
 }

+ 22 - 0
Source/QtDialog/WarningMessagesDialog.h

@@ -35,6 +35,28 @@ private slots:
    */
   void doAccept();
 
+  /**
+   * Handler for checked state changed event of the suppress developer warnings
+   * checkbox.
+   */
+  void doSuppressDeveloperWarningsChanged(int state);
+  /**
+   * Handler for checked state changed event of the suppress deprecated
+   * warnings checkbox.
+   */
+  void doSuppressDeprecatedWarningsChanged(int state);
+
+  /**
+   * Handler for checked state changed event of the developer warnings as
+   * errors checkbox.
+   */
+  void doDeveloperWarningsAsErrorsChanged(int state);
+  /**
+   * Handler for checked state changed event of the deprecated warnings as
+   * errors checkbox.
+   */
+  void doDeprecatedWarningsAsErrorsChanged(int state);
+
 private:
   QCMake* cmakeInstance;
 

+ 55 - 2
Source/QtDialog/WarningMessagesDialog.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>250</width>
-    <height>150</height>
+    <width>300</width>
+    <height>300</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -37,6 +37,9 @@
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="toolTip">
+         <string>Suppress developer (author) warnings.</string>
+        </property>
         <property name="text">
          <string>Developer Warnings</string>
         </property>
@@ -53,6 +56,9 @@
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="toolTip">
+         <string>Suppress deprecated warnings.</string>
+        </property>
         <property name="text">
          <string>Deprecated Warnings</string>
         </property>
@@ -64,6 +70,53 @@
      </layout>
     </widget>
    </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>Warnings as Errors</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_3">
+      <item>
+       <widget class="QCheckBox" name="developerWarningsAsErrors">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Treat developer (author) warnings as errors.</string>
+        </property>
+        <property name="text">
+         <string>Developer Warnings as Errors</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="deprecatedWarningsAsErrors">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Treat deprecated warnings as errors.</string>
+        </property>
+        <property name="text">
+         <string>Deprecated Warnings as Errors</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item>
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="sizePolicy">