blob: 9a18d770c749d56f1cf9c8e3a75c6ea5bfc23cdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
function(check_lto)
if (DEFINED LTO_WORKS)
return()
endif()
set(LTO_WORKS FALSE CACHE INTERNAL "LTO works")
CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)
if (NOT HAS_LTO_FLAG)
return()
endif()
find_program(LTO_AR NAMES "${CMAKE_C_COMPILER}-ar" gcc-ar)
find_program(LTO_RANLIB NAMES "${CMAKE_C_COMPILER}-ranlib" gcc-ranlib)
if (NOT LTO_AR OR NOT LTO_RANLIB)
return()
endif()
EXECUTE_PROCESS(COMMAND "${LTO_AR}" --version RESULT_VARIABLE ret OUTPUT_QUIET ERROR_QUIET)
if (ret)
return()
endif()
EXECUTE_PROCESS(COMMAND "${LTO_RANLIB}" --version RESULT_VARIABLE ret OUTPUT_QUIET ERROR_QUIET)
if (ret)
return()
endif()
set(LTO_WORKS TRUE CACHE INTERNAL "LTO works")
endfunction()
|