Build with LTO if the compiler supports it

This commit is contained in:
Sebastian Messmer 2021-01-06 20:42:07 -08:00
parent 353f287bde
commit 6927a7087a
4 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
# TODO Remove this deprecated policy switch once we're on cmake 3.4 or later
cmake_policy(SET CMP0065 OLD)
@ -37,6 +37,21 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE INTERNAL "CMAKE_BUILD_TYPE")
endif(NOT CMAKE_BUILD_TYPE)
# Enable LTO if we're in a release build and LTO is supported
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error)
if(LTO_SUPPORTED)
string(TOUPPER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE_UPPER)
if (_CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
message(STATUS "LTO disabled because we're in a debug build")
else()
message(STATUS "LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
else()
message(WARNING "LTO disabled because compiler does not support it.")
endif()
if(USE_CLANG_TIDY)
# note: for clang-tidy, we need cmake 3.6, or (if the return code should be handled correctly, e.g. on CI), we need 3.8.
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

View File

@ -3,9 +3,8 @@ Version 0.11.0 (unreleased)
Build changes:
* Switch to Conan package manager
* Allow an easy way to modify how the dependencies are found. This is mostly helpful for package maintainers.
Other changes:
* Now requires CMake 3.6 or later
* Build with LTO if the compiler supports it
* Now requires CMake 3.9 or later
Improvements:
* Display the file system configuration when mounting a file system

3
vendor/README vendored
View File

@ -5,4 +5,5 @@ cryptopp: https://github.com/weidai11/cryptopp/tree/CRYPTOPP_8_2_0
- changed: added CMakeLists.txt and cryptopp-config.cmake from https://github.com/noloader/cryptopp-cmake/tree/CRYPTOPP_8_2_0
- changed: commented out line including winapifamily.h in CMakeLists.txt
- changed: In CMakeLists.txt, rename BUILD_TESTING to CRYPTOPP_BUILD_TESTING so it doesn't clash with our BUILD_TESTING
- changed: Fix Android compilation using patch file https://github.com/termux/termux-root-packages/files/4664745/config.h.patch.txt from https://github.com/cryfs/cryfs/issues/345
- changed: In CmakeLists.txt, add cmake_policy(SET CMP0069 NEW) to silence a warning
- changed: Fix Android compilation using patch file https://github.com/termux/termux-root-packages/files/4664745/config.h.patch.txt from https://github.com/cryfs/cryfs/issues/345

View File

@ -30,6 +30,7 @@ endif()
message( STATUS "CMake version ${CMAKE_VERSION}" )
cmake_minimum_required(VERSION 2.8.6)
cmake_policy(SET CMP0069 NEW)
if (${CMAKE_VERSION} VERSION_LESS "3.0.0")
project(cryptopp)
set(cryptopp_VERSION_MAJOR 8)