mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
CMake: Add an option to enable IPO
This commit is contained in:
parent
69e312f5fb
commit
9e8c97c812
|
@ -126,6 +126,7 @@ option(DEV "Don't generate stuff necessary for packaging" OFF)
|
|||
option(VULKAN "Enable the vulkan backend" ${AUTO_VULKAN_BACKEND})
|
||||
|
||||
option(EXCEPTION_HANDLING "Enable exception handling (only works with Windows as of now)" OFF)
|
||||
option(IPO "Enable interprocedural optimizations" OFF)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/toolchains/Emscripten.toolchain)
|
||||
|
@ -157,6 +158,21 @@ endif()
|
|||
|
||||
set(DBG $<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>)
|
||||
|
||||
if(IPO)
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.9)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
|
||||
if(ipo_supported)
|
||||
message(STATUS "IPO is enabled")
|
||||
set(ENABLE_IPO TRUE)
|
||||
else()
|
||||
message(WARNING "IPO is not supported: ${ipo_output}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "IPO enablement requires CMake 3.9+")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
configure_file(src/game/version.h vd.h)
|
||||
else()
|
||||
|
@ -2914,6 +2930,9 @@ foreach(target ${TARGETS})
|
|||
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>) # Detect some buffer overflows.
|
||||
endif()
|
||||
endif()
|
||||
if(ENABLE_IPO)
|
||||
set_property(TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(target ${TARGETS_LINK})
|
||||
|
|
Loading…
Reference in a new issue