]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] CMake: Add ENABLE_LTO option 3228/head
authorPeter Wu <peter@lekensteyn.nl>
Tue, 21 Jan 2020 04:13:16 +0000 (04:13 +0000)
committerPeter Wu <peter@lekensteyn.nl>
Tue, 21 Jan 2020 04:16:26 +0000 (04:16 +0000)
* The `CMAKE_BUILD_TYPE=None` option is commonly used to respect the
  user's optimization flags. Users may be interested in enabling LTO
  anyway in that case. Implement this the Debian build.
* Remove typo, the value is called RelWithDebInfo. Enable LTO for this
  by default.

cmake/Toolset.cmake
debian/rules

index 37019bc475e835020ba2d3a8959511439f478215..a60815d7a34019df1ec11d7bb9d392de385a7d9e 100644 (file)
@@ -166,9 +166,16 @@ else ()
 endif()
 
 
+if (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE|RELWITHDEBINFO")
+  set(ENABLE_LTO_INIT ON)
+else()
+  set(ENABLE_LTO_INIT OFF)
+endif()
+option(ENABLE_LTO       "Build rspamd with Link Time Optimization if supported [default: ${ENABLE_LTO_INIT}]" ${ENABLE_LTO_INIT})
+
 if (CMAKE_BUILD_TYPE_UC MATCHES "COVERAGE")
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
-elseif (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE")
+elseif (ENABLE_LTO)
     if (${CMAKE_VERSION} VERSION_GREATER "3.9.0")
         cmake_policy (SET CMP0069 NEW)
         include (CheckIPOSupported)
@@ -183,4 +190,4 @@ elseif (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE")
 endif ()
 
 message (STATUS "Final CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
-message (STATUS "Final CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
\ No newline at end of file
+message (STATUS "Final CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
index 17ebd6eb13bc1191feb9698fd4b7c5bf46a9aa47..309bd073813caef6285df1f0ff04896a5dcc4432 100755 (executable)
@@ -30,8 +30,9 @@ override_dh_auto_configure:
                -DLIBDIR=/usr/lib/rspamd \
                -DINCLUDEDIR=/usr/include \
                -DSYSTEMDDIR=/lib/systemd/system \
-               -DCMAKE_BUILD_TYPE=ReleaseWithDebInfo \
+               -DCMAKE_BUILD_TYPE=None \
                -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
+               -DENABLE_LTO=ON \
                -DDEBIAN_BUILD=1 \
                -DENABLE_JEMALLOC=ON \
                -DENABLE_PCRE2=OFF \