diff options
author | Robert Adam <dev@robert-adam.de> | 2021-12-06 13:23:49 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2021-12-26 21:46:54 +0300 |
commit | 8d83afb07c90302ec816c852fdd8e86f2145ca25 (patch) | |
tree | a37e195b42dd3d5c1d6396badebac519549e5005 /CMakeLists.txt | |
parent | aea05b6f93657b427130c7f29e5d140262bb2438 (diff) |
BUILD: Enable LTO, if supported
In theory LTO could give us a bit more performance than what we are
currently seeing. Client-side this will probably not be very noticeably
but on the server-side a few drops of extra performance can't hurt.
LTO will be enabled by default in all non-Debug builds. It remains
disabled for Debug builds as this is expected to be the kind of build
that a developer will use when they perform their work and there it is
useful to be able to go through multiple iterations of the program,
without waiting long times on the linker each time.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea7a64f00..987844d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,12 @@ # that can be found in the LICENSE file at the root of the # Mumble source tree or at <https://www.mumble.info/LICENSE>. + cmake_minimum_required(VERSION 3.15) cmake_policy(SET CMP0079 NEW) cmake_policy(SET CMP0091 NEW) +cmake_policy(SET CMP0069 NEW) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0") cmake_policy(SET CMP0118 NEW) endif() @@ -48,6 +50,9 @@ list(APPEND CMAKE_MODULE_PATH include(pkg-utils) include(project-utils) include(TargetArch) +include(CheckIPOSupported) + +check_ipo_supported(RESULT LTO_DEFAULT) option(tests "Build tests" OFF) @@ -70,8 +75,13 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") "-DDEBUG" "-DSNAPSHOT_BUILD" ) + + # Disable LTO in Debug builds in order to reduce time required for linking + set(LTO_DEFAULT OFF) endif() +option(lto "Enables link-time optimizations" ${LTO_DEFAULT}) + include(compiler) include(os) @@ -87,6 +97,7 @@ if(NOT IS_MULTI_CONFIG) else() message(STATUS "Using multi-config generator that will determine build type on-the-fly") endif() +message(STATUS "Using LTO: ${lto}") message(STATUS "##################################################") include(install-paths) |