summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-03-04 21:47:49 (GMT)
committerBrad King <brad.king@kitware.com>2021-03-22 17:28:27 (GMT)
commit608ef8a6fcbdd3d1a8419ff774109b8f9e5ebafb (patch)
treef25e9e15dd9a73796a5c949f6a1fa393b167a2ef /Source/cmGlobalVisualStudio10Generator.cxx
parent8dd8d6366576c09a44dc19d6609209ff74cd0dde (diff)
downloadCMake-608ef8a6fcbdd3d1a8419ff774109b8f9e5ebafb.zip
CMake-608ef8a6fcbdd3d1a8419ff774109b8f9e5ebafb.tar.gz
CMake-608ef8a6fcbdd3d1a8419ff774109b8f9e5ebafb.tar.bz2
VS: Add a mostly-undocumented hook to load custom JSON flag tables
The names and formats of our VS flag tables are internal implementation details. However, some institutions need to maintain support for non-public VS platforms and toolsets. Provide a hook that their projects can use to load custom flag table files. This helps avoid distributing a custom CMake package within such institutions. Document the hook itself, but explicitly specify that the files the hook loads are not considered a stable interface.
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index d33c763..93fbe37 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -231,6 +231,23 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
return false;
}
+ if (!this->CustomFlagTableDir.empty() &&
+ !(cmSystemTools::FileIsFullPath(this->CustomFlagTableDir) &&
+ cmSystemTools::FileIsDirectory(this->CustomFlagTableDir))) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset\n"
+ " customFlagTableDir=" << this->CustomFlagTableDir << "\n"
+ "that is not an absolute path to an existing directory.";
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
if (cmHasLiteralPrefix(this->GetPlatformToolsetString(), "v140")) {
// The GenerateDebugInformation link setting for the v140 toolset
// in VS 2015 was originally an enum with "No" and "Debug" values,
@@ -486,6 +503,11 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
}
return true;
}
+ if (key == "customFlagTableDir") {
+ this->CustomFlagTableDir = value;
+ cmSystemTools::ConvertToUnixSlashes(this->CustomFlagTableDir);
+ return true;
+ }
if (key == "version") {
this->GeneratorToolsetVersion = value;
return true;
@@ -1375,6 +1397,20 @@ static cmIDEFlagTable const* cmLoadFlagTableJson(
cm::optional<std::string> cmGlobalVisualStudio10Generator::FindFlagTable(
cm::string_view toolsetName, cm::string_view table) const
{
+ if (!this->CustomFlagTableDir.empty()) {
+ std::string customFlagTableFile =
+ cmStrCat(this->CustomFlagTableDir, '/', this->GetPlatformName(), '_',
+ toolsetName, '_', table, ".json");
+ if (cmSystemTools::FileExists(customFlagTableFile)) {
+ return customFlagTableFile;
+ }
+ customFlagTableFile =
+ cmStrCat(this->CustomFlagTableDir, '/', this->GetPlatformName(), '_',
+ table, ".json");
+ if (cmSystemTools::FileExists(customFlagTableFile)) {
+ return customFlagTableFile;
+ }
+ }
std::string fullPath =
cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/MSBuild/FlagTables/",
toolsetName, '_', table, ".json");