mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Conditionally enable IPO
Put corresponding functionality in `cmake/ipo.cmake`. This directory allows for future further separation of build concerns.
This commit is contained in:
parent
06600440fe
commit
87d9932792
4 changed files with 30 additions and 16 deletions
|
@ -6,14 +6,6 @@ endif()
|
||||||
|
|
||||||
project(openrct2 CXX)
|
project(openrct2 CXX)
|
||||||
|
|
||||||
include(CheckIPOSupported)
|
|
||||||
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_LOG)
|
|
||||||
if(IPO_SUPPORTED)
|
|
||||||
message(INFO "IPO supported")
|
|
||||||
else()
|
|
||||||
message(WARNING "IPO not supported: ${IPO_LOG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -60,6 +52,10 @@ if (PORTABLE OR WIN32)
|
||||||
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
include(cmake/ipo.cmake)
|
||||||
|
list(APPEND IPO_ENABLED_BUILDS Release RelWithDebInfo MinSizeRel)
|
||||||
|
ipo_enable("${IPO_ENABLED_BUILDS}")
|
||||||
|
|
||||||
# Describe current version in terms of closest tag
|
# Describe current version in terms of closest tag
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git describe HEAD
|
COMMAND git describe HEAD
|
||||||
|
|
24
cmake/ipo.cmake
Normal file
24
cmake/ipo.cmake
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Helpers for inter-procedural optimizations (IPO)
|
||||||
|
|
||||||
|
# Enabled IPO for a LIST of CMake build types.
|
||||||
|
# Provides IPO_BUILD_ENABLED to the parent scope.
|
||||||
|
function(ipo_enable IPO_ENABLED_BUILDS)
|
||||||
|
include(CheckIPOSupported)
|
||||||
|
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_LOG)
|
||||||
|
|
||||||
|
set(IPO_BUILD_ENABLED OFF PARENT_SCOPE)
|
||||||
|
if(IPO_SUPPORTED AND ${CMAKE_BUILD_TYPE} IN_LIST IPO_ENABLED_BUILDS)
|
||||||
|
message(STATUS "IPO supported and enabled in ${CMAKE_BUILD_TYPE}.")
|
||||||
|
set(IPO_BUILD_ENABLED ON PARENT_SCOPE)
|
||||||
|
elseif(NOT IPO_SUPPORTED AND ${CMAKE_BUILD_TYPE} IN_LIST IPO_ENABLED_BUILDS)
|
||||||
|
message(STATUS "IPO not supported: ${IPO_LOG}.")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Sets appropriate IPO properties on target _target
|
||||||
|
# if IPO is supported and enabled for the current build.
|
||||||
|
function(ipo_set_target_properties _target)
|
||||||
|
if(IPO_BUILD_ENABLED)
|
||||||
|
set_property(TARGET ${_target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
|
@ -14,10 +14,7 @@ file(GLOB_RECURSE OPENRCT2_CLI_SOURCES
|
||||||
set (PROJECT openrct2-cli)
|
set (PROJECT openrct2-cli)
|
||||||
project(${PROJECT} CXX)
|
project(${PROJECT} CXX)
|
||||||
add_executable(${PROJECT} ${OPENRCT2_CLI_SOURCES})
|
add_executable(${PROJECT} ${OPENRCT2_CLI_SOURCES})
|
||||||
|
ipo_set_target_properties(${PROJECT})
|
||||||
if(IPO_SUPPORTED)
|
|
||||||
set_property(TARGET ${PROJECT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT} "libopenrct2")
|
target_link_libraries(${PROJECT} "libopenrct2")
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,7 @@ endif ()
|
||||||
set (PROJECT openrct2)
|
set (PROJECT openrct2)
|
||||||
project(${PROJECT} CXX)
|
project(${PROJECT} CXX)
|
||||||
add_executable(${PROJECT} ${OPENRCT2_UI_SOURCES} ${OPENRCT2_UI_MM_SOURCES})
|
add_executable(${PROJECT} ${OPENRCT2_UI_SOURCES} ${OPENRCT2_UI_MM_SOURCES})
|
||||||
|
ipo_set_target_properties(${PROJECT})
|
||||||
if(IPO_SUPPORTED)
|
|
||||||
set_property(TARGET ${PROJECT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT} "libopenrct2"
|
target_link_libraries(${PROJECT} "libopenrct2"
|
||||||
${SDL2_LDFLAGS}
|
${SDL2_LDFLAGS}
|
||||||
|
|
Loading…
Reference in a new issue