summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jones <jonesmz@users.noreply.github.com>2019-12-03 15:46:56 -0600
committerJan Niklas Hasse <jhasse@bixense.com>2019-12-03 22:46:56 +0100
commit0c84b0ebd757e85548cb49a40694b4528c465830 (patch)
treefd83f6637886fef55ccf0051b03ff85be3ce65bc
parentc90a078edb8a23a3cf36b3f061990ed425481855 (diff)
downloadninja-0c84b0ebd757e85548cb49a40694b4528c465830.tar.gz
Enable Link Time Optimization for Release builds (#1701)
-rw-r--r--CMakeLists.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 582e0ef..de0fe1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,19 @@
cmake_minimum_required(VERSION 3.12)
project(ninja)
+if(CMAKE_BUILD_TYPE MATCHES "Release")
+ cmake_policy(SET CMP0069 NEW)
+ include(CheckIPOSupported)
+ check_ipo_supported(RESULT lto_supported OUTPUT error)
+
+ if(lto_supported)
+ message(STATUS "IPO / LTO enabled")
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+ else()
+ message(STATUS "IPO / LTO not supported: <${error}>")
+ endif()
+endif()
+
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /GR- /Zc:__cplusplus")
else()