CMake: Make LTO default off, restrict to release build

Link Time Optimizations increases build time a lot so restrict
this optimization to release builds. Follow our build bots and
make this option default off.

Also LTO requires CMake >= 3.9 so make the LTO CMake option
universally conditional on that requirement.
This commit is contained in:
João Valverde 2021-07-22 21:29:37 +01:00 committed by Wireshark GitLab Utility
parent 925e01b23f
commit 3467b98eb7
2 changed files with 4 additions and 6 deletions

View File

@ -73,8 +73,8 @@ if (ENABLE_LTO)
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT lto_output) check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
if(lto_supported) if(lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
message(STATUS "LTO/IPO is enabled") message(STATUS "LTO/IPO is enabled for Release configuration")
else() else()
message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}") message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
endif() endif()

View File

@ -63,10 +63,8 @@ else()
option(ENABLE_COMPILER_COLOR_DIAGNOSTICS "Always enable the compiler's color diagnostic output" OFF) option(ENABLE_COMPILER_COLOR_DIAGNOSTICS "Always enable the compiler's color diagnostic output" OFF)
endif() endif()
if(WIN32) if(CMAKE_VERSION VERSION_GREATER "3.8.99")
option(ENABLE_LTO "Improves performance using Link Time Optimization" ON) option(ENABLE_LTO "Use Link Time Optimization (release configuration only)" OFF)
elseif(CMAKE_VERSION VERSION_GREATER "3.8.99")
option(ENABLE_LTO "Improves performance using Link Time Optimization" OFF)
endif() endif()
if(WIN32) if(WIN32)