CMake: Re-enable LTO for Release builds with CMake >= 3.9
If you're using an earlier version, I suggest you upgrade, CMake 3.9 was released in 2017....
This commit is contained in:
parent
e7cfc69975
commit
fa46ba16bf
|
@ -145,7 +145,19 @@ if(MSVC)
|
|||
|
||||
# Enable LTO/LTCG on Release builds.
|
||||
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
if (${CMAKE_VERSION} VERSION_LESS "3.9.0")
|
||||
message(WARNING "CMake version is less than 3.9.0, we can't enable LTCG/IPO. This will make the build slightly slower, consider updating your CMake version.")
|
||||
else()
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT IPO_IS_SUPPORTED)
|
||||
if(IPO_IS_SUPPORTED)
|
||||
message(STATUS "Enabling LTCG/IPO.")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
else()
|
||||
message(WARNING "LTCG/IPO is not supported, this will make the build slightly slower.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue