diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2016-09-19 14:38:16 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-09-28 10:14:07 +0300 |
commit | 07c6c86874fef1e4aeccd37dc62cc009ba7212b8 (patch) | |
tree | c79906daa4a4054a0be2b85442d782179d09ad9a | |
parent | f093a5529cc925e18104e62764e209358c7a4ec2 (diff) |
Fix LTO detection
Catch gcc-ar and gcc-ranlib versions compiled without plugin support and
disable LTO in that case.
Also do the LTO check only once by checking if HAS_LTO_FLAG has been set.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 190119f..9214bfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,12 +35,27 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) # static link libc # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") -if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) +if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG AND NOT DEFINED HAS_LTO_FLAG) CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) if (HAS_LTO_FLAG) 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) + EXECUTE_PROCESS(COMMAND "${LTO_AR}" --version RESULT_VARIABLE ret OUTPUT_QUIET ERROR_QUIET) + if (ret) + unset(LTO_AR CACHE) + endif() + endif() + + if (LTO_RANLIB) + EXECUTE_PROCESS(COMMAND "${LTO_RANLIB}" --version RESULT_VARIABLE ret OUTPUT_QUIET ERROR_QUIET) + if (ret) + unset(LTO_RANLIB CACHE) + endif() + endif() + if (LTO_AR AND LTO_RANLIB) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") set(CMAKE_AR "${LTO_AR}") |