From 765a611956e58d763af4557b92115d3a451abff9 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 13 Mar 2024 14:01:49 +0100 Subject: NAG-Fortran: Added initial default compilation flags The configuration of the NAG Fortran compiler was previously missing the standard flags for debug, release and the other build types. --- Modules/Compiler/NAG-Fortran.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index b946cfd..a843001 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -28,6 +28,13 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED) endif() endif() +# Initial configuration flags. +string(APPEND CMAKE_Fortran_FLAGS_INIT " ") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -O2 -DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O4 -DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") + set(CMAKE_Fortran_SUBMODULE_SEP ".") set(CMAKE_Fortran_SUBMODULE_EXT ".sub") set(CMAKE_Fortran_MODDIR_FLAG "-mdir ") -- cgit v0.12 From e056006116b90b54e5e1e02a43eea84913585eb1 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 13 Mar 2024 14:01:49 +0100 Subject: NAG-Fortran: Tell the Ninja generator how to preprocess Fortran sources Fixes: #21398 --- Modules/Compiler/NAG-Fortran.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index a843001..a6636c4 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -46,3 +46,6 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC") set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-PIC") set(CMAKE_Fortran_RESPONSE_FILE_LINK_FLAG "-Wl,@") set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-fpp") + +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -fpp -F -o ") -- cgit v0.12 From 91bb8dd872ca3a7f1a9d458217ff81124e1983de Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 13 Mar 2024 15:33:49 +0100 Subject: NAG-Fortran: Fix MODULE library creation on Apple platforms Previously we passed `-bundle` to the NAG Fortran front-end, which does not support it. Pass it through to the linker instead. --- Modules/Platform/Apple-NAG-Fortran.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Platform/Apple-NAG-Fortran.cmake b/Modules/Platform/Apple-NAG-Fortran.cmake index 8d3e741..0836e1c 100644 --- a/Modules/Platform/Apple-NAG-Fortran.cmake +++ b/Modules/Platform/Apple-NAG-Fortran.cmake @@ -9,6 +9,7 @@ set(CMAKE_Fortran_COMPILE_OBJECT set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version -Wl,") set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version -Wl,") +set(CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS "-Wl,-bundle") set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-Wl,-shared") set(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,-install_name -Wl,") set(CMAKE_Fortran_CREATE_SHARED_LIBRARY -- cgit v0.12 From 4af20bb7940bbbfb624a231b6394a996f5dd755a Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 13 Mar 2024 15:33:49 +0100 Subject: NAG-Fortran: Do not repeat preprocessing with Ninja on Apple platforms The Ninja generator uses separate preprocessing and compilation steps. Do not pass `-fpp` when compiling an already-preprocessed source. Issue: #25900 --- Modules/Platform/Apple-NAG-Fortran.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Modules/Platform/Apple-NAG-Fortran.cmake b/Modules/Platform/Apple-NAG-Fortran.cmake index 0836e1c..828d7ab 100644 --- a/Modules/Platform/Apple-NAG-Fortran.cmake +++ b/Modules/Platform/Apple-NAG-Fortran.cmake @@ -3,9 +3,13 @@ set(CMAKE_Fortran_VERBOSE_FLAG "-Wl,-v") # Runs gcc under the hood. -# Need -fpp explicitly on case-insensitive filesystem. -set(CMAKE_Fortran_COMPILE_OBJECT - " -fpp -o -c ") +# FIXME(#25900): We need -fpp explicitly on case-insensitive filesystems, +# but this does not work with the Ninja generator's separate preprocessing +# and compilation steps. +if(NOT CMAKE_GENERATOR MATCHES "^Ninja") + set(CMAKE_Fortran_COMPILE_OBJECT + " -fpp -o -c ") +endif() set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version -Wl,") set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version -Wl,") -- cgit v0.12