[Cmake-commits] [cmake-commits] king committed CMakeDetermineCompilerId.cmake 1.19.4.2 1.19.4.3

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Feb 1 09:02:41 EST 2010


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv21584/Modules

Modified Files:
      Tag: CMake-2-8
	CMakeDetermineCompilerId.cmake 
Log Message:
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.


Index: CMakeDetermineCompilerId.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCompilerId.cmake,v
retrieving revision 1.19.4.2
retrieving revision 1.19.4.3
diff -C 2 -d -r1.19.4.2 -r1.19.4.3
*** CMakeDetermineCompilerId.cmake	28 Jan 2010 21:47:34 -0000	1.19.4.2
--- CMakeDetermineCompilerId.cmake	1 Feb 2010 14:02:39 -0000	1.19.4.3
***************
*** 43,46 ****
--- 43,51 ----
    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)
***************
*** 246,247 ****
--- 251,287 ----
    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)



More information about the Cmake-commits mailing list