CMakeLists.txt 790 B

123456789101112131415161718192021222324
  1. cmake_minimum_required(VERSION 3.8)
  2. project(CheckIPOSupported-Fortran LANGUAGES Fortran)
  3. cmake_policy(SET CMP0069 NEW)
  4. if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran")
  5. add_compile_options(--implicit-interface)
  6. endif()
  7. include(CheckIPOSupported)
  8. check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
  9. if(ipo_supported)
  10. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
  11. elseif(CMake_TEST_IPO_WORKS_Fortran)
  12. string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
  13. message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
  14. endif()
  15. add_library(foo foo.f)
  16. add_executable(CheckIPOSupported-Fortran main.f)
  17. target_link_libraries(CheckIPOSupported-Fortran PUBLIC foo)
  18. enable_testing()
  19. add_test(NAME CheckIPOSupported-Fortran COMMAND CheckIPOSupported-Fortran)