From: Peter Wu Date: Tue, 21 Jan 2020 04:13:16 +0000 (+0000) Subject: [Minor] CMake: Add ENABLE_LTO option X-Git-Tag: 2.3~71^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3228%2Fhead;p=thirdparty%2Frspamd.git [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. --- diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake index 37019bc475..a60815d7a3 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 17ebd6eb13..309bd07381 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 \