From 1e519df0259677df67b5e7d21e1f189d655ddbd3 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 15 Oct 2020 08:46:03 -0400 Subject: CheckSource{Runs,Compiles}: Fix default Fortran source extension In commit 357e2ef429 (CheckSoureRuns: Add a unified way to check if a source runs, 2020-09-14, v3.19.0-rc1~118^2), the default Fortran source file extension was accidentally changed from `.F90` to `.F`. Fix that. In commit 10ae907de0 (CheckSoureCompiles: Add a unified way to check if a source compiles, 2020-09-14, v3.19.0-rc1~118^2~1), the default Fortran source extension was correctly preserved as `.F`, but `.F90` is a better default both for consistency and modern usage. Use that for direct calls to the `check_source_compiles` macro. Update our original `check_fortran_source_compiles` implementation to use `.F` by default as it did before. Fixes: #21307 --- Modules/CheckFortranSourceCompiles.cmake | 4 +++- Modules/CheckFortranSourceRuns.cmake | 4 +++- Modules/CheckSourceCompiles.cmake | 9 ++++++--- Modules/CheckSourceRuns.cmake | 11 +++++++---- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index 2bcc343..169b829 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -90,5 +90,7 @@ include_guard(GLOBAL) include(CheckSourceCompiles) macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) - check_source_compiles(Fortran "${SOURCE}" ${VAR} ${ARGN}) + # Pass the SRC_EXT we used by default historically. + # A user-provided SRC_EXT argument in ARGN will override ours. + check_source_compiles(Fortran "${SOURCE}" ${VAR} SRC_EXT "F" ${ARGN}) endmacro() diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index 29f4a98..5276709 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -86,5 +86,7 @@ include_guard(GLOBAL) include(CheckSourceRuns) macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) - check_source_runs(Fortran "${SOURCE}" ${VAR} ${ARGN}) + # Pass the SRC_EXT we used by default historically. + # A user-provided SRC_EXT argument in ARGN will override ours. + check_source_runs(Fortran "${SOURCE}" ${VAR} SRC_EXT "F90" ${ARGN}) endmacro() diff --git a/Modules/CheckSourceCompiles.cmake b/Modules/CheckSourceCompiles.cmake index 08fc153..4ed9a5c 100644 --- a/Modules/CheckSourceCompiles.cmake +++ b/Modules/CheckSourceCompiles.cmake @@ -94,7 +94,7 @@ function(CHECK_SOURCE_COMPILES _lang _source _var) set(_lang_ext "cu") elseif(_lang STREQUAL Fortran) set(_lang_textual "Fortran") - set(_lang_ext "F") + set(_lang_ext "F90") elseif(_lang STREQUAL ISPC) set(_lang_textual "ISPC") set(_lang_ext "ispc") @@ -121,8 +121,11 @@ function(CHECK_SOURCE_COMPILES _lang _source _var) foreach(arg ${ARGN}) if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$") set(_key "${arg}") - elseif(_key) - list(APPEND _${_key} "${arg}") + elseif(_key STREQUAL "FAIL_REGEX") + list(APPEND _FAIL_REGEX "${arg}") + elseif(_key STREQUAL "SRC_EXT") + set(_SRC_EXT "${arg}") + set(_key "") else() message(FATAL_ERROR "Unknown argument:\n ${arg}\n") endif() diff --git a/Modules/CheckSourceRuns.cmake b/Modules/CheckSourceRuns.cmake index 20f3e1e..033793d 100644 --- a/Modules/CheckSourceRuns.cmake +++ b/Modules/CheckSourceRuns.cmake @@ -92,7 +92,7 @@ function(CHECK_SOURCE_RUNS _lang _source _var) set(_lang_ext "cu") elseif(_lang STREQUAL Fortran) set(_lang_textual "Fortran") - set(_lang_ext "F") + set(_lang_ext "F90") elseif(_lang STREQUAL OBJC) set(_lang_textual "Objective-C") set(_lang_ext "m") @@ -114,10 +114,13 @@ function(CHECK_SOURCE_RUNS _lang _source _var) set(_SRC_EXT) set(_key) foreach(arg ${ARGN}) - if("${arg}" MATCHES "^(SRC_EXT)$") + if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$") set(_key "${arg}") - elseif(_key) - list(APPEND _${_key} "${arg}") + elseif(_key STREQUAL "FAIL_REGEX") + list(APPEND _FAIL_REGEX "${arg}") + elseif(_key STREQUAL "SRC_EXT") + set(_SRC_EXT "${arg}") + set(_key "") else() message(FATAL_ERROR "Unknown argument:\n ${arg}\n") endif() -- cgit v0.12