Skip to content

Commit

Permalink
Add option to build CMake itself with IPO/LTO
Browse files Browse the repository at this point in the history
Create a `CMake_BUILD_LTO` option when building with a CMake that
is new enough to support `CheckIPOSupported` everywhere.
  • Loading branch information
cristianadam authored and bradking committed Oct 25, 2018
1 parent 53e65e8 commit 786dddc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 786dddc

Please sign in to comment.