cmake: add USE_LTO option

This commit is contained in:
Rosalie Wanders
2023-07-20 13:19:33 +02:00
parent 7c46d9ef41
commit 6a50c09517
2 changed files with 16 additions and 0 deletions
+10
View File
@@ -9,6 +9,7 @@ option(APPIMAGE_UPDATER "Enables AppImage updater" OFF)
option(DISCORD_RPC "Enables Discord Rich Presence" ON)
option(VRU "Enables VRU support in RMG-Input" ON)
option(USE_CCACHE "Enables usage of ccache when ccache has been found" ON)
option(USE_LTO "Enables building with LTO/IPO when compiler supports it" ON)
option(FORCE_XCB "Forces Qt to use the xcb platform on linux" ${LINUX})
option(NO_RUST "Disables the building of rust subprojects" OFF)
@@ -32,6 +33,15 @@ if (USE_CCACHE)
endif(CCACHE_FOUND)
endif(USE_CCACHE)
if (USE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT ENABLE_IPO)
if(ENABLE_IPO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif(ENABLE_IPO)
endif(USE_LTO)
if (NOT PORTABLE_INSTALL AND (WIN32 OR MSYS))
message(WARNING "Not-Portable build not supported on windows, re-enabling PORTABLE_INSTALL!")
set(PORTABLE_INSTALL ON)
+6
View File
@@ -5,6 +5,12 @@ project(RMG-Core)
set(CMAKE_CXX_STANDARD 20)
# RMG-Core needs LTO disabled for windows
# else linking fails
if (WIN32)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif(WIN32)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(MINIZIP REQUIRED minizip)