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)