Skip to content

Commit

Permalink
AWS_ENABLE_LTO=ON|OFF now controls LTO globally (#504)
Browse files Browse the repository at this point in the history
* AWS_ENABLE_LTO=ON|OFF now controls LTO globally

* Made AWS_ENABLE_LTO an option
  • Loading branch information
Justin Boswell authored Sep 11, 2019
1 parent 94351a9 commit 2c8ed74
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmake/AwsCFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ include(CheckCCompilerFlag)
include(CheckIncludeFile)
include(CMakeParseArguments) # needed for CMake v3.4 and lower

option(AWS_ENABLE_LTO "Enables LTO on libraries. Ensure this is set on all consumed targets, or linking will fail" OFF)

# This function will set all common flags on a target
# Options:
# NO_WGNU: Disable -Wgnu
Expand Down Expand Up @@ -119,14 +121,17 @@ function(aws_set_common_properties target)
list(APPEND AWS_C_DEFINES_PRIVATE -DDEBUG_BUILD)
else() # release build
if (POLICY CMP0069)
if (NOT SET_PROPERTIES_NO_LTO)
if ((NOT SET_PROPERTIES_NO_LTO) AND AWS_ENABLE_LTO)
cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler
include(CheckIPOSupported OPTIONAL RESULT_VARIABLE ipo_check_exists)
if (ipo_check_exists)
check_ipo_supported(RESULT ipo_supported)
if (ipo_supported)
message(STATUS "Enabling IPO/LTO for Release builds")
set(AWS_ENABLE_LTO ON)
else()
message(STATUS "AWS_ENABLE_LTO is enabled, but cmake/compiler does not support it, disabling")
set(AWS_ENABLE_LTO OFF)
endif()
endif()
endif()
Expand Down

0 comments on commit 2c8ed74

Please sign in to comment.