Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ option(SC_NO_NETWORKING "Disable all networking related stuff." OFF)
option(SC_USE_FLAT_INSTALL "Install files into a flat folder structure" ${WIN32})

option(SC_EVENT_QUEUE_DEBUG "Enable Event Queue Debug Info" OFF)
option(SC_ENABLE_LTO "Enable IPO/LTO for non-Debug builds" ON)

set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
Expand Down Expand Up @@ -53,6 +54,26 @@ function(sc_common_compiler_options target)
)
endfunction()

if(SC_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT SC_IPO_SUPPORTED OUTPUT SC_IPO_OUTPUT LANGUAGES CXX)
if(SC_IPO_SUPPORTED)
message(STATUS "IPO/LTO enabled for non-Debug builds")
else()
message(STATUS "IPO/LTO requested but not supported by this toolchain: ${SC_IPO_OUTPUT}")
endif()
endif()

function(sc_enable_lto target)
if(SC_ENABLE_LTO AND SC_IPO_SUPPORTED)
set_target_properties(${target} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE ON
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON
INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON
)
endif()
endfunction()


### Git Hash ###
# Get the current working branch
Expand Down Expand Up @@ -80,6 +101,7 @@ endif()
add_executable(simc engine/sc_main.cpp)
target_link_libraries(simc engine)
sc_common_compiler_options(simc)
sc_enable_lto(simc)

install(TARGETS simc DESTINATION ${SIMC_INSTALL_BIN})

Expand Down
1 change: 1 addition & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include(../source_files/cmake_engine.txt)
add_library(engine ${source_files})
target_include_directories(engine PUBLIC . ./include ./lib)
sc_common_compiler_options(engine)
sc_enable_lto(engine)

# Make cmake selections visible to C++ code
if(SC_NO_THREADING)
Expand Down
3 changes: 2 additions & 1 deletion qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if (${QT_VERSION_MAJOR} EQUAL 6)
endif()

sc_common_compiler_options(SimulationCraft)
sc_enable_lto(SimulationCraft)

target_include_directories(SimulationCraft PUBLIC ../engine/)
target_link_libraries(SimulationCraft
Expand Down Expand Up @@ -74,4 +75,4 @@ DESTINATION ${SIMC_INSTALL_SHARED}/locale)
if(WIN32)
include(${PROJECT_SOURCE_DIR}/cmake/windeployqt.cmake)
windeployqt(SimulationCraft)
endif()
endif()
Loading