PKGNAME=pcsx2
PKGSEC=games
PKGDEP="curl ffmpeg fmt freetype kddockwidgets libjpeg-turbo libpcap \
        libpng libwebp libxkbcommon lz4 plutosvg qt-6 shaderc sdl3 \
        vulkan wayland zlib zstd"
BUILDDEP="extra-cmake-modules llvm"
PKGDES="Emulator for PlayStation 2"

ABTYPE=cmakeninja
CMAKE_AFTER=(
   '-DENABLE_QT_UI=ON'
   '-DENABLE_SETCAP=OFF'
   '-DENABLE_TESTS=OFF'
   '-DENABLE_GSRUNNER=ON'
   # Note: Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else
   '-DLTO_PCSX2_CORE=ON'
   # Note: Use this option to ease packaging of PCSX2 (developer/distribution option)
   '-DPACKAGE_MODE=ON'
   '-DUSE_ASAN=OFF'
   '-DUSE_BACKTRACE=ON'
   '-DUSE_LINKED_FFMPEG=ON'
   # Note: Plug VTUNE to profile GS JIT
   '-DUSE_VTUNE=OFF'
   '-DUSE_OPENGL=ON'
   '-DUSE_VULKAN=ON'
   '-DWAYLAND_API=ON'
   '-DX11_API=ON'
   '-DUSE_SYSTEM_LIBS=ON'
   # Note: -march=native would be otherwise specified
   '-DDISABLE_ADVANCE_SIMD=ON'
)

# Note: PCSX2 wants to be built with Clang.
#
#   *************** UNSUPPORTED CONFIGURATION ***************
#
#   You are not compiling PCSX2 with a supported compiler.
#
#   It may not even build successfully.
#
#   PCSX2 only supports the Clang and MSVC compilers.
#
#   No support will be provided, continue at your own risk.
#
#   *********************************************************
USECLANG=1

# FIXME: Limited architecture support.
FAIL_ARCH="!(amd64)"
