<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi: I’m trying to create a 64-bit Visual Studio 12 (aka 2013) project with CMake 3.0.2. My CMakeLists.txt file is really simple:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">cmake_minimum_required( VERSION 3.0 )<o:p></o:p></p>
<p class="MsoNormal">project( cmc CXX )<o:p></o:p></p>
<p class="MsoNormal"># What compiler did we find?<o:p></o:p></p>
<p class="MsoNormal">message( "C++: ${CMAKE_CXX_COMPILER}" )<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">From a windows shell I do:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat<o:p></o:p></p>
<p class="MsoNormal">> cmake –G “Visual Studio 12 Win64” .<o:p></o:p></p>
<p class="MsoNormal">-- The CXX compiler identification is MSVC 18.0.31101.0<o:p></o:p></p>
<p class="MsoNormal">-- Check for working CXX compiler using: Visual Studio 12 2013 Win64<o:p></o:p></p>
<p class="MsoNormal">-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works<o:p></o:p></p>
<p class="MsoNormal">-- Detecting CXX compiler ABI info<o:p></o:p></p>
<p class="MsoNormal">-- Detecting CXX compiler ABI info - done<o:p></o:p></p>
<p class="MsoNormal">C++: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe<o:p></o:p></p>
<p class="MsoNormal">-- Configuring done<o:p></o:p></p>
<p class="MsoNormal">-- Generating done<o:p></o:p></p>
<p class="MsoNormal">-- Build files have been written to: C:/Users/dbarnett/cmc/build<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, it appears to find the compiler OK since it emits the correct compiler identification. But, the actual value of CMAKE_CXX_COMPILER is not usable. If you try to execute C:/Program…./x86_amd64/cl.exe from within a CMake script or even
 from the command line, it will fail and produce the well-known “0xc000007b” dialog (missing DLL). Unless you’ve sourced vcvarsx86_amd64.bat, the correct environment variables are not set for this version of the compiler.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On the other hand, if I do “cmake –G NMake Makefiles”, I get what I expect:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-- The CXX compiler identification is MSVC 18.0.31101.0<o:p></o:p></p>
<p class="MsoNormal">-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe<o:p></o:p></p>
<p class="MsoNormal">-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe -- works<o:p></o:p></p>
<p class="MsoNormal">-- Detecting CXX compiler ABI info<o:p></o:p></p>
<p class="MsoNormal">-- Detecting CXX compiler ABI info - done<o:p></o:p></p>
<p class="MsoNormal">C++: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe<o:p></o:p></p>
<p class="MsoNormal">-- Configuring done<o:p></o:p></p>
<p class="MsoNormal">-- Generating done<o:p></o:p></p>
<p class="MsoNormal">-- Build files have been written to: C:/Users/dbarnett/cmc/other<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Namely, it finds C:/Program…./amd64/cl.exe.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve looked through the CMake Modules, but I could not really find the place where CMake derives the value for CMAKE_CXX_COMPILER when you generate a VS project. Could someone point me to the source code where this occurs? I would like
 to see how it is coming up with this version of the compiler which isn’t even in the PATH.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Allen<o:p></o:p></p>
</div>
</body>
</html>