commit 3daf276: [Minor] CMake: Add ENABLE_LTO option

Peter Wu peter at lekensteyn.nl
Tue Jan 21 09:14:18 UTC 2020


Author: Peter Wu
Date: 2020-01-21 04:13:16 +0000
URL: https://github.com/rspamd/rspamd/commit/3daf2762a956ee1c578f6320d6caf2885a2a8ea4 (refs/pull/3228/head)

[Minor] CMake: Add ENABLE_LTO option
* 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 | 11 +++++++++--
 debian/rules        |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake
index 37019bc47..a60815d7a 100644
--- a/cmake/Toolset.cmake
+++ b/cmake/Toolset.cmake
@@ -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}}")
diff --git a/debian/rules b/debian/rules
index 17ebd6eb1..309bd0738 100755
--- a/debian/rules
+++ b/debian/rules
@@ -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 \


More information about the Commits mailing list