diff options
author | Gilles Khouzam <gillesk@microsoft.com> | 2014-11-13 19:47:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-11-14 14:13:27 (GMT) |
commit | b20a32ac7349d38b215ef065773968c63c813f70 (patch) | |
tree | 7c7a0f4a22dc30c832c0d841e65c22f5822777d1 /Source/cmGlobalVisualStudio12Generator.cxx | |
parent | 54ff77dc621a91302abad0ab38d9bd26de8914b9 (diff) | |
download | CMake-b20a32ac7349d38b215ef065773968c63c813f70.zip CMake-b20a32ac7349d38b215ef065773968c63c813f70.tar.gz CMake-b20a32ac7349d38b215ef065773968c63c813f70.tar.bz2 |
VS: Improve error messages when compiler is not detected (#15228)
CMake requires both the Desktop SDK and the correct platform SDK
(Windows Phone or Windows Store) to be installed when targeting the
Windows mobile platforms. Verify that the right platform components are
installed and give a more detailed error message when something is
wrong.
Diffstat (limited to 'Source/cmGlobalVisualStudio12Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio12Generator.cxx | 111 |
1 files changed, 97 insertions, 14 deletions
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 29ecfe0..047f2ad 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -111,12 +111,20 @@ cmGlobalVisualStudio12Generator::MatchesGeneratorName( //---------------------------------------------------------------------------- bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf) { - this->DefaultPlatformToolset = this->SelectWindowsPhoneToolset(); - if(this->DefaultPlatformToolset.empty()) + if(!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) { cmOStringStream e; - e << this->GetName() << " supports Windows Phone '8.0' and '8.1', " - "but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION."; + if(this->DefaultPlatformToolset.empty()) + { + e << this->GetName() << " supports Windows Phone '8.0' and '8.1', but " + "not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION."; + } + else + { + e << "A Windows Phone component with CMake requires both the Windows " + << "Desktop SDK as well as the Windows Phone '" << this->SystemVersion + << "' SDK. Please make sure that you have both installed"; + } mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } @@ -126,12 +134,20 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf) //---------------------------------------------------------------------------- bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf) { - this->DefaultPlatformToolset = this->SelectWindowsStoreToolset(); - if(this->DefaultPlatformToolset.empty()) + if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) { cmOStringStream e; - e << this->GetName() << " supports Windows Store '8.0' and '8.1', " - "but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION."; + if(this->DefaultPlatformToolset.empty()) + { + e << this->GetName() << " supports Windows Store '8.0' and '8.1', but " + "not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION."; + } + else + { + e << "A Windows Store component with CMake requires both the Windows " + << "Desktop SDK as well as the Windows Store '" << this->SystemVersion + << "' SDK. Please make sure that you have both installed"; + } mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } @@ -139,23 +155,47 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf) } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset() const +bool +cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset( + std::string& toolset) const { if(this->SystemVersion == "8.1") { - return "v120_wp81"; + if (this->IsWindowsPhoneToolsetInstalled() && + this->IsWindowsDesktopToolsetInstalled()) + { + toolset = "v120_wp81"; + return true; + } + else + { + return false; + } } - return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(); + return + this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(toolset); } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset() const +bool +cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset( + std::string& toolset) const { if(this->SystemVersion == "8.1") { - return "v120"; + if(this->IsWindowsStoreToolsetInstalled() && + this->IsWindowsDesktopToolsetInstalled()) + { + toolset = "v120"; + return true; + } + else + { + return false; + } } - return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(); + return + this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(toolset); } //---------------------------------------------------------------------------- @@ -180,3 +220,46 @@ cmLocalGenerator *cmGlobalVisualStudio12Generator::CreateLocalGenerator() lg->SetGlobalGenerator(this); return lg; } + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const +{ + const char desktop81Key[] = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "VisualStudio\\12.0\\VC\\LibraryDesktop"; + + std::vector<std::string> subkeys; + return cmSystemTools::GetRegistrySubKeys(desktop81Key, + subkeys, + cmSystemTools::KeyWOW64_32); +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::IsWindowsPhoneToolsetInstalled() const +{ + const char wp81Key[] = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "Microsoft SDKs\\WindowsPhone\\v8.1\\Install Path;Install Path"; + + std::string path; + cmSystemTools::ReadRegistryValue(wp81Key, + path, + cmSystemTools::KeyWOW64_32); + return !path.empty(); +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::IsWindowsStoreToolsetInstalled() const +{ + const char win81Key[] = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "VisualStudio\\12.0\\VC\\Libraries\\Core\\Arm"; + + std::vector<std::string> subkeys; + return cmSystemTools::GetRegistrySubKeys(win81Key, + subkeys, + cmSystemTools::KeyWOW64_32); +} |