At the first CMake configure time, CMake will try to determine the CXXCompiler variables and flags (files, Paths, filePaths, version ID, and some boolean values…) to use. That’s why you have to launch CMake from the correct commandPrompt (visual studio 2008 command prompt to load the VC9 environnement variable and allow cmake to find it).
CMake define the CMAKE_MAKE_PROGRAM variable from CMakeVS<visual-studio-version-major>FindMake.cmake for visual studio (this file is in the common cmake scripts dir in its installation dir). and it is set to :
CMAKE_MAKE_PROGRAM = devenv
(by default the first found is devenv.com but there is also a devenv.exe)
In some case…. I don’t know very well why at this moment (maybe a corrupt installation…), but the devenv.com doesn’t work. Try to launch devenv or devenv.com /? from a visual studio command prompt do absolutly nothing…
That’s why CMake can’t continue to find CXXCompiler and linker variables…
Because in CMakeDetermineCompilerId.cmake (in CMAKE_DETERMINE_COMPILER_ID_BUILD function ) CMake try to compile a source file with devenv.com in order to extract the final output and determine the required cmake variables.
This is a VISUAL STUDIO or Microsoft problem !!!!
But in order to allow CMake to find and use visual studio compiler, we have to do some changes :
1- First, in CMakeVS<visual-studio-version-major>FindMake.cmake (for me it was CMakeVS71FindMake.cmake) we have to be sure to find the devenv.exe and not the devenv.com :
So replace the « devenv » name pattern by the « devenv.exe » name pattern in the find_program(…).
One of the differences between devenv.com and devenv.exe is that devenv.com auto redirect full output to the console whereas devenv.exe not.
2- Next, in CMakeDetermineCompilerId.cmake, in CMAKE_DETERMINE_COMPILER_ID_BUILD function (lin 157) :
replace :
execute_process(
COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build}
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
)
by :
execute_process(
COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build} /Out log.txt
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
)
if(NOT CMAKE_${lang}_COMPILER_ID_OUTPUT)
message(« From CMakeDetermineCompilerID (line 165) : change the CMAKE_${lang}_COMPILER_ID_OUTPUT.)
file(READ ${CMAKE_${lang}_COMPILER_ID_DIR}/log.txt CMAKE_${lang}_COMPILER_ID_OUTPUT)
endif()
Then try to launch CMake…