# Optimization flags
IF(NOT CMAKE_C_OPT_FLAGS)
IF(ENABLE_OPTIMIZATION MATCHES "ON")
- SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+ CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO)
+ IF(SUPPORT_FLTO)
+ SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing -flto")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
+ ELSE()
+ SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+ ENDIF()
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
IF(DEBUG_MODE MATCHES "ON")
SET(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")