mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-10 11:29:09 -05:00
cmGlobalVisualStudio10Generator: Generalize flag table lookup interface
This commit is contained in:
@@ -1358,46 +1358,61 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string cmGetFlagTableName(std::string const& toolsetName,
|
cm::optional<std::string> cmGlobalVisualStudio10Generator::FindFlagTable(
|
||||||
std::string const& table)
|
cm::string_view toolsetName, cm::string_view table) const
|
||||||
{
|
{
|
||||||
return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" +
|
std::string fullPath =
|
||||||
toolsetName + "_" + table + ".json";
|
cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/MSBuild/FlagTables/",
|
||||||
|
toolsetName, '_', table, ".json");
|
||||||
|
if (cmSystemTools::FileExists(fullPath)) {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
|
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
|
||||||
std::string const& toolSpecificName, std::string const& defaultName,
|
std::string const& toolSpecificName, std::string const& defaultName,
|
||||||
std::string const& table) const
|
std::string const& table) const
|
||||||
{
|
{
|
||||||
cmIDEFlagTable const* ret = nullptr;
|
cmMakefile* mf = this->GetCurrentMakefile();
|
||||||
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
if (!toolSpecificName.empty()) {
|
if (!toolSpecificName.empty()) {
|
||||||
filename = cmGetFlagTableName(toolSpecificName, table);
|
if (cm::optional<std::string> found =
|
||||||
ret = cmLoadFlagTableJson(filename);
|
this->FindFlagTable(toolSpecificName, table)) {
|
||||||
|
filename = std::move(*found);
|
||||||
|
} else {
|
||||||
|
mf->IssueMessage(MessageType::FATAL_ERROR,
|
||||||
|
cmStrCat("JSON flag table for ", table,
|
||||||
|
" not found for toolset ", toolSpecificName));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string const& genericName =
|
std::string const& genericName =
|
||||||
this->CanonicalToolsetName(this->GetPlatformToolsetString());
|
this->CanonicalToolsetName(this->GetPlatformToolsetString());
|
||||||
filename = cmGetFlagTableName(genericName, table);
|
cm::optional<std::string> found = this->FindFlagTable(genericName, table);
|
||||||
if (cmSystemTools::FileExists(filename)) {
|
if (!found) {
|
||||||
ret = cmLoadFlagTableJson(filename);
|
found = this->FindFlagTable(defaultName, table);
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
filename = std::move(*found);
|
||||||
} else {
|
} else {
|
||||||
filename = cmGetFlagTableName(defaultName, table);
|
mf->IssueMessage(MessageType::FATAL_ERROR,
|
||||||
ret = cmLoadFlagTableJson(filename);
|
cmStrCat("JSON flag table for ", table,
|
||||||
|
" not found for toolset ", genericName, " ",
|
||||||
|
defaultName));
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename)) {
|
||||||
cmMakefile* mf = this->GetCurrentMakefile();
|
return ret;
|
||||||
|
|
||||||
std::ostringstream e;
|
|
||||||
/* clang-format off */
|
|
||||||
e << "JSON flag table \"" << filename <<
|
|
||||||
"\" could not be loaded.\n";
|
|
||||||
/* clang-format on */
|
|
||||||
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
mf->IssueMessage(
|
||||||
|
MessageType::FATAL_ERROR,
|
||||||
|
cmStrCat("JSON flag table could not be loaded:\n ", filename));
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
|
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include <cm/optional>
|
||||||
|
#include <cm/string_view>
|
||||||
|
|
||||||
#include "cmGlobalVisualStudio8Generator.h"
|
#include "cmGlobalVisualStudio8Generator.h"
|
||||||
|
|
||||||
/** \class cmGlobalVisualStudio10Generator
|
/** \class cmGlobalVisualStudio10Generator
|
||||||
@@ -239,6 +242,9 @@ private:
|
|||||||
std::string GetMasmFlagTableName() const;
|
std::string GetMasmFlagTableName() const;
|
||||||
std::string CanonicalToolsetName(std::string const& toolset) const;
|
std::string CanonicalToolsetName(std::string const& toolset) const;
|
||||||
|
|
||||||
|
cm::optional<std::string> FindFlagTable(cm::string_view toolsetName,
|
||||||
|
cm::string_view table) const;
|
||||||
|
|
||||||
std::string CustomVCTargetsPath;
|
std::string CustomVCTargetsPath;
|
||||||
std::string VCTargetsPath;
|
std::string VCTargetsPath;
|
||||||
bool FindVCTargetsPath(cmMakefile* mf);
|
bool FindVCTargetsPath(cmMakefile* mf);
|
||||||
|
|||||||
Reference in New Issue
Block a user