Skip to content

Commit

Permalink
Check at configure time that LTO is supported by the C++ compiler bef…
Browse files Browse the repository at this point in the history
…ore enabling it
  • Loading branch information
sjanel committed Mar 23, 2024
1 parent 92b3b77 commit 9b09368
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
aux_source_directory(src MAIN_SRC)

include(CheckIPOSupported)

if(CCT_BUILD_EXEC)
add_executable(coincenter ${MAIN_SRC})

# Enable LTO with coincenter in Release mode
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET coincenter PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "Activate LTO for coincenter")
check_ipo_supported(RESULT result OUTPUT output LANGUAGES CXX)

if(result)
# Enable LTO with coincenter in Release mode
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET coincenter PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "Activate LTO for coincenter")
endif()
else()
message(WARNING "IPO is not supported: ${output}")
endif()

else()
list(REMOVE_ITEM ENGINE_SRC "src/main.cpp")
add_library(coincenter STATIC ${MAIN_SRC})
Expand All @@ -27,4 +36,4 @@ add_unit_test(
test/processcommandsfromcli_test.cpp
LIBRARIES
coincenter_engine
)
)

0 comments on commit 9b09368

Please sign in to comment.