Skip to content

Commit

Permalink
Add LTO.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryouze committed Oct 31, 2024
1 parent 2240ac2 commit 1f07f01
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Enable Link Time Optimization (if supported)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT lto_error)
if(lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
message(STATUS "[INFO] Link Time Optimization (LTO) is enabled.")
else()
message(WARNING "[WARNING] Link Time Optimization (LTO) not supported: ${lto_error}")
endif()

# Project options
option(BUILD_TESTS "Build tests" OFF)
option(ENABLE_COMPILE_FLAGS "Enable compile flags" ON)
Expand Down

0 comments on commit 1f07f01

Please sign in to comment.