sfizz/cmake/CheckIPO.cmake

22 lines
645 B
CMake
Raw Normal View History

2019-11-26 13:43:07 +01:00
# Added in CMake 3.9
include (CheckIPOSupported)
check_ipo_supported (RESULT result OUTPUT output)
if (result AND ENABLE_LTO AND CMAKE_BUILD_TYPE STREQUAL "Release")
2019-11-26 13:43:07 +01:00
message (STATUS "\nLTO enabled.")
else()
if (${output})
message (WARNING "\nIPO disabled: ${output}")
else()
message (WARNING "\nIPO was disabled or not in a Release build.")
2019-11-26 13:43:07 +01:00
endif()
set (ENABLE_LTO OFF)
endif()
2019-12-01 15:54:28 +01:00
function (SFIZZ_ENABLE_LTO_IF_NEEDED TARGET)
if (${ENABLE_LTO})
message(STATUS "Enabling LTO on ${TARGET}")
set_property (TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
endif()
endfunction()