diff options
author | Arnout Vandecappelle (Essensium/Mind) | 2016-08-26 14:55:06 -0500 |
---|---|---|
committer | Arnout Vandecappelle (Essensium/Mind) | 2016-08-27 05:29:44 -0500 |
commit | 21113e024402057d878b4650ffba61b922552b86 (patch) | |
tree | 40d9208c76b7bb8f76bf742db944dcb440a28580 /CMakeLists.txt | |
parent | 86f3c44f768d6e49ad8cb2133e0ac3f6ed11baea (diff) | |
download | external-kmsxx-21113e024402057d878b4650ffba61b922552b86.tar.gz external-kmsxx-21113e024402057d878b4650ffba61b922552b86.tar.xz external-kmsxx-21113e024402057d878b4650ffba61b922552b86.zip |
Fix LTO support for cross-compilation.
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>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e5b5ea5..190119f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -39,9 +39,15 @@ if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) | |||
39 | CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) | 39 | CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) |
40 | 40 | ||
41 | if (HAS_LTO_FLAG) | 41 | if (HAS_LTO_FLAG) |
42 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") | 42 | find_program(LTO_AR NAMES "${CMAKE_C_COMPILER}-ar" gcc-ar) |
43 | set(CMAKE_AR gcc-ar) | 43 | find_program(LTO_RANLIB NAMES "${CMAKE_C_COMPILER}-ranlib" gcc-ranlib) |
44 | set(CMAKE_RANLIB gcc-ranlib) | 44 | if (LTO_AR AND LTO_RANLIB) |
45 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") | ||
46 | set(CMAKE_AR "${LTO_AR}") | ||
47 | set(CMAKE_RANLIB "${LTO_RANLIB}") | ||
48 | else() | ||
49 | message(STATUS "gcc-ar or gcc-ranlib not found, disabling LTO") | ||
50 | endif() | ||
45 | endif() | 51 | endif() |
46 | endif() | 52 | endif() |
47 | 53 | ||