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"
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
)) {
41 if (this->DefaultPlatformToolset
.empty()) {
42 e
= cmStrCat(this->GetName(), " supports Windows Phone '8.0', but not '",
43 this->SystemVersion
, "'. Check CMAKE_SYSTEM_VERSION.");
46 "A Windows Phone component with CMake requires both the Windows "
47 "Desktop SDK as well as the Windows Phone '",
49 "' SDK. Please make sure that you have both installed");
51 mf
->IssueMessage(MessageType::FATAL_ERROR
, e
);
57 bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile
* mf
)
59 if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset
)) {
61 if (this->DefaultPlatformToolset
.empty()) {
62 e
= cmStrCat(this->GetName(), " supports Windows Store '8.0', but not '",
63 this->SystemVersion
, "'. Check CMAKE_SYSTEM_VERSION.");
66 "A Windows Store component with CMake requires both the Windows "
67 "Desktop SDK as well as the Windows Store '",
69 "' SDK. Please make sure that you have both installed");
71 mf
->IssueMessage(MessageType::FATAL_ERROR
, e
);
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";
88 return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
92 bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
93 std::string
& toolset
) const
95 if (this->SystemVersion
== "8.0"_s
) {
96 if (this->IsWindowsStoreToolsetInstalled() &&
97 this->IsWindowsDesktopToolsetInstalled()) {
103 return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
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
;
134 if (cmSystemTools::ReadRegistryValue(key
, path
,
135 cmSystemTools::KeyWOW64_32
) &&
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
;
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";
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
);