diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 9e11197188..42df7041d7 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -541,7 +541,8 @@ void QCMake::setUpEnvironment() const void QCMake::loadPresets() { auto result = this->CMakePresetsGraph.ReadProjectPresets( - this->SourceDirectory.toStdString(), true); + this->SourceDirectory.toStdString(), + cmCMakePresetsGraph::ReadOption::AllowNoFiles); if (!result) { emit this->presetLoadError( this->SourceDirectory, diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 7e57854753..408ff4956e 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -1142,12 +1142,12 @@ std::string cmCMakePresetsGraph::GetUserFilename(std::string const& sourceDir) } bool cmCMakePresetsGraph::ReadProjectPresets(std::string const& sourceDir, - bool allowNoFiles) + ReadOption readFilesOption) { this->SourceDir = cmSystemTools::CollapseFullPath(sourceDir); this->ClearPresets(); - if (!this->ReadProjectPresetsInternal(allowNoFiles)) { + if (!this->ReadProjectPresetsInternal(readFilesOption)) { this->ClearPresets(); return false; } @@ -1183,7 +1183,8 @@ std::string cmCMakePresetsGraph::GetGeneratorForPreset( return {}; } -bool cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) +bool cmCMakePresetsGraph::ReadProjectPresetsInternal( + ReadOption readFilesOption) { bool haveOneFile = false; @@ -1209,7 +1210,7 @@ bool cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) assert(inProgressFiles.empty()); if (!haveOneFile) { - if (allowNoFiles) { + if (readFilesOption == ReadOption::AllowNoFiles) { return true; } cmCMakePresetsErrors::FILE_NOT_FOUND(filename, &this->parseState); diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h index 209fd647ca..1d69d7d1f2 100644 --- a/Source/cmCMakePresetsGraph.h +++ b/Source/cmCMakePresetsGraph.h @@ -453,8 +453,15 @@ public: return preset.OriginFile->Version; } - bool ReadProjectPresets(std::string const& sourceDir, - bool allowNoFiles = false); + enum class ReadOption + { + RequireFiles, + AllowNoFiles, + }; + + bool ReadProjectPresets( + std::string const& sourceDir, + ReadOption readFilesOption = ReadOption::RequireFiles); std::string GetGeneratorForPreset(std::string const& presetName) const; @@ -482,7 +489,7 @@ private: Included, }; - bool ReadProjectPresetsInternal(bool allowNoFiles); + bool ReadProjectPresetsInternal(ReadOption readFilesOption); bool ReadJSONFile(std::string const& filename, RootType rootType, ReadReason readReason, std::vector& inProgressFiles, File*& file, std::string& errMsg);