CMakeDetermineCompilerId: Use CMAKE_VS_(DEVENV|MSBUILD|MSDEV)_COMMAND

In the code path for launching the VS IDE tools, avoid using
CMAKE_MAKE_PROGRAM.  Instead use the variables CMAKE_VS_DEVENV_COMMAND,
CMAKE_VS_MSBUILD_COMMAND, and CMAKE_VS_MSDEV_COMMAND to lookup the
location of the build tool needed.  Choose the proper tool based on
availability and necessity for the language (e.g. Intel Fortran must
build with devenv.com and not MSBuild.exe).
This commit is contained in:
Brad King 2013-12-04 10:36:18 -05:00
parent 0c55729c13
commit e4201248ce
1 changed files with 23 additions and 14 deletions

View File

@ -154,24 +154,33 @@ Id flags: ${testflags}
else() else()
set(id_subsystem 1) set(id_subsystem 1)
endif() endif()
if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]")
set(build /p:Configuration=Debug /p:Platform=@id_platform@ /p:VisualStudioVersion=${vs_version}.0)
elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]")
set(build /make)
else()
set(build /build Debug)
endif()
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
get_filename_component(id_src "${src}" NAME) get_filename_component(id_src "${src}" NAME)
configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in
${id_dir}/CompilerId${lang}.${ext} @ONLY) ${id_dir}/CompilerId${lang}.${ext} @ONLY)
if(CMAKE_VS_MSBUILD_COMMAND AND NOT lang STREQUAL "Fortran")
set(command "${CMAKE_VS_MSBUILD_COMMAND}" "CompilerId${lang}.${ext}"
"/p:Configuration=Debug" "/p:Platform=${id_platform}" "/p:VisualStudioVersion=${vs_version}.0"
)
elseif(CMAKE_VS_DEVENV_COMMAND)
set(command "${CMAKE_VS_DEVENV_COMMAND}" "CompilerId${lang}.${ext}" "/build" "Debug")
elseif(CMAKE_VS_MSDEV_COMMAND)
set(command "${CMAKE_VS_MSDEV_COMMAND}" "CompilerId${lang}.${ext}" "/make")
else()
set(command "")
endif()
if(command)
execute_process( execute_process(
COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build} COMMAND ${command}
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
) )
else()
set(CMAKE_${lang}_COMPILER_ID_RESULT 1)
set(CMAKE_${lang}_COMPILER_ID_OUTPUT "VS environment not known to support ${lang}")
endif()
# Match the compiler location line printed out. # Match the compiler location line printed out.
if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]") if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]")
# Strip VS diagnostic output from the end of the line. # Strip VS diagnostic output from the end of the line.