Skip to content

Commit

Permalink
Merge pull request #810 from Hoikas/ipo
Browse files Browse the repository at this point in the history
Enable the /LTCG switch where applicable.
  • Loading branch information
zrax authored Feb 9, 2021
2 parents e7e29e5 + 3237d28 commit dc64629
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmake/CompilerChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
endif()

# Use LTCG if available.
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
include(CheckIPOSupported)
check_ipo_supported(RESULT _IPO_SUPPORTED LANGUAGES CXX OUTPUT _IPO_OUTPUT)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${_IPO_SUPPORTED} CACHE BOOL "Use link-time optimizations")
if(_IPO_SUPPORTED)
message(STATUS "IPO supported: using link-time optimizations")
else()
message(STATUS "IPO not supported: ${_IPO_OUTPUT}")
endif()
endif()

# Check for CPUID headers
try_compile(HAVE_CPUID ${PROJECT_BINARY_DIR}
Expand Down

0 comments on commit dc64629

Please sign in to comment.