From 6e366213cec605fdbe68ab035a43484514258fb0 Mon Sep 17 00:00:00 2001 From: Miles Curry <2590700+MiCurry@users.noreply.github.com> Date: Mon, 9 Feb 2026 17:52:57 -0700 Subject: [PATCH] Update f90/CMakeLists.txt to only use Fortran flags for Fortran files Before, several flags were being specified for the ModEM target that were not properly being wrapped in a CMake generator expression. Currently this is not a problem at all, but it would prevent any C files to be included, as CMake will try to use these flags when compiling a C file. This will prevent that issue occurring if a C file is added in the future. --- f90/CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/f90/CMakeLists.txt b/f90/CMakeLists.txt index 9f7ba414..2ebaed8c 100644 --- a/f90/CMakeLists.txt +++ b/f90/CMakeLists.txt @@ -20,13 +20,14 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") target_compile_options( ${MODEM_EXE} PRIVATE - -cpp -ffree-line-length-none -fallow-argument-mismatch $<$:-O3> - $<$:-O0> $<$:-g> - $<$:-fbacktrace> - $<$:-fbounds-check> + $<$:-cpp> + $<$:-ffree-line-length-none> + $<$:-fallow-argument-mismatch> + $<$,$>:-fbacktrace> + $<$,$>:-fbounds-check> ) elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") enable_language(C) @@ -38,17 +39,17 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") target_compile_options( ${MODEM_EXE} PRIVATE - -fpp - -parallel $<$:-O3> $<$:-w> $<$:-O0> - $<$:-fp-stack-check> - $<$:-g> - $<$:-traceback> - $<$:-debug extend> - $<$:-check bounds> + $<$:-g> + $<$:-fpp> + $<$:-parallel> $<$:-heap-array> + $<$,$>:-fp-stack-check> + $<$,$>:-traceback> + $<$,$>:-debug extend> + $<$,$>:-check bounds> ) target_link_libraries( ${MODEM_EXE} @@ -64,7 +65,7 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") -qopenmp ) else() - message(FATAL_ERROR "Unknown/Unsupported Fortran Compiler: '${CMake_Fortran_COMPILER_ID}' - Supported compilers are < GNU | Ifort") + message(FATAL_ERROR "Unknown/Unsupported Fortran Compiler: '${CMAKE_Fortran_COMPILER_ID}' - Supported compilers are < GNU | Ifort") endif()