aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadia Holmquist Pedersen <nadia@nhp.sh>2020-11-28 17:12:44 +0100
committerGitHub <noreply@github.com>2020-11-28 17:12:44 +0100
commit14be591ab8e769457678d5cac8536b2abfb3a94f (patch)
treeb30cd0d98d2f62d4bc6f6ea7e0c556aca981c9f0
parent1ff4a1564f951ef1a60fe2f55afe78aedede674a (diff)
Override CMAKE_AR/CMAKE_RANLIB, fixes flatpak builds, also use lld with clang if found (#828)
* Override CMAKE_AR/CMAKE_RANLIB, fixes flatpak builds, also use lld with clang if found * Ensure we build with -fPIC/-pie for LTO builds
-rw-r--r--CMakeLists.txt16
1 files changed, 14 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f34367f..04ad2a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,8 +74,20 @@ if (CMAKE_BUILD_TYPE STREQUAL Release)
endif()
if (ENABLE_LTO)
- add_compile_options(-flto)
- add_link_options(-flto -fuse-linker-plugin)
+ add_compile_options(-flto -fPIC)
+ add_link_options(-flto -fuse-linker-plugin -pie)
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set(CMAKE_AR "gcc-ar")
+ set(CMAKE_RANLIB "gcc-ranlib")
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ find_program(LLD NAMES ld.lld ld64.lld lld-link)
+ if (NOT LLD STREQUAL "LLD-NOTFOUND")
+ add_link_options(-fuse-ld=lld)
+ endif()
+ set(CMAKE_AR "llvm-ar")
+ set(CMAKE_RANLIB "llvm-ranlib")
endif()
option(BUILD_QT_SDL "Build Qt/SDL frontend" ON)