summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMartino Fontana <tinozzo123@gmail.com>2026-01-23 17:55:57 +0100
committerMartino Fontana <tinozzo123@gmail.com>2026-01-23 17:56:06 +0100
commiteec35a214dd2f8b0d18a66340e7b34e2928e1411 (patch)
tree21afc9bb03a8ae3727aa14b18ea6e1126fcbbee5 /CMakeLists.txt
parentb18abc41edcce4b98aeaf13a52c693fcd724d07b (diff)
CMakeLists: Use `CMAKE_INTERPROCEDURAL_OPTIMIZATION` for LTO
Just a simple modernization. LTO is still disabled by default.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt14
1 files changed, 6 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91b80a5718..1a346103d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,15 +377,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif()
if(ENABLE_LTO)
- if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
- add_compile_options(/GL)
- string(APPEND CMAKE_EXE_LINKER_FLAGS " /LTCG")
+ include(CheckIPOSupported)
+ check_ipo_supported(RESULT supported OUTPUT error)
+
+ if(supported)
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
- check_and_add_flag(LTO -flto)
- if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
- set(CMAKE_AR gcc-ar)
- set(CMAKE_RANLIB gcc-ranlib)
- endif()
+ message(STATUS "IPO / LTO not supported: <${error}>")
endif()
endif()