From 7e8f76dad2c528cf1d6a59654229bb587855e4d0 Mon Sep 17 00:00:00 2001 From: Christopher Albert Date: Sat, 13 Sep 2025 23:09:50 +0200 Subject: [PATCH] LFortran: Update flags renamed by version 0.55 The `--generate-object-code` flag is now `--separate-compilation`. Fixes: #27225 --- Modules/FortranCInterface/CMakeLists.txt | 7 ++++++- Modules/FortranCInterface/Verify/CMakeLists.txt | 7 ++++++- Tests/Fortran/CMakeLists.txt | 7 ++++++- Tests/FortranOnly/CMakeLists.txt | 7 ++++++- Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt | 7 ++++++- Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt | 7 ++++++- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index af7d32d27f..cabbb32b6a 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -104,7 +104,12 @@ target_link_libraries(symbols PUBLIC myfort) set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # Require symbols through Fortran. diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt index 7367968825..04fa6aa4ee 100644 --- a/Modules/FortranCInterface/Verify/CMakeLists.txt +++ b/Modules/FortranCInterface/Verify/CMakeLists.txt @@ -5,7 +5,12 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(VerifyFortranC C Fortran) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options("$<$:--generate-object-code>") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options("$<$:${_LFORTRAN_SC_FLAG}>") endif() option(VERIFY_CXX "Whether to verify C++ and Fortran" OFF) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index ce36829a37..4769ab22ea 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -38,7 +38,12 @@ if(WIN32 AND NOT CYGWIN) endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options("$<$:--implicit-interface;--generate-object-code>") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options("$<$:--implicit-interface;${_LFORTRAN_SC_FLAG}>") endif() add_library(hello STATIC hello.f) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index d32c3bdff6..a59cf83675 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -9,7 +9,12 @@ if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(L endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # create a library with hello and world functions diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index 4d03a93891..3017898e24 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -4,7 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() include(CheckIPOSupported) diff --git a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt index 5689289b78..9080c24d61 100644 --- a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt @@ -26,7 +26,12 @@ target_link_libraries(sunq sunquad) endfunction() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # check for the fortran c interface mangling