diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2018-10-19 12:53:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-10-25 15:52:43 (GMT) |
commit | 786dddc0fd0439b7f7ba1f062d60720f16627856 (patch) | |
tree | 2f0ce0220d74ad8dde4ddd921f63b898bdca7fae /CMakeLists.txt | |
parent | 53e65e8e0a91f7b83e2f0f27781e75c2868a321d (diff) | |
download | CMake-786dddc0fd0439b7f7ba1f062d60720f16627856.zip CMake-786dddc0fd0439b7f7ba1f062d60720f16627856.tar.gz CMake-786dddc0fd0439b7f7ba1f062d60720f16627856.tar.bz2 |
Add option to build CMake itself with IPO/LTO
Create a `CMake_BUILD_LTO` option when building with a CMake that
is new enough to support `CheckIPOSupported` everywhere.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e94503c..756e379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,18 @@ option(CMake_BUILD_DEVELOPER_REFERENCE "Build CMake Developer Reference" OFF) mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE) +# option to build using interprocedural optimizations (IPO/LTO) +if (NOT CMAKE_VERSION VERSION_LESS 3.12.2) + option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF) + if(CMake_BUILD_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT HAVE_IPO) + if(HAVE_IPO) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + endif() +endif() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script |