From c65a060e1b19a463312f9003bc4d7793db9630e5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 18 Jun 2015 10:57:46 -0400 Subject: CMakeDetermineCompilerId: Optionally try some flags before no flags Teach CMAKE_DETERMINE_COMPILER_ID to optionally try detecting the compiler id using some given flags before trying to detect it with no special flags. This will be useful for Fortran detection to distinguish some compilers that use the preprocessors of others but have no macro of their own by getting verbose output. --- Modules/CMakeDetermineCCompiler.cmake | 1 + Modules/CMakeDetermineCXXCompiler.cmake | 1 + Modules/CMakeDetermineCompilerId.cmake | 4 +++- Modules/CMakeDetermineFortranCompiler.cmake | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 937aa8c..40d4ce6 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -80,6 +80,7 @@ else() # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce # a valid identification file. + set(CMAKE_C_COMPILER_ID_TEST_FLAGS_FIRST) set(CMAKE_C_COMPILER_ID_TEST_FLAGS # Try compiling to an object file only. "-c" diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 893c454..a673525 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -78,6 +78,7 @@ else() # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce # a valid identification file. + set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS_FIRST) set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS # Try compiling to an object file only. "-c" diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 403ac08..7ddf33f 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -34,7 +34,9 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Try building with no extra flags and then try each set # of helper flags. Stop when the compiler is identified. - foreach(flags "" ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) + foreach(flags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} + "" + ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) if(NOT CMAKE_${lang}_COMPILER_ID) CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}") foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 3a27127..ca68900 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -98,6 +98,7 @@ else() # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce # a valid identification executable. + set(CMAKE_Fortran_COMPILER_ID_TEST_FLAGS_FIRST) set(CMAKE_Fortran_COMPILER_ID_TEST_FLAGS # Try compiling to an object file only. "-c" -- cgit v0.12