From deb715ff98eb4f52051af17e2ff2a1a86edea59c Mon Sep 17 00:00:00 2001 From: Steffen Winter Date: Sat, 19 Apr 2025 13:20:29 +0200 Subject: [PATCH] CMake: Enable LTO by default only for release builds Signed-off-by: Steffen Winter --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ef2201..8290d4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,13 +36,19 @@ set(CMAKE_COLOR_DIAGNOSTICS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(BTOP_STATIC "Link btop statically" OFF) -option(BTOP_LTO "Enable LTO" ON) option(BTOP_USE_MOLD "Use mold to link btop" OFF) option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF) option(BTOP_WERROR "Compile with warnings as errors" OFF) option(BTOP_GPU "Enable GPU support" ON) cmake_dependent_option(BTOP_RSMI_STATIC "Link statically to ROCm SMI" OFF "BTOP_GPU" OFF) +# Enable LTO in release builds by default +if(CMAKE_BUILD_TYPE MATCHES "Rel(ease|WithDebInfo)") + option(BTOP_LTO "Enable LTO" ON) +else() + option(BTOP_LTO "Enable LTO" OFF) +endif() + if(BTOP_STATIC AND NOT APPLE) # Set this before calling find_package set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")