enable LTO

This commit is contained in:
Lephenixnoir 2024-05-26 18:18:39 +02:00
parent 5b092a5a4e
commit 5a885b541f
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -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 <TARGET> <OBJECTS>")
# Also the ranlib rule (useless because ar is passed the s flag anyway)
set(CMAKE_C_ARCHIVE_FINISH "${CMAKE_C_COMPILER_RANLIB} <TARGET>")
install(TARGETS ${NAME}
DESTINATION "${FXSDK_LIB}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"