From c7c83a35fa74b419145f2e5013873bf98bf46df5 Mon Sep 17 00:00:00 2001 From: Philipp David Date: Sat, 19 Mar 2022 18:08:28 +0100 Subject: Enable LTO/IPO on release builds --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 7537703c..889d6fc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) if(WIN32) # In Qt 5.1+ we have our own main() function, don't autolink to qtmain on Windows @@ -43,6 +43,18 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type") # Fix build with Qt 5.13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y") +include(CheckIPOSupported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error) + +if(ipo_supported AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")) + message(STATUS "IPO / LTO enabled") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +elseif(ipo_supported) + message(STATUS "Not enabling IPO / LTO on debug builds") +else() + message(STATUS "IPO / LTO not supported: <${ipo_error}>") +endif() + ##################################### Set Application options ##################################### ######## Set URLs ######## -- cgit