cmake: enable link time optimizations

This commit is contained in:
Sebastian Krzyszkowiak 2018-12-18 13:19:58 +01:00
parent db096e7e97
commit d20363e244
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF

View file

@ -99,7 +99,6 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -shared-libsan")
endif()
if(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-undefined,error")
@ -125,6 +124,21 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
endif()
endif()
if(POLICY CMP0069)
if(NOT USE_CLANG_TIDY) # clang-tidy + GCC + LTO = errors
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
message(STATUS "Link time optimization: ${IPO_SUPPORTED}")
if(IPO_SUPPORTED)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
endif()
endif()
endif()
option(LIBSUPERDERPY_STATIC "Compile and link libsuperderpy as a static library." OFF)
option(LIBSUPERDERPY_STATIC_DEPS "Link dependencies (e.g. Allegro) statically." OFF)