Commit c65a060e authored by Brad King's avatar Brad King
Browse files

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.
parent e2e6cb73
......@@ -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"
......
......@@ -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"
......
......@@ -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})
......
......@@ -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"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment