[CMake] Wrong cl.exe getting picked up

James Bigler jamesbigler at gmail.com
Thu Mar 15 15:22:54 EDT 2012


On Thu, Mar 15, 2012 at 6:46 AM, Bill Hoffman <bill.hoffman at kitware.com>wrote:

> On 3/14/2012 6:39 PM, James Bigler wrote:
>
>> I have a system with several copies of Visual Studio installed.
>>
>> When I set the generator for "Visual Studio 9 2008" it ends up picking
>> up a different compiler:
>>
>> CMAKE_C_COMPILER:FILEPATH=C:/**Program Files (x86)/SCE/Common/VSI/bin/cl.
>> **exe
>>
>> 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):
>>
>>   # Find the compiler.
>>   IF (_CMAKE_USER_CXX_COMPILER_**PATH)
>>     FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} PATHS
>> ${_CMAKE_USER_CXX_COMPILER_**PATH} DOC "C compiler" NO_DEFAULT_PATH)
>>   ENDIF (_CMAKE_USER_CXX_COMPILER_**PATH)
>>   FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} DOC "C
>> compiler")
>>
>>   IF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)
>>     SET(CMAKE_C_COMPILER "${CMAKE_C_COMPILER_INIT}" CACHE FILEPATH "C
>> compiler" FORCE)
>>   ENDIF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)
>>
>> I believe the CMAKE_C_COMPILER_LIST contains "cl" as is the default of
>> CMAKE_GENERATOR_CC for VS generators.
>>
>> 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.
>>
>> 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.
>>
>> 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?
>>
>> Anyone have any thoughts?
>>
>> I'm using CMake 2.8.2 and 2.8.6 on windows.
>>
>>
> So, with the IDE generators CMake should not even look for cl.  It does
> not use that value anyway.
>
> -Bill
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>

OK, but it does try to fill in the CMAKE_C_COMPILER value.  What are you
suggesting?  That this is a bug or some kind of mistake on my part thinking
that the value in CMAKE_C_COMPILER is somehow relevant for Visual Studio
targets?

Thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120315/ace47613/attachment.htm>


More information about the CMake mailing list