diff options
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 14 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio15Generator.cxx | 48 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio15Generator.h | 5 | ||||
-rw-r--r-- | Source/cmake.cxx | 30 |
4 files changed, 59 insertions, 38 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index dde6e82..e27615a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -425,20 +425,6 @@ std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand() } } - // Search where VS15Preview places it. - mskey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;"; - mskey += this->GetIDEVersion(); - if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild, - cmSystemTools::KeyWOW64_32)) { - cmSystemTools::ConvertToUnixSlashes(msbuild); - msbuild += "/MSBuild/"; - msbuild += this->GetIDEVersion(); - msbuild += "/Bin/MSBuild.exe"; - if (cmSystemTools::FileExists(msbuild, true)) { - return msbuild; - } - } - msbuild = "MSBuild.exe"; return msbuild; } diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index 4299081..d11ee7c 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -8,6 +8,7 @@ #include "cmMakefile.h" #include "cmVS141CLFlagTable.h" #include "cmVS141CSharpFlagTable.h" +#include "cmVSSetupHelper.h" static const char vs15generatorName[] = "Visual Studio 15 2017"; @@ -126,21 +127,44 @@ bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset( bool cmGlobalVisualStudio15Generator::IsWindowsDesktopToolsetInstalled() const { - const char desktop10Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" - "VisualStudio\\15.0\\VC\\Runtimes"; - - std::vector<std::string> vc15; - return cmSystemTools::GetRegistrySubKeys(desktop10Key, vc15, - cmSystemTools::KeyWOW64_32); + return vsSetupAPIHelper.IsVS2017Installed(); } bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const { - const char universal10Key[] = - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" - "VisualStudio\\15.0\\Setup\\Build Tools for Windows 10;SrcPath"; + return vsSetupAPIHelper.IsWin10SDKInstalled(); +} + +std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand() +{ + std::string msbuild; + + // Ask Visual Studio Installer tool. + std::string vs; + if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } + } + + msbuild = "MSBuild.exe"; + return msbuild; +} + +std::string cmGlobalVisualStudio15Generator::FindDevEnvCommand() +{ + std::string devenv; + + // Ask Visual Studio Installer tool. + std::string vs; + if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + devenv = vs + "/Common7/IDE/devenv.com"; + if (cmSystemTools::FileExists(devenv)) { + return devenv; + } + } - std::string win10SDK; - return cmSystemTools::ReadRegistryValue(universal10Key, win10SDK, - cmSystemTools::KeyWOW64_32); + devenv = "devenv.com"; + return devenv; } diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h index 59eb11a..781b41e 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudio15Generator.h @@ -9,6 +9,7 @@ #include <string> #include "cmGlobalVisualStudio14Generator.h" +#include "cmVSSetupHelper.h" class cmGlobalGeneratorFactory; class cmake; @@ -39,7 +40,11 @@ protected: // of the toolset is installed bool IsWindowsStoreToolsetInstalled() const; + std::string FindMSBuildCommand() CM_OVERRIDE; + std::string FindDevEnvCommand() CM_OVERRIDE; + private: class Factory; + mutable cmVSSetupAPIHelper vsSetupAPIHelper; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 733e0e4..6141f50 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -64,6 +64,7 @@ #include "cmGlobalVisualStudio71Generator.h" #include "cmGlobalVisualStudio8Generator.h" #include "cmGlobalVisualStudio9Generator.h" +#include "cmVSSetupHelper.h" #define CMAKE_HAVE_VS_GENERATORS #endif @@ -1470,18 +1471,23 @@ void cmake::CreateDefaultGlobalGenerator() "\\Setup\\VC;ProductDir", // ";InstallDir" // }; - for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators); - found.empty() && g != cmArrayEnd(vsGenerators); ++g) { - for (const char* const* v = cmArrayBegin(vsVariants); - found.empty() && v != cmArrayEnd(vsVariants); ++v) { - for (const char* const* e = cmArrayBegin(vsEntries); - found.empty() && e != cmArrayEnd(vsEntries); ++e) { - std::string const reg = vsregBase + *v + g->MSVersion + *e; - std::string dir; - if (cmSystemTools::ReadRegistryValue(reg, dir, - cmSystemTools::KeyWOW64_32) && - cmSystemTools::PathExists(dir)) { - found = g->GeneratorName; + cmVSSetupAPIHelper vsSetupAPIHelper; + if (vsSetupAPIHelper.IsVS2017Installed()) { + found = "Visual Studio 15 2017"; + } else { + for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators); + found.empty() && g != cmArrayEnd(vsGenerators); ++g) { + for (const char* const* v = cmArrayBegin(vsVariants); + found.empty() && v != cmArrayEnd(vsVariants); ++v) { + for (const char* const* e = cmArrayBegin(vsEntries); + found.empty() && e != cmArrayEnd(vsEntries); ++e) { + std::string const reg = vsregBase + *v + g->MSVersion + *e; + std::string dir; + if (cmSystemTools::ReadRegistryValue(reg, dir, + cmSystemTools::KeyWOW64_32) && + cmSystemTools::PathExists(dir)) { + found = g->GeneratorName; + } } } } |