Skip to content

Commit

Permalink
Override CMAKE_AR/CMAKE_RANLIB, fixes flatpak builds, also use lld wi…
Browse files Browse the repository at this point in the history
…th clang if found (melonDS-emu#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
  • Loading branch information
nadiaholmquist authored Nov 28, 2020
1 parent 1ff4a15 commit 14be591
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 14be591

Please sign in to comment.