CMake: Add support for CMAKE_LTO option.

This enables Link Time Optimization. LTO is a proven technique for
optimizing across compilation units.

Closes #4799
This commit is contained in:
Tobias Hieta 2020-01-09 12:10:55 +01:00 committed by Daniel Stenberg
parent f128c00a99
commit 4ccf7622db
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 30 additions and 0 deletions

View file

@ -96,6 +96,12 @@ endif()
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
if(CURL_HAS_LTO)
set_target_properties(${LIB_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
endif()
if(WIN32)
if(BUILD_SHARED_LIBS)
# Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"