From 47842e279798b5419a9f29fdef57447c47435d26 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 4 Mar 2015 08:57:20 +0100 Subject: [PATCH] Add a CMake variable for -flto --- CMakeLists.txt | 8 ++++++++ INSTALL.md | 1 + 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aff346be0..6bce7ffe3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins") set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe") set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build") +set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO") file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS) @@ -139,6 +140,13 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections") endif() +if(ICINGA2_LTO_BUILD) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto") +endif() + if(MSVC) add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) endif() diff --git a/INSTALL.md b/INSTALL.md index 4e39ee492..9e6e3fba9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -143,6 +143,7 @@ variables are supported: - `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON` - `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd` - `ICINGA2_UNITY_BUILD`: Whether to perform a unity build; defaults to `ON` +- `ICINGA2_LTO_BUILD`: Whether to use link time optimization (LTO); defaults to `OFF` - `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins` - `ICINGA2_RUNDIR`: The location of the "run" directory; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run` - `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`