diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-15 11:47:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-15 11:47:16 +0100 |
commit | 95b113764d8e2199dd30cd0ffcf2a8c1dfab9875 (patch) | |
tree | cbc75b5ae52d1e55212dff5f3cc82b7c47a47d66 /CMakeLists.txt | |
parent | e229b6dd55b04b155b17fcb8c09b9f7e602c4913 (diff) | |
download | rspamd-95b113764d8e2199dd30cd0ffcf2a8c1dfab9875.tar.gz rspamd-95b113764d8e2199dd30cd0ffcf2a8c1dfab9875.zip |
[Rework] Require CMake 3.9 to work, remove manual lto crap
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 99fbc8f2d..e0b6f15fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # ############################# INITIAL SECTION ############################################# -CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR) SET(RSPAMD_VERSION_MAJOR 2) SET(RSPAMD_VERSION_MINOR 1) @@ -769,30 +769,21 @@ ENDIF(SUPPORT_FPIC) # Optimization flags IF(NOT CMAKE_C_OPT_FLAGS) IF(ENABLE_OPTIMIZATION MATCHES "ON") - CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO) - IF(SUPPORT_FLTO) - IF(NOT CMAKE_GCC_AR OR NOT CMAKE_GCC_RANLIB) - FIND_PROGRAM(CMAKE_GCC_AR NAMES "gcc-ar") - FIND_PROGRAM(CMAKE_GCC_RANLIB NAMES "gcc-ranlib") - MARK_AS_ADVANCED(CMAKE_GCC_AR CMAKE_GCC_RANLIB) + SET(CMAKE_C_OPT_FLAGS "-g -O2") + IF(${CMAKE_VERSION} VERSION_GREATER "3.9.0") + CMAKE_POLICY(SET CMP0069 NEW) + INCLUDE(CheckIPOSupported) + check_ipo_supported(RESULT SUPPORT_LTO OUTPUT LTO_DIAG ) + if(SUPPORT_LTO) + SET(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "IPO is not supported: ${LTO_DIAG}") + endif() ENDIF() - IF(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB) - SET(CMAKE_C_OPT_FLAGS "-g -O3 -flto") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") - SET(CMAKE_C_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_C_ARCHIVE_APPEND "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_C_ARCHIVE_FINISH "${CMAKE_GCC_RANLIB} <TARGET>") - SET(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>") - SET(CMAKE_CXX_ARCHIVE_FINISH "${CMAKE_GCC_RANLIB} <TARGET>") - ENDIF() - ELSE() - SET(CMAKE_C_OPT_FLAGS "-g -O3") - ENDIF() ELSE(ENABLE_OPTIMIZATION MATCHES "ON") IF(ENABLE_FULL_DEBUG MATCHES "ON") ADD_DEFINITIONS(-DFULL_DEBUG) - SET(CMAKE_C_OPT_FLAGS "-g -O0") + SET(CMAKE_C_OPT_FLAGS "-g -Og") ELSE(ENABLE_FULL_DEBUG MATCHES "ON") SET(CMAKE_C_OPT_FLAGS "-g -O2") ENDIF(ENABLE_FULL_DEBUG MATCHES "ON") @@ -800,7 +791,7 @@ IF(NOT CMAKE_C_OPT_FLAGS) ENDIF(NOT CMAKE_C_OPT_FLAGS) IF(ENABLE_COVERAGE) - SET(CMAKE_C_OPT_FLAGS "-g -O0") + SET(CMAKE_C_OPT_FLAGS "-g -Og") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") |