stellar

Stellar - UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 9ee804501d5cd5fd02da68ec89e975d29876e389
parent 75e27270d7d82dceb3274989abbe149546584541
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 11 Mar 2024 14:03:08 +0000

Enable link-time optimization properly

Diffstat:
MCMakeLists.txt | 22+++++++++++-----------
Msrc/engine/CMakeLists.txt | 1+
2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project( Stellar - VERSION 1.2.0 + VERSION 1.2.1 DESCRIPTION "Chess engine written in C++" HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git LANGUAGES CXX @@ -35,16 +35,6 @@ function(stellar_target_precompile_headers) endif() endfunction() -CHECK_CXX_COMPILER_FLAG("-flto" COMPILER_SUPPORTS_LTO) -if(COMPILER_SUPPORTS_LTO) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") -endif() - -CHECK_CXX_COMPILER_FLAG("-fno-fat-lto-objects" COMPILER_SUPPORTS_LTO_NOFAT) -if(COMPILER_SUPPORTS_LTO_NOFAT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-fat-lto-objects") -endif() - CHECK_CXX_COMPILER_FLAG("-fconstexpr-ops-limit=10000000000" COMPILER_SUPPORTS_CONSTEXPR_OPS_LIMIT) if(COMPILER_SUPPORTS_CONSTEXPR_OPS_LIMIT) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=1000000000") @@ -61,3 +51,13 @@ if(COMPILER_SUPPORTS_MARCH_NATIVE) endif() add_subdirectory(src) + +include(CheckIPOSupported) +check_ipo_supported(RESULT lto_supported OUTPUT lto_error) + +if( lto_supported ) + message(STATUS "IPO / LTO enabled") + set_property(TARGET engine PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) +else() + message(STATUS "IPO / LTO not supported: <${error}>") +endif() diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt @@ -4,6 +4,7 @@ add_executable(engine engine.cpp ) + target_link_libraries(engine PRIVATE Stellar_version PRIVATE board