From 82bca69eb7cef937997bf30fac00c46acf8394b7 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 22 Aug 2021 12:49:09 +0200 Subject: [PATCH] feat(cmake): Use standard linker for LTO scenarios --- CMakeLists.txt | 10 +++++----- cmake/UseFastestLinker.cmake | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cf2e5f3e..bb4b251ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,11 @@ if(NOT DEFINED CCACHE_DEV_MODE) endif() message(STATUS "Ccache dev mode: ${CCACHE_DEV_MODE}") +option(ENABLE_IPO "Enable interprocedural (link time, LTO) optimization" OFF) +if(ENABLE_IPO) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +endif() + include(UseCcache) include(UseFastestLinker) include(StandardSettings) @@ -72,11 +77,6 @@ include(StandardWarnings) include(CIBuildType) include(DefaultBuildType) -option(ENABLE_IPO "Enable interprocedural (link time, LTO) optimization" OFF) -if(ENABLE_IPO) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) -endif() - # # Configuration # diff --git a/cmake/UseFastestLinker.cmake b/cmake/UseFastestLinker.cmake index f7e079b4f..b38833cff 100644 --- a/cmake/UseFastestLinker.cmake +++ b/cmake/UseFastestLinker.cmake @@ -10,6 +10,11 @@ if(MSVC) return() endif() +if(ENABLE_IPO) + message(STATUS "Using standard linker for IPO") + return() +endif() + if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) # Be conservative and only probe for a faster linker on platforms that likely # don't have toolchain bugs. See for example -- 2.47.2