[CMake] CMake doesn't detect Microsoft Build Tools 2015 on Windows 10

Gilles Khouzam gilles.khouzam at microsoft.com
Mon Oct 10 11:35:58 EDT 2016


Please open a bug, I can take a look at it.

From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Eduard Wirch
Sent: Monday, October 10, 2016 02:41
To: cmake at cmake.org
Subject: [CMake] CMake doesn't detect Microsoft Build Tools 2015 on Windows 10

Hi

I've installed build tools from here: http://landinghub.visualstudio.com/visual-cpp-build-tools
But CMake will automatically detect (and choose) Visual Studio 8 (installed here as well) instead.

Looking into the source:

    const std::string vsregBase =
      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\";
    std::vector<std::string> vsVerions;
    vsVerions.push_back("VisualStudio\\");
    vsVerions.push_back("VCExpress\\");
    vsVerions.push_back("WDExpress\\");
    struct VSRegistryEntryName
    {
      const char* MSVersion;
      const char* GeneratorName;
    };
    VSRegistryEntryName version[] = {
      /* clang-format needs this comment to break after the opening brace */
      { "7.1", "Visual Studio 7 .NET 2003" },
      { "8.0", "Visual Studio 8 2005" },
      { "9.0", "Visual Studio 9 2008" },
      { "10.0", "Visual Studio 10 2010" },
      { "11.0", "Visual Studio 11 2012" },
      { "12.0", "Visual Studio 12 2013" },
      { "14.0", "Visual Studio 14 2015" },
      { "15.0", "Visual Studio 15" },
      { 0, 0 }
    };
    for (int i = 0; version[i].MSVersion != 0; i++) {
      for (size_t b = 0; b < vsVerions.size(); b++) {
        std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion;
        reg += ";InstallDir]";
        cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32);
        if (!(reg == "/registry")) {
          installedCompiler = version[i].GeneratorName;
          break;
        }
      }
    }

CMake will look for 'HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\InstallDir'. This key is not present indeed. When specified explicitly:
    cmake . -G "Visual Studio 14 2015"
CMake will correctly detect the compiler and build without problems.

These keys might be helpful when looking for Build Tools:

    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\Setup\VC]
    "ProductDir"="C:\\Program Files (x86)\\Microsoft<file://Microsoft> Visual Studio 14.0\\VC\\"

    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\Setup\SSDT]
    "InstallDir"="C:\\Program Files (x86)\\Microsoft<file://Microsoft> Visual Studio 14.0\\"
    "VersionNumber"="14.0.50616.0"

Am I missing something or is this a bug which should be reported to issue tracker?

Cheers,
Eduard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161010/c5fb4cd2/attachment.html>


More information about the CMake mailing list