From 6f0ad398f1bee54924e8da56d3a1efa5a6123c35 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2025 10:56:14 -0500 Subject: cmake-gui: Clarify "Open Project" button implementation details --- Source/QtDialog/QCMake.cxx | 6 +++--- Source/cmake.cxx | 4 ++-- Source/cmake.h | 8 +++++++- Source/cmakemain.cxx | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 89781ca..baf8fbd 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/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); } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index fd410af..51731df 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4011,7 +4011,7 @@ int cmake::Build(int jobs, std::string dir, std::vector 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(""); @@ -4052,7 +4052,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) diff --git a/Source/cmake.h b/Source/cmake.h index f128a46..a9efeec 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -643,8 +643,14 @@ public: std::string const& presetName, bool listPresets, std::vector 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 diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 7c60427..aaf266a 100644 --- a/Source/cmakemain.cxx +++ b/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 -- cgit v0.12 From d1792c48d5b5171541fbf425e125ba61dbf89b82 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2025 10:58:12 -0500 Subject: cmake-gui: Suppress incidental error messages while choosing build tree Avoid printing Error: is not a directory to the console for every update to the GUI's build directory widget. --- Source/cmake.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 51731df..a096521 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4016,7 +4016,9 @@ 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; } -- cgit v0.12