diff --git a/.versioning/changes/qz3SfuZKgk.minor.md b/.versioning/changes/qz3SfuZKgk.minor.md new file mode 100644 index 0000000..5fbbcf5 --- /dev/null +++ b/.versioning/changes/qz3SfuZKgk.minor.md @@ -0,0 +1 @@ +Enables LTO when supported by compiler/linker diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b3dbc..4a74d43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,19 @@ set(CMAKE_CXX_STANDARD 20) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) include(CPPCheck) include(GNUInstallDirs) +include(CheckIPOSupported) +check_ipo_supported( + RESULT SHADOW_CAST_IPO_SUPPORTED + OUTPUT SHADOW_CAST_IPO_SUPORTED_OUTPUT + LANGUAGES CXX +) + +if (SHADOW_CAST_IPO_SUPPORTED) + message(STATUS "IPO supported. Enabling") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +else () + message(STATUS "IPO not supported: ${SHADOW_CAST_IPO_SUPORTED_OUTPUT}") +endif () string(TOLOWER ${CMAKE_CXX_BYTE_ORDER} SHADOW_CAST_BYTE_ORDER)