diff options
author | Brad King <brad.king@kitware.com> | 2022-06-23 13:24:42 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-23 09:24:58 -0400 |
commit | 0c2066f2d99cb5f6e5dcf734be5a867c619ec61f (patch) | |
tree | 1a31d73bd012ca295eaae8a90a6add9b60d155a0 | |
parent | fd83847b14d34d6b81a9fd9be863003ac5fa1e00 (diff) | |
parent | fe57410b33de1e8640091f0a1ac3ddde81163882 (diff) | |
download | cmake-0c2066f2d99cb5f6e5dcf734be5a867c619ec61f.tar.gz |
Merge topic 'ipo_append_auto_on_gcc' into release-3.24
fe57410b33 IPO: Use -flto=auto if compiler is GCC >= 10.1
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7400
-rw-r--r-- | Modules/Compiler/GNU.cmake | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index c5946f0335..db1eab5574 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -72,7 +72,18 @@ macro(__compiler_gnu lang) # * https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Option-Summary.html (yes) if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.5) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) - set(__lto_flags -flto) + + set(__lto_flags "") + + # '-flto=auto' introduced since GCC 10.1: + # * https://gcc.gnu.org/onlinedocs/gcc-9.5.0/gcc/Optimize-Options.html#Optimize-Options (no) + # * https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Optimize-Options.html#Optimize-Options (yes) + # Since GCC 12.1, the abundance of a parameter produces a warning if compiling multiple targets. + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 10.1) + list(APPEND __lto_flags -flto=auto) + else() + list(APPEND __lto_flags -flto) + endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7) # '-ffat-lto-objects' introduced since GCC 4.7: |