Cmake build: Use interprocedural optimization if possible

With gnu compilers this adds -flto and -fno-fat-lto-objects
to compiler and linker flags.
This commit is contained in:
Kornel Benko 2019-04-22 18:49:03 +02:00
parent 89121a664a
commit 7d021a938c
5 changed files with 34 additions and 4 deletions

View File

@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
project(hunspell)

View File

@ -5,7 +5,12 @@
# Please note that the package source code is licensed under its own license.
project ( libiconv C )
cmake_minimum_required ( VERSION 2.8 )
cmake_minimum_required(VERSION 3.1)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
set(CMAKE_MODULE_PATH .)
include ( configure.cmake )

View File

@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
set(VERSION "1.2.5")
set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${VERSION})

View File

@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 2.4.4)
cmake_minimum_required(VERSION 3.1)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)

View File

@ -81,6 +81,18 @@ if(NOT help AND NOT HELP)
message(FATAL_ERROR "Exiting")
endif()
endif()
# Enable LTO if supported
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT reason LANGUAGES CXX)
if(result)
message(STATUS "Setting IPO True")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "Not setting IPO , result = ${result}, reason = ${reason}")
endif()
endif()
endif()
if(UNIX)