Skip to content

Commit fdb98b5

Browse files
refactor(cmake): improve ipo support check (estkme-group#347)
Co-authored-by: Coelacanthus <uwu@coelacanthus.name>
1 parent e5c608c commit fdb98b5

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2222

2323
# add_compile_options(-Wall -Wextra -Wpedantic)
2424

25-
# Enable LTO when possible.
26-
include(CheckIPOSupported)
27-
check_ipo_supported(RESULT result OUTPUT output)
28-
if(result)
29-
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
30-
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
31-
endif()
32-
else()
33-
message(INFO "IPO is not supported: ${output}")
34-
endif()
25+
if (NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
26+
message(CHECK_START "Detecting LTO")
27+
include(CheckIPOSupported)
28+
check_ipo_supported(RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION OUTPUT LTO_ERROR)
29+
if (LTO_ERROR)
30+
message(CHECK_FAIL "Not supported: ${LTO_ERROR}")
31+
else ()
32+
message(CHECK_PASS "Supported")
33+
endif ()
34+
endif ()
3535

3636
if (APPLE AND NOT DEFINED CMAKE_OSX_ARCHITECTURES)
3737
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")

0 commit comments

Comments
 (0)