fmt is publicly linked now, enable lto by default

This commit is contained in:
Robin Müller 2022-05-09 02:02:13 +02:00
parent e8a5f1e095
commit fb1d775b52
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
1 changed files with 17 additions and 0 deletions

View File

@ -30,6 +30,14 @@ set(FSFW_FMT_LIB_VERSION v${FSFW_FMT_LIB_MAJOR_VERSION}.1.1 CACHE STRING
"{fmt} library exact version requirement"
)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(NOT IPO_SUPPORTED)
message(STATUS "FSFW | IPO/LTO not supported: ${IPO_ERROR}")
endif()
option(FSFW_ENABLE_IPO "Enable interprocedural optimization or link-time optimization if available" ON)
option(FSFW_GENERATE_SECTIONS
"Generate function and data sections. Required to remove unused code" ON
)
@ -68,6 +76,10 @@ set(FSFW_DUMMY_TGT fsfw-dummy)
project(${LIB_FSFW_NAME})
add_library(${LIB_FSFW_NAME} src/fsfw/serviceinterface/fmtWrapper.h src/fsfw/serviceinterface/fmtWrapper.cpp)
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(FSFW_BUILD_UNITTESTS)
message(STATUS "Building the FSFW unittests in addition to the static library")
# Check whether the user has already installed Catch2 first
@ -427,7 +439,12 @@ target_compile_options(${LIB_FSFW_NAME} PRIVATE
${COMPILER_FLAGS}
)
target_link_libraries(${LIB_FSFW_NAME} PUBLIC
${FSFW_FMT_LINK_TARGET}
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
# If any ELT headers are ever exposed inside a header or as part of the API, the ETL target needs to be linked PUBLIC
${FSFW_ETL_LINK_TARGET}
${FSFW_ADDITIONAL_LINK_LIBS}
)