diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 2edf366e59..c216a4d471 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0.2) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") set(RES_FILES "") set(CMAKE_CXX_STANDARD 14) +include(CheckCCompilerFlag) # Qt section find_package(Qt5 5.7 COMPONENTS Widgets) @@ -104,6 +105,17 @@ if(NOT MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -image-base=0x10000") endif() + # Some distros have the compilers set to use PIE by default, but RPCS3 doesn't work with PIE, so we need to disable it. + CHECK_C_COMPILER_FLAG("-no-pie" HAS_NO_PIE) + if(HAS_NO_PIE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") + else() + CHECK_C_COMPILER_FLAG("-nopie" HAS_NO_PIE) + if(HAS_NO_PIE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nopie") + endif() + endif() + find_package(GLEW REQUIRED) find_package(ZLIB REQUIRED) else()