diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 0652520072..a8cad9c333 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -108,13 +108,15 @@ if(NOT MSVC) 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") - endif() - CHECK_C_COMPILER_FLAG("-nopie" HAS_NOPIE) - if(HAS_NOPIE) - if (NOT HAS_NO_PIE) + if(APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie") + else() + CHECK_C_COMPILER_FLAG("-no-pie" HAS_NO_PIE) + CHECK_C_COMPILER_FLAG("-nopie" HAS_NOPIE) + + if(HAS_NO_PIE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") + elseif(HAS_NOPIE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nopie") endif() endif()