I have a system with several copies of Visual Studio installed.<br><br>When I set the generator for &quot;Visual Studio 9 2008&quot; it ends up picking up a different compiler:<br><br>CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/SCE/Common/VSI/bin/cl.exe<br>

<br>I think this is because of the following code in CMakeDetermineCCompiler.cmake (which I can&#39;t figure out how it&#39;s invokes by the cmake-gui or cmake.exe):<br><br><span style="font-family:courier new,monospace">  # Find the compiler.</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  IF (_CMAKE_USER_CXX_COMPILER_PATH)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} PATHS ${_CMAKE_USER_CXX_COMPILER_PATH} DOC &quot;C compiler&quot; NO_DEFAULT_PATH)</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  ENDIF (_CMAKE_USER_CXX_COMPILER_PATH)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} DOC &quot;C compiler&quot;)</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  IF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    SET(CMAKE_C_COMPILER &quot;${CMAKE_C_COMPILER_INIT}&quot; CACHE FILEPATH &quot;C compiler&quot; FORCE)</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  ENDIF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)</span><br><br>I believe the CMAKE_C_COMPILER_LIST contains &quot;cl&quot; as is the default of CMAKE_GENERATOR_CC for VS generators.<br>

<br>Typically VS isn&#39;t in the default path, so the first two FIND_PROGRAM commands don&#39;t yield any usable results.  Then the next block sets the CMAKE_C_COMPILER to &quot;cl&quot;, and everything is OK, because if it&#39;s run from within the project, VS sets the paths so its cl.exe is first.<br>

<br>However if there is another cl.exe in the system PATH, then that version will get picked up by the second FIND_PROGRAM, and thus cause a bit of trouble later on when the copies of cl.exe aren&#39;t the same.<br><br>Does this seem like a bug to anyone?  It seems like if you would want cl to point to the same version as your copy of Visual Studio.  Perhaps $(VCInstallDir) could be used with a custom command to generate what VS thinks the path should be?<br>

<br>Anyone have any thoughts?<br><br>I&#39;m using CMake 2.8.2 and 2.8.6 on windows.<br><br>James<br><br>