summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerId.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-02-01 14:03:05 (GMT)
committerBrad King <brad.king@kitware.com>2010-02-01 14:03:05 (GMT)
commit3c2ecbe74eb0d01dc276b98b1307b2580b81adc6 (patch)
treec0d14b0e92bd71a7b54d47bf256f020f09c9ba32 /Modules/CMakeDetermineCompilerId.cmake
parent17e5e5fcb0d92a9a2a6e94be57499f92e90dd1ba (diff)
downloadCMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.zip
CMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.tar.gz
CMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.tar.bz2
Add alternate per-vendor compiler id detection
At least one Fortran compiler does not provide a preprocessor symbol to identify itself. Instead we try running unknown compilers with version query flags known for each vendor and look for known output. Future commits will add vendor-specific flags/output table entries.
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index a70c6ab..bddd6a1 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -42,6 +42,11 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
ENDIF(NOT CMAKE_${lang}_COMPILER_ID)
ENDFOREACH(flags)
+ # If the compiler is still unknown, try to query its vendor.
+ IF(NOT CMAKE_${lang}_COMPILER_ID)
+ CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang})
+ ENDIF()
+
# if the format is unknown after all files have been checked, put "Unknown" in the cache
IF(NOT CMAKE_EXECUTABLE_FORMAT)
SET(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format")
@@ -245,3 +250,38 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
PARENT_SCOPE)
SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE)
ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang)
+
+#-----------------------------------------------------------------------------
+# Function to query the compiler vendor.
+# This uses a table with entries of the form
+# list(APPEND CMAKE_${lang}_COMPILER_ID_VENDORS ${vendor})
+# set(CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor} -some-vendor-flag)
+# set(CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor} "Some Vendor Output")
+# We try running the compiler with the flag for each vendor and
+# matching its regular expression in the output.
+FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang)
+ FOREACH(vendor ${CMAKE_${lang}_COMPILER_ID_VENDORS})
+ SET(flags ${CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor}})
+ SET(regex ${CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor}})
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_${lang}_COMPILER}
+ ${CMAKE_${lang}_COMPILER_ID_ARG1}
+ ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}
+ ${flags}
+ WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
+ OUTPUT_VARIABLE output ERROR_VARIABLE output
+ RESULT_VARIABLE result
+ )
+ IF("${output}" MATCHES "${regex}")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
+ "matched \"${regex}\":\n${output}")
+ SET(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
+ BREAK()
+ ELSE()
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
+ "did not match \"${regex}\":\n${output}")
+ ENDIF()
+ ENDFOREACH()
+ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR)