From e4201248ce76be40c109b67e68a4e295d709e2dc Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 4 Dec 2013 10:36:18 -0500 Subject: 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). --- Modules/CMakeDetermineCompilerId.cmake | 37 +++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 7fa4534..93358c7 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -154,24 +154,33 @@ Id flags: ${testflags} else() set(id_subsystem 1) 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}) get_filename_component(id_src "${src}" NAME) configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in ${id_dir}/CompilerId${lang}.${ext} @ONLY) - 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 - ) + 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( + COMMAND ${command} + 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 + ) + 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. if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]") # Strip VS diagnostic output from the end of the line. -- cgit v0.12