diff options
author | Brad King <brad.king@kitware.com> | 2022-01-20 16:57:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-20 16:58:05 (GMT) |
commit | 79589f7dfe5f4bc35210ad8d3dc9a71ec5124eb3 (patch) | |
tree | a9a6a3e7ce430f65cf8537e91d31cbfc3d8e4743 /Modules | |
parent | 925d089a4d24e0f5873ab87a65a36db551052ee9 (diff) | |
parent | 6a0ce19ce1cb594cdec19bacc9fc7a38156e38da (diff) | |
download | CMake-79589f7dfe5f4bc35210ad8d3dc9a71ec5124eb3.zip CMake-79589f7dfe5f4bc35210ad8d3dc9a71ec5124eb3.tar.gz CMake-79589f7dfe5f4bc35210ad8d3dc9a71ec5124eb3.tar.bz2 |
Merge topic 'FortranCInterface-gcc-12-lto'
6a0ce19ce1 FortranCInterface: Fix compatibility with GCC gfortran 12 LTO
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6879
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FortranCInterface/CMakeLists.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 13e4498..ce0bc10 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -102,6 +102,19 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) +# If IPO is enabled here, GCC gfortran >= 12.0 will obfuscate +# the strings of the return values in the compiled executable, +# which we use to regex match against later. +# The static libraries must be build with IPO and non-IPO objects, +# as that will ensure the verify step will operate on IPO objects, +# if requested by the system compiler flags. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND + CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + target_compile_options(FortranCInterface PRIVATE "-fno-lto") + target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects") + target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects") +endif() + file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[ set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>") ]]) |