123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- macro(check_language lang)
- if(NOT DEFINED CMAKE_${lang}_COMPILER)
- set(_desc "Looking for a ${lang} compiler")
- message(STATUS ${_desc})
- file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
- "cmake_minimum_required(VERSION ${CMAKE_VERSION})
- project(Check${lang} ${lang})
- file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
- \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
- )
- ")
- execute_process(
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}
- COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
- OUTPUT_VARIABLE output
- ERROR_VARIABLE output
- RESULT_VARIABLE result
- )
- include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/result.cmake OPTIONAL)
- if(CMAKE_${lang}_COMPILER AND "${result}" STREQUAL "0")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "${_desc} passed with the following output:\n"
- "${output}\n")
- else()
- set(CMAKE_${lang}_COMPILER NOTFOUND)
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "${_desc} failed with the following output:\n"
- "${output}\n")
- endif()
- message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}")
- set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler")
- mark_as_advanced(CMAKE_${lang}_COMPILER)
- endif()
- endmacro()
|