From 0ad6adc90048490b3d333d8929592a09c1fd7224 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 7 Jul 2020 18:54:11 +1000 Subject: [PATCH] build: Enable LTO/LTCG on Windows Release builds --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3feeed43..9c98a72fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,11 @@ if(MSVC) # COMDAT folding/remove unused functions. set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF /OPT:ICF") + + # Enable LTO/LTCG on Release builds. + if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) + endif() endif()