From: Vsevolod Stakhov Date: Thu, 14 Jul 2016 11:54:41 +0000 (+0100) Subject: [Feature] Use -flto if possible when optimizations are enabled X-Git-Tag: 1.3.0~90 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bcde3b0e5396f3ea560d3429b8fab1d69a18a55a;p=rspamd.git [Feature] Use -flto if possible when optimizations are enabled --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 22704af4e..5d126659d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -793,7 +793,13 @@ ENDIF(SUPPORT_FPIC) # 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")