]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Require CMake 3.9 to work, remove manual lto crap
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Oct 2019 10:47:16 +0000 (11:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Oct 2019 10:47:16 +0000 (11:47 +0100)
CMakeLists.txt
contrib/replxx/CMakeLists.txt

index 99fbc8f2d8936916607ffe0857cef69cfbe5a31f..e0b6f15fdbd6176c3858e17a637b5581c03275ab 100644 (file)
@@ -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")
index a2dcf2dd1f24b7c7873965fcba074bfb2b7737c2..a1b40dfdbcb6fc3cdb7290bd5320efb85efe9f96 100644 (file)
@@ -1,7 +1,4 @@
 # -*- mode: CMAKE; -*-
-
-cmake_minimum_required(VERSION 3.0)
-
 project( replxx VERSION 0.0.2 LANGUAGES CXX C )
 message(STATUS "Build mode: ${CMAKE_BUILD_TYPE}")