Debian Codegraph @

Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.10)
2 project(CheckIPOSupported-Fortran LANGUAGES Fortran)
3
4 cmake_policy(SET CMP0069 NEW)
5
6 if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran")
7 if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55")
8 set(_LFORTRAN_SC_FLAG --separate-compilation)
9 else()
10 set(_LFORTRAN_SC_FLAG --generate-object-code)
11 endif()
12 add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG})
13 endif()
14
15 include(CheckIPOSupported)
16 check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
17 if(ipo_supported)
18 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
19 elseif(CMake_TEST_IPO_WORKS_Fortran)
20 string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
21 message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
22 endif()
23
24 add_library(foo foo.f)
25 add_executable(CheckIPOSupported-Fortran main.f)
26 target_link_libraries(CheckIPOSupported-Fortran PUBLIC foo)
27
28 enable_testing()
29 add_test(NAME CheckIPOSupported-Fortran COMMAND CheckIPOSupported-Fortran)