From 9bbed4ae216c9f2fb0fdc6706130b7229c137f50 Mon Sep 17 00:00:00 2001 From: ezcrypt Date: Wed, 27 Nov 2024 11:32:55 +0100 Subject: [PATCH] CMake: Enable LTO (Link Time Optimizations) --- src/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b8bdfc..d4d407e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,6 +100,13 @@ else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror") endif() +# Enable LTO. +if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" + MATCHES "Clang")) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") +endif() + # ----------------------------------------------------------------------------- # The libezcrypt library. # ----------------------------------------------------------------------------- -- 2.11.4.GIT