summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 86f3c44)
raw | patch | inline | side by side (parent: 86f3c44)
author | Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> | |
Fri, 26 Aug 2016 19:55:06 +0000 (21:55 +0200) | ||
committer | Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> | |
Sat, 27 Aug 2016 10:29:44 +0000 (12:29 +0200) |
When cross-compiling, the ar and ranlib to be used for LTO are prefixed
by the cross-tuple. gcc-ar and gcc-ranlib may not exist. Cfr.
http://autobuild.buildroot.net/results/f3c/f3c48da3a9706cd366c0e0a96c3cd0ff959f2a78/
Therefore, search for an appropriate lto-ar and lto-ranlib before
enabling LTO.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
by the cross-tuple. gcc-ar and gcc-ranlib may not exist. Cfr.
http://autobuild.buildroot.net/results/f3c/f3c48da3a9706cd366c0e0a96c3cd0ff959f2a78/
Therefore, search for an appropriate lto-ar and lto-ranlib before
enabling LTO.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
CMakeLists.txt | patch | blob | history |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5b5ea568e7bc5bf2ab62cae105f5654a0457ff9..190119f93646a65e4ebb1f5d211b0107defe67ef 100644 (file)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)
if (HAS_LTO_FLAG)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
- set(CMAKE_AR gcc-ar)
- set(CMAKE_RANLIB gcc-ranlib)
+ find_program(LTO_AR NAMES "${CMAKE_C_COMPILER}-ar" gcc-ar)
+ find_program(LTO_RANLIB NAMES "${CMAKE_C_COMPILER}-ranlib" gcc-ranlib)
+ if (LTO_AR AND LTO_RANLIB)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
+ set(CMAKE_AR "${LTO_AR}")
+ set(CMAKE_RANLIB "${LTO_RANLIB}")
+ else()
+ message(STATUS "gcc-ar or gcc-ranlib not found, disabling LTO")
+ endif()
endif()
endif()