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.
This commit is contained in:
makise-homura 2023-02-16 03:55:31 +03:00
parent ea5f1f33fd
commit 9f9d121ddb
3 changed files with 17 additions and 9 deletions

View File

@ -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")

View File

@ -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()

View File

@ -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