mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-24 08:47:59 +00:00
presets: Convert allowNoFiles to enum class
This improves readability at the call site when "yes" is desired.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<File*>& inProgressFiles,
|
||||
File*& file, std::string& errMsg);
|
||||
|
||||
Reference in New Issue
Block a user