From 1b0a24a9bd39cfd5c7cb5912eb826213a82c6cde Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Sat, 14 Nov 2020 13:29:47 +0100 Subject: [PATCH] Fix LTO builds with Clang (#815) --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e672ed68..cce9d6d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,17 +65,19 @@ if (CMAKE_BUILD_TYPE STREQUAL Release) add_link_options(-s) endif() -add_link_options(-no-pie) - if (ENABLE_LTO) add_compile_options(-flto) add_link_options(-flto) - set(CMAKE_AR "gcc-ar") - set(CMAKE_C_ARCHIVE_CREATE " qcs ") - set(CMAKE_C_ARCHIVE_FINISH true) - set(CMAKE_CXX_ARCHIVE_CREATE " qcs ") - set(CMAKE_CXX_ARCHIVE_FINISH true) + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(CMAKE_AR "gcc-ar") + set(CMAKE_C_ARCHIVE_CREATE " qcs ") + set(CMAKE_C_ARCHIVE_FINISH true) + set(CMAKE_CXX_ARCHIVE_CREATE " qcs ") + set(CMAKE_CXX_ARCHIVE_FINISH true) + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + set(CMAKE_AR "llvm-ar") + endif() endif() option(BUILD_QT_SDL "Build Qt/SDL frontend" ON)