From 8aa86a05059f2207875cee2a3ba8eb26b3a4be3b Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Thu, 5 Sep 2024 16:12:26 +0200 Subject: [PATCH] Add support for building with LTO (#165) --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8681bc..46f5cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,18 @@ option(MLN_QT_WITH_WIDGETS "Build QMapLibreWidgets" ON) option(MLN_QT_STATIC "Build QMapLibre staticaly (force static build with Qt6)" OFF) option(MLN_QT_WITH_COVERAGE "Build QMapLibre with code coverage collection" OFF) option(MLN_QT_WITH_CLANG_TIDY "Build QMapLibre with clang-tidy checks enabled" OFF) +option(MLN_QT_WITH_LTO "Build QMapLibre with Link-Time Optimization" OFF) + +if(MLN_QT_WITH_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT ipo_result OUTPUT ipo_output) + if(ipo_result) + message(STATUS "Building with LTO/IPO enabled") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "LTO/IPO is not supported: ${ipo_output}") + endif() +endif() # Find Qt if("${QT_VERSION_MAJOR}" STREQUAL "")