From 5434547678223c79c18429f7b1c75d0634f60185 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 16 Feb 2023 00:05:16 +0300 Subject: LCC: Don't require liblfortran on lcc versions that don't have it There wasn't a liblfortran library before 1.24 (actually 1.24.01), and it is replaced by libgfortran in 1.26.03 and later. --- Modules/Platform/Linux-LCC-Fortran.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Platform/Linux-LCC-Fortran.cmake b/Modules/Platform/Linux-LCC-Fortran.cmake index bf2a1c2..166c06a 100644 --- a/Modules/Platform/Linux-LCC-Fortran.cmake +++ b/Modules/Platform/Linux-LCC-Fortran.cmake @@ -1,7 +1,7 @@ include(Platform/Linux-LCC) __linux_compiler_lcc(Fortran) -if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "1.26.03") - set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-llfortran") -else() +if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.26.03") set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-lgfortran") +elseif (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.24.01") + set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-llfortran") endif() -- cgit v0.12 From ea5f1f33fd5986a7858fa064cd747e09d372c63d Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 16 Feb 2023 03:53:14 +0300 Subject: LCC: Disable implicit testing of FortranCInterface LCC < 1.24 has unsupported mangling scheme: it changes 'sub' neither to 'sub' nor to 'SUB', but to 'Sub'. So we should explicitly check if FortranCInterface works in the case of LCC. --- Tests/Fortran/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 0fede25..30ab16b 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -49,7 +49,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft|Fujitsu") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft|Fujitsu|LCC") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) -- cgit v0.12 From 9f9d121ddb75e480660976555791e2cf3b61b1c9 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 16 Feb 2023 03:55:31 +0300 Subject: LCC: Disable Fortran preprocessor testing if unsupported LCC < 1.24 has no way to disable integrated Fortran preprocessor, and it can't produce preprocessed files explicitly. So we disable all functionality (and therefore tests) related to it. --- Modules/Compiler/LCC-Fortran.cmake | 7 +++++-- Modules/Platform/Linux-LCC-Fortran.cmake | 2 ++ Tests/FortranOnly/CMakeLists.txt | 17 ++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Modules/Compiler/LCC-Fortran.cmake b/Modules/Compiler/LCC-Fortran.cmake index 8091b29..2d82ea8 100644 --- a/Modules/Compiler/LCC-Fortran.cmake +++ b/Modules/Compiler/LCC-Fortran.cmake @@ -10,8 +10,11 @@ set(CMAKE_Fortran_PREPROCESS_SOURCE set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") -set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") -set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") +# LCC < 1.24.00 has a broken Fortran preprocessor +if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.24.00") + set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") + set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") +endif() set(CMAKE_Fortran_POSTPROCESS_FLAG "-fpreprocessed") diff --git a/Modules/Platform/Linux-LCC-Fortran.cmake b/Modules/Platform/Linux-LCC-Fortran.cmake index 166c06a..308c771 100644 --- a/Modules/Platform/Linux-LCC-Fortran.cmake +++ b/Modules/Platform/Linux-LCC-Fortran.cmake @@ -4,4 +4,6 @@ if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.26.03") set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-lgfortran") elseif (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.24.01") set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-llfortran") +else() + unset(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) endif() diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index fc71a18..d749fe1 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -152,13 +152,16 @@ if(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON AND set_property(SOURCE preprocess3.f PROPERTY Fortran_PREPROCESS ON) endif() -# Test that neither the compiler nor CMake performs unnecessary preprocessing. -add_library(no_preprocess_target_lower STATIC no_preprocess_target_lower.f) -target_compile_options(no_preprocess_target_lower PRIVATE -DINTEGER=nonsense) -set_property(TARGET no_preprocess_target_lower PROPERTY Fortran_PREPROCESS OFF) -add_library(no_preprocess_source_lower STATIC no_preprocess_source_lower.f) -target_compile_options(no_preprocess_source_lower PRIVATE -DINTEGER=nonsense) -set_property(SOURCE no_preprocess_source_lower.f PROPERTY Fortran_PREPROCESS OFF) +# LCC < 1.24 has no way to disable Fortran preprocessor +if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LCC" OR CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.24.00") + # Test that neither the compiler nor CMake performs unnecessary preprocessing. + add_library(no_preprocess_target_lower STATIC no_preprocess_target_lower.f) + target_compile_options(no_preprocess_target_lower PRIVATE -DINTEGER=nonsense) + set_property(TARGET no_preprocess_target_lower PROPERTY Fortran_PREPROCESS OFF) + add_library(no_preprocess_source_lower STATIC no_preprocess_source_lower.f) + target_compile_options(no_preprocess_source_lower PRIVATE -DINTEGER=nonsense) + set_property(SOURCE no_preprocess_source_lower.f PROPERTY Fortran_PREPROCESS OFF) +endif() # Test that we can explicitly not preprocess a target or source. # This will not work on certain compilers due to either missing a -- cgit v0.12