From 1b0400fc54ec6815c0135ff2f6db40e17020c429 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 13 Jan 2021 13:31:15 -0800 Subject: [PATCH] First check for debug build, then for LTO --- CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7370f40d..0595159c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,18 +38,18 @@ if(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE) # Enable LTO if we're in a release build and LTO is supported -include(CheckIPOSupported) -check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error) -if(LTO_SUPPORTED) - string(TOUPPER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE_UPPER) - if (_CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - message(STATUS "LTO disabled because we're in a debug build") - else() +string(TOUPPER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE_UPPER) +if (_CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") + message(STATUS "LTO disabled because we're in a debug build") +else() + include(CheckIPOSupported) + check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error) + if(LTO_SUPPORTED) message(STATUS "LTO enabled") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "LTO disabled because compiler does not support it.") endif() -else() - message(WARNING "LTO disabled because compiler does not support it.") endif() if(USE_CLANG_TIDY)