
This was added in commit 98d0f918ba
(LFortran: Add support for this
compiler, 2024-01-25, v3.31.0-rc1~303^2~2) because it is needed for
cases covered by CMake's Fortran tests. However, it does not work
with Fortran modules and breaks lfortran's own `examples/project1`.
Move the flag to the test cases that need it, just as the original
commit did with `--implicit-interface`.
Fixes: #26597
Co-authored-by: Brad King <brad.king@kitware.com>
25 lines
814 B
CMake
25 lines
814 B
CMake
cmake_minimum_required(VERSION 3.10)
|
|
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)
|
|
endif()
|
|
|
|
include(CheckIPOSupported)
|
|
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
|
|
if(ipo_supported)
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
elseif(CMake_TEST_IPO_WORKS_Fortran)
|
|
string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
|
|
message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
|
|
endif()
|
|
|
|
add_library(foo foo.f)
|
|
add_executable(CheckIPOSupported-Fortran main.f)
|
|
target_link_libraries(CheckIPOSupported-Fortran PUBLIC foo)
|
|
|
|
enable_testing()
|
|
add_test(NAME CheckIPOSupported-Fortran COMMAND CheckIPOSupported-Fortran)
|