I have a system with several copies of Visual Studio installed.<br><br>When I set the generator for "Visual Studio 9 2008" 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't figure out how it'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 "C compiler" 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 "C compiler")</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 "${CMAKE_C_COMPILER_INIT}" CACHE FILEPATH "C compiler" 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 "cl" as is the default of CMAKE_GENERATOR_CC for VS generators.<br>
<br>Typically VS isn't in the default path, so the first two FIND_PROGRAM commands don't yield any usable results. Then the next block sets the CMAKE_C_COMPILER to "cl", and everything is OK, because if it'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'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'm using CMake 2.8.2 and 2.8.6 on windows.<br><br>James<br><br>