Skip to content

Commit

Permalink
cmake: try to use link-time optimizations (otland#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt authored and DSpeichert committed Jan 2, 2018
1 parent 76ffcee commit bdd4870
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
endif()

include(FindCXX11)
include(FindLTO)

# Find packages.
find_package(GMP REQUIRED)
Expand Down
12 changes: 12 additions & 0 deletions cmake/FindLTO.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if(__FIND_LTO_CMAKE__)
return()
endif()
set(__FIND_LTO_CMAKE__ TRUE)

include(CheckCXXCompilerFlag)
enable_language(CXX)

check_cxx_compiler_flag("-flto" COMPILER_KNOWS_LTO)
if(COMPILER_KNOWS_LTO)
add_compile_options(-flto)
endif()

0 comments on commit bdd4870

Please sign in to comment.