summaryrefslogtreecommitdiff
path: root/Source/cmVisualStudioGeneratorOptions.cxx
diff options
context:
space:
mode:
authorcomicfans <comicfans44@gmail.com>2017-09-10 17:39:04 +0800
committerBrad King <brad.king@kitware.com>2017-09-18 11:53:22 -0400
commit3232f84c19b86184cb7c2db137b97ccb9aec20cc (patch)
treee501ab9d8d15456e731bc323c118c2d3b4285eff /Source/cmVisualStudioGeneratorOptions.cxx
parente18ab9c4b2fc3b11a1e246b1418d25382a853bfb (diff)
downloadcmake-3232f84c19b86184cb7c2db137b97ccb9aec20cc.tar.gz
VS: Fix MANIFESTUAC link flag map to .vcxproj elements
Add special parsing of the flags given in `/MANIFESTUAC:"..."` in order to map them correctly to `.vcxproj` elements. Keep the old incorrect flag table entries for `uiAccess` and `level` flags for compatibility even though they do not really exist. Fixes: #16563
Diffstat (limited to 'Source/cmVisualStudioGeneratorOptions.cxx')
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx68
1 files changed, 68 insertions, 0 deletions
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 51944fad3a..b1686bec1b 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -256,6 +256,74 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
}
}
+void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
+{
+ static const char* ENABLE_UAC = "EnableUAC";
+ if (!HasFlag(ENABLE_UAC)) {
+ return;
+ }
+
+ const std::string uacFlag = GetFlag(ENABLE_UAC);
+ std::vector<std::string> subOptions;
+ cmsys::SystemTools::Split(uacFlag, subOptions, ' ');
+ if (subOptions.empty()) {
+ AddFlag(ENABLE_UAC, "true");
+ return;
+ }
+
+ if (subOptions.size() == 1 && subOptions[0] == "NO") {
+ AddFlag(ENABLE_UAC, "false");
+ return;
+ }
+
+ std::map<std::string, std::string> uacMap;
+ uacMap["level"] = "UACExecutionLevel";
+ uacMap["uiAccess"] = "UACUIAccess";
+
+ std::map<std::string, std::string> uacExecuteLevelMap;
+ uacExecuteLevelMap["asInvoker"] = "AsInvoker";
+ uacExecuteLevelMap["highestAvailable"] = "HighestAvailable";
+ uacExecuteLevelMap["requireAdministrator"] = "RequireAdministrator";
+
+ for (auto const& subopt : subOptions) {
+ std::vector<std::string> keyValue;
+ cmsys::SystemTools::Split(subopt, keyValue, '=');
+ if (keyValue.size() != 2 || (uacMap.find(keyValue[0]) == uacMap.end())) {
+ // ignore none key=value option or unknown flags
+ continue;
+ }
+
+ if (keyValue[1].front() == '\'' && keyValue[1].back() == '\'') {
+ keyValue[1] =
+ keyValue[1].substr(1, std::max<int>(0, keyValue[1].size() - 2));
+ }
+
+ if (keyValue[0] == "level") {
+ if (uacExecuteLevelMap.find(keyValue[1]) == uacExecuteLevelMap.end()) {
+ // unknown level value
+ continue;
+ }
+
+ AddFlag(uacMap[keyValue[0]].c_str(),
+ uacExecuteLevelMap[keyValue[1]].c_str());
+ continue;
+ }
+
+ if (keyValue[0] == "uiAccess") {
+ if (keyValue[1] != "true" && keyValue[1] != "false") {
+ // unknown uiAccess value
+ continue;
+ }
+ AddFlag(uacMap[keyValue[0]].c_str(), keyValue[1].c_str());
+ continue;
+ }
+
+ // unknwon sub option
+ }
+
+ AddFlag(ENABLE_UAC, "true");
+}
+
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
{
// Parse the input string as a windows command line since the string