From 941927336eb3a1b92a0edef4ae4258b1c4f5212d Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 31 Dec 2020 13:52:11 +0100 Subject: [PATCH] Reduce file size by using IPO and LTO. Signed-off-by: Deukhoofd --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a025d2a..47f1257 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 3.16) +include(CheckIPOSupported) + project(CreatureLib) # Enable all warnings, and make them error when occurring. @@ -59,6 +61,13 @@ file(GLOB_RECURSE LIBRARY_SRC_FILES add_library(CreatureLib SHARED ${LIBRARY_SRC_FILES}) target_precompile_headers(CreatureLib PUBLIC src/Precompiled.hxx) +# If interprocedural optimization is available, apply it +check_ipo_supported(RESULT IPO_SUPPORTED) +if (IPO_SUPPORTED) + message(STATUS "IPO / LTO enabled") + set_property(TARGET CreatureLib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) +endif () + # If we are building for Windows we need to set some specific variables. if (WINDOWS) MESSAGE(WARNING, "Using Windows Build.")