Merge topic 'curl-tls-verify'
[kiteware-cmake.git] / Source / cmGlobalVisualStudio11Generator.cxx
blob0ec5e8b21899026e4638a993c4150688dd6d0bb8
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmGlobalVisualStudio11Generator.h"
5 #include <cstring>
6 #include <utility>
7 #include <vector>
9 #include <cmext/string_view>
11 #include "cmGlobalGenerator.h"
12 #include "cmGlobalVisualStudioGenerator.h"
13 #include "cmMakefile.h"
14 #include "cmMessageType.h"
15 #include "cmStringAlgorithms.h"
16 #include "cmSystemTools.h"
18 cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
19 cmake* cm, const std::string& name,
20 std::string const& platformInGeneratorName)
21 : cmGlobalVisualStudio10Generator(cm, name, platformInGeneratorName)
25 void cmGlobalVisualStudio11Generator::EnableLanguage(
26 std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
28 for (std::string const& it : lang) {
29 if (it == "ASM_MARMASM"_s) {
30 this->MarmasmEnabled = true;
33 this->AddPlatformDefinitions(mf);
34 cmGlobalVisualStudio10Generator::EnableLanguage(lang, mf, optional);
37 bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
39 if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
40 std::string e;
41 if (this->DefaultPlatformToolset.empty()) {
42 e = cmStrCat(this->GetName(), " supports Windows Phone '8.0', but not '",
43 this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
44 } else {
45 e = cmStrCat(
46 "A Windows Phone component with CMake requires both the Windows "
47 "Desktop SDK as well as the Windows Phone '",
48 this->SystemVersion,
49 "' SDK. Please make sure that you have both installed");
51 mf->IssueMessage(MessageType::FATAL_ERROR, e);
52 return false;
54 return true;
57 bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
59 if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
60 std::string e;
61 if (this->DefaultPlatformToolset.empty()) {
62 e = cmStrCat(this->GetName(), " supports Windows Store '8.0', but not '",
63 this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
64 } else {
65 e = cmStrCat(
66 "A Windows Store component with CMake requires both the Windows "
67 "Desktop SDK as well as the Windows Store '",
68 this->SystemVersion,
69 "' SDK. Please make sure that you have both installed");
71 mf->IssueMessage(MessageType::FATAL_ERROR, e);
72 return false;
74 return true;
77 bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
78 std::string& toolset) const
80 if (this->SystemVersion == "8.0"_s) {
81 if (this->IsWindowsPhoneToolsetInstalled() &&
82 this->IsWindowsDesktopToolsetInstalled()) {
83 toolset = "v110_wp80";
84 return true;
86 return false;
88 return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
89 toolset);
92 bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
93 std::string& toolset) const
95 if (this->SystemVersion == "8.0"_s) {
96 if (this->IsWindowsStoreToolsetInstalled() &&
97 this->IsWindowsDesktopToolsetInstalled()) {
98 toolset = "v110";
99 return true;
101 return false;
103 return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
104 toolset);
107 bool cmGlobalVisualStudio11Generator::UseFolderProperty() const
109 // Intentionally skip up to the top-level class implementation.
110 // Folders are not supported by the Express editions in VS10 and earlier,
111 // but they are in VS11 Express and above.
112 // NOLINTNEXTLINE(bugprone-parent-virtual-call)
113 return cmGlobalGenerator::UseFolderProperty();
116 std::set<std::string>
117 cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
119 const char sdksKey[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
120 "Windows CE Tools\\SDKs";
122 std::vector<std::string> subkeys;
123 cmSystemTools::GetRegistrySubKeys(sdksKey, subkeys,
124 cmSystemTools::KeyWOW64_32);
126 std::set<std::string> ret;
127 for (std::string const& i : subkeys) {
128 std::string key = sdksKey;
129 key += '\\';
130 key += i;
131 key += ';';
133 std::string path;
134 if (cmSystemTools::ReadRegistryValue(key, path,
135 cmSystemTools::KeyWOW64_32) &&
136 !path.empty()) {
137 ret.insert(i);
141 return ret;
144 bool cmGlobalVisualStudio11Generator::TargetSystemSupportsDeployment() const
146 return this->SystemIsWindowsPhone || this->SystemIsWindowsStore ||
147 cmGlobalVisualStudio10Generator::TargetSystemSupportsDeployment();
150 bool cmGlobalVisualStudio11Generator::IsWindowsDesktopToolsetInstalled() const
152 const char desktop80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
153 "VisualStudio\\11.0\\VC\\Libraries\\Extended";
154 const char VS2012DesktopExpressKey[] =
155 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
156 "WDExpress\\11.0;InstallDir";
158 std::vector<std::string> subkeys;
159 std::string path;
160 return cmSystemTools::ReadRegistryValue(VS2012DesktopExpressKey, path,
161 cmSystemTools::KeyWOW64_32) ||
162 cmSystemTools::GetRegistrySubKeys(desktop80Key, subkeys,
163 cmSystemTools::KeyWOW64_32);
166 bool cmGlobalVisualStudio11Generator::IsWindowsPhoneToolsetInstalled() const
168 const char wp80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
169 "Microsoft SDKs\\WindowsPhone\\v8.0\\"
170 "Install Path;Install Path";
172 std::string path;
173 cmSystemTools::ReadRegistryValue(wp80Key, path, cmSystemTools::KeyWOW64_32);
174 return !path.empty();
177 bool cmGlobalVisualStudio11Generator::IsWindowsStoreToolsetInstalled() const
179 const char win80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
180 "VisualStudio\\11.0\\VC\\Libraries\\Core\\Arm";
182 std::vector<std::string> subkeys;
183 return cmSystemTools::GetRegistrySubKeys(win80Key, subkeys,
184 cmSystemTools::KeyWOW64_32);