From 5a885b541f7aad3dfcc76f522d4deec274cc91e4 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 26 May 2024 18:18:39 +0200 Subject: [PATCH] enable LTO --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce1981..1bf82e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,13 +40,19 @@ add_library(${NAME} STATIC ) target_compile_options(${NAME} PUBLIC - -Wall -Wextra -std=c11 -Os) + -Wall -Wextra -std=c11 -Os -flto) target_include_directories(${NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include") target_link_libraries(${NAME} Gint::Gint -lm) +# Generate the archive with gcc-ar instead of ar as it will load the LTO plugin +# which is required to generate a usable archive. +set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER_AR} qcs ") +# Also the ranlib rule (useless because ar is passed the s flag anyway) +set(CMAKE_C_ARCHIVE_FINISH "${CMAKE_C_COMPILER_RANLIB} ") + install(TARGETS ${NAME} DESTINATION "${FXSDK_LIB}") install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"