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.
This commit is contained in:
Brad King 2015-06-18 10:57:46 -04:00
parent e2e6cb7348
commit c65a060e1b
4 changed files with 6 additions and 1 deletions

View File

@ -80,6 +80,7 @@ else()
# Each entry in this list is a set of extra flags to try # Each entry in this list is a set of extra flags to try
# adding to the compile line to see if it helps produce # adding to the compile line to see if it helps produce
# a valid identification file. # a valid identification file.
set(CMAKE_C_COMPILER_ID_TEST_FLAGS_FIRST)
set(CMAKE_C_COMPILER_ID_TEST_FLAGS set(CMAKE_C_COMPILER_ID_TEST_FLAGS
# Try compiling to an object file only. # Try compiling to an object file only.
"-c" "-c"

View File

@ -78,6 +78,7 @@ else()
# Each entry in this list is a set of extra flags to try # Each entry in this list is a set of extra flags to try
# adding to the compile line to see if it helps produce # adding to the compile line to see if it helps produce
# a valid identification file. # a valid identification file.
set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS_FIRST)
set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS
# Try compiling to an object file only. # Try compiling to an object file only.
"-c" "-c"

View File

@ -34,7 +34,9 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
# Try building with no extra flags and then try each set # Try building with no extra flags and then try each set
# of helper flags. Stop when the compiler is identified. # 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) if(NOT CMAKE_${lang}_COMPILER_ID)
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}") CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}")
foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) foreach(file ${COMPILER_${lang}_PRODUCED_FILES})

View File

@ -98,6 +98,7 @@ else()
# Each entry in this list is a set of extra flags to try # Each entry in this list is a set of extra flags to try
# adding to the compile line to see if it helps produce # adding to the compile line to see if it helps produce
# a valid identification executable. # a valid identification executable.
set(CMAKE_Fortran_COMPILER_ID_TEST_FLAGS_FIRST)
set(CMAKE_Fortran_COMPILER_ID_TEST_FLAGS set(CMAKE_Fortran_COMPILER_ID_TEST_FLAGS
# Try compiling to an object file only. # Try compiling to an object file only.
"-c" "-c"