Browse Source

Merge topic 'cmake-gui-incidental-errors'

d1792c48d5 cmake-gui: Suppress incidental error messages while choosing build tree
6f0ad398f1 cmake-gui: Clarify "Open Project" button implementation details

Acked-by: Kitware Robot <[email protected]>
Acked-by: Juan Ramos <[email protected]>
Merge-request: !10448
Brad King 10 months ago
parent
commit
582cbc541d
4 changed files with 16 additions and 8 deletions
  1. 3 3
      Source/QtDialog/QCMake.cxx
  2. 5 3
      Source/cmake.cxx
  3. 7 1
      Source/cmake.h
  4. 1 1
      Source/cmakemain.cxx

+ 3 - 3
Source/QtDialog/QCMake.cxx

@@ -310,8 +310,8 @@ void QCMake::open()
   InterruptFlag = 0;
   cmSystemTools::ResetErrorOccurredFlag();
 
-  auto successful =
-    this->CMakeInstance->Open(this->BinaryDirectory.toStdString(), false);
+  auto successful = this->CMakeInstance->Open(
+    this->BinaryDirectory.toStdString(), cmake::DryRun::No);
 
 #ifdef Q_OS_WIN
   SetErrorMode(lastErrorMode);
@@ -715,6 +715,6 @@ void QCMake::setWarnUninitializedMode(bool value)
 void QCMake::checkOpenPossible()
 {
   std::string data = this->BinaryDirectory.toStdString();
-  auto possible = this->CMakeInstance->Open(data, true);
+  auto possible = this->CMakeInstance->Open(data, cmake::DryRun::Yes);
   emit openPossible(possible);
 }

+ 5 - 3
Source/cmake.cxx

@@ -4011,12 +4011,14 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
   return buildresult;
 }
 
-bool cmake::Open(std::string const& dir, bool dryRun)
+bool cmake::Open(std::string const& dir, DryRun dryRun)
 {
   this->SetHomeDirectory("");
   this->SetHomeOutputDirectory("");
   if (!cmSystemTools::FileIsDirectory(dir)) {
-    std::cerr << "Error: " << dir << " is not a directory\n";
+    if (dryRun == DryRun::No) {
+      std::cerr << "Error: " << dir << " is not a directory\n";
+    }
     return false;
   }
 
@@ -4052,7 +4054,7 @@ bool cmake::Open(std::string const& dir, bool dryRun)
     return false;
   }
 
-  return gen->Open(dir, *cachedProjectName, dryRun);
+  return gen->Open(dir, *cachedProjectName, dryRun == DryRun::Yes);
 }
 
 #if !defined(CMAKE_BOOTSTRAP)

+ 7 - 1
Source/cmake.h

@@ -643,8 +643,14 @@ public:
             std::string const& presetName, bool listPresets,
             std::vector<std::string> const& args);
 
+  enum class DryRun
+  {
+    No,
+    Yes,
+  };
+
   //! run the --open option
-  bool Open(std::string const& dir, bool dryRun);
+  bool Open(std::string const& dir, DryRun dryRun);
 
   //! run the --workflow option
   enum class WorkflowListPresets

+ 1 - 1
Source/cmakemain.cxx

@@ -1132,7 +1132,7 @@ int do_open(int ac, char const* const* av)
   cm.SetProgressCallback([&cm](std::string const& msg, float prog) {
     cmakemainProgressCallback(msg, prog, &cm);
   });
-  return cm.Open(dir, false) ? 0 : 1;
+  return cm.Open(dir, cmake::DryRun::No) ? 0 : 1;
 #endif
 }
 } // namespace