Merge topic 'FortranCInterface-gcc12' into release-3.23

cb616d43d6 FortranCInterface: Fix failure with gfortran 12 and Clang

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7266
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
index ce0bc10..fb35ff0 100644
--- a/Modules/FortranCInterface/CMakeLists.txt
+++ b/Modules/FortranCInterface/CMakeLists.txt
@@ -112,6 +112,9 @@
   CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
   target_compile_options(FortranCInterface PRIVATE "-fno-lto")
   target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects")
+endif()
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
+  CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
   target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects")
 endif()