Re: [CMake] Wrong cl.exe getting picked up
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 Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Wrong cl.exe getting picked up
On Thu, Mar 15, 2012 at 6:46 AM, Bill Hoffman bill.hoff...@kitware.comwrote: 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.htmlhttp://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/**CMake_FAQhttp://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/**listinfo/cmakehttp://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 -- Powered by www.kitware.com Visit other Kitware open-source projects at 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 Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Wrong cl.exe getting picked up
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? CMAKE_C_COMPILER is not used for Visual Studio targets -- Powered by www.kitware.com Visit other Kitware open-source projects at 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 Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Wrong cl.exe getting picked up
On Thu, Mar 15, 2012 at 1:30 PM, John Drescher dresche...@gmail.com wrote: 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? CMAKE_C_COMPILER is not used for Visual Studio targets If that's the case then the value should never be defined or defined to something like CMAKE_C_COMPILER-NOTFOUND or CMAKE_C_COMPILER-NOTUSEDFORVISUALSTUDIO. This behavior isn't documented anywhere, and even if it was documented it's confusing to have the system define variables that it will never use. James -- Powered by www.kitware.com Visit other Kitware open-source projects at 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 Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake