Skip to content

Commit c93cfe6

Browse files
tobodnermarcomagdy
authored andcommitted
Make LTO optional in CMake
Currently, there is a verbose warning if LTO is not supported by the compiler. This change makes LTO optional, such that users can prevent the warning. The default behavior (enabled) is preserved.
1 parent 80bfd5d commit c93cfe6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: CMakeLists.txt

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ project(aws-lambda-runtime
44
VERSION 0.2.6
55
LANGUAGES CXX)
66

7+
option(ENABLE_LTO "Enables link-time optimization, requires compiler support." ON)
78
option(ENABLE_TESTS "Enables building the test project, requires AWS C++ SDK." OFF)
89

9-
include(CheckIPOSupported)
10-
1110
add_library(${PROJECT_NAME}
1211
"src/logging.cpp"
1312
"src/runtime.cpp"
@@ -23,11 +22,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC
2322
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2423
$<INSTALL_INTERFACE:include>)
2524

26-
check_ipo_supported(RESULT has_lto OUTPUT lto_check_output)
27-
if(has_lto)
28-
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
29-
else()
30-
message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}")
25+
if (ENABLE_LTO)
26+
include(CheckIPOSupported)
27+
check_ipo_supported(RESULT has_lto OUTPUT lto_check_output)
28+
if(has_lto)
29+
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
30+
else()
31+
message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}")
32+
endif()
3133
endif()
3234

3335
find_package(CURL REQUIRED)

0 commit comments

Comments
 (0)