CMakeDetermineCompilerId: Try matching compiler output to detect id
Some compilers can only be distinguished by their compilation output rather than preprocessor symbols or special flags. Add infrastructure to determine the compiler id by matching output.
This commit is contained in:
parent
5f0dad75a9
commit
0d204c1c1d
|
@ -38,6 +38,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
||||||
""
|
""
|
||||||
${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
|
${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
|
||||||
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}")
|
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}")
|
||||||
|
CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
|
||||||
|
if(CMAKE_${lang}_COMPILER_ID)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
foreach(file ${COMPILER_${lang}_PRODUCED_FILES})
|
foreach(file ${COMPILER_${lang}_PRODUCED_FILES})
|
||||||
CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
|
CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -358,6 +362,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
||||||
|
|
||||||
# No output files should be inspected.
|
# No output files should be inspected.
|
||||||
set(COMPILER_${lang}_PRODUCED_FILES)
|
set(COMPILER_${lang}_PRODUCED_FILES)
|
||||||
|
set(COMPILER_${lang}_PRODUCED_OUTPUT)
|
||||||
else()
|
else()
|
||||||
# Compilation succeeded.
|
# Compilation succeeded.
|
||||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
@ -398,10 +403,24 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
||||||
"${src}\" did not produce an executable in \""
|
"${src}\" did not produce an executable in \""
|
||||||
"${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n")
|
"${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(COMPILER_${lang}_PRODUCED_OUTPUT "${CMAKE_${lang}_COMPILER_ID_OUTPUT}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Return the files produced by the compilation.
|
# Return the files produced by the compilation.
|
||||||
set(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE)
|
set(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE)
|
||||||
|
set(COMPILER_${lang}_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Function to extract the compiler id from compiler output.
|
||||||
|
function(CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR lang output)
|
||||||
|
foreach(vendor ${CMAKE_${lang}_COMPILER_ID_MATCH_VENDORS})
|
||||||
|
if(output MATCHES "${CMAKE_${lang}_COMPILER_ID_MATCH_VENDOR_REGEX_${vendor}}")
|
||||||
|
set(CMAKE_${lang}_COMPILER_ID "${vendor}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue