summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Dierheimer <Linus@Dierheimer.de>2022-06-22 12:32:54 (GMT)
committerBrad King <brad.king@kitware.com>2022-06-22 13:09:16 (GMT)
commitfe57410b33de1e8640091f0a1ac3ddde81163882 (patch)
treeeb1c678dde17b76514be99d447dba36058b191c1
parentaae6a67e5c850f0f4dd0be4bb7d645d48995f24c (diff)
downloadCMake-fe57410b33de1e8640091f0a1ac3ddde81163882.zip
CMake-fe57410b33de1e8640091f0a1ac3ddde81163882.tar.gz
CMake-fe57410b33de1e8640091f0a1ac3ddde81163882.tar.bz2
IPO: Use -flto=auto if compiler is GCC >= 10.1
Since GCC 12.1, the `-flto` option warns unless given an explicit LTRANS job count. Issue: #23640
-rw-r--r--Modules/Compiler/GNU.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index c5946f0..db1eab5 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: