aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2020-01-21 04:13:16 +0000
committerPeter Wu <peter@lekensteyn.nl>2020-01-21 04:16:26 +0000
commit3daf2762a956ee1c578f6320d6caf2885a2a8ea4 (patch)
treefdc72f29baaf81c5f10bb863a91d8a0f0c48d241 /cmake
parentaee58d4583b1aec4db06aedf9072205e5e184970 (diff)
downloadrspamd-3daf2762a956ee1c578f6320d6caf2885a2a8ea4.tar.gz
rspamd-3daf2762a956ee1c578f6320d6caf2885a2a8ea4.zip
[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.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Toolset.cmake11
1 files changed, 9 insertions, 2 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}}")