Allow builds on MSYS2 & improve Windows build steps documentation

This commit is contained in:
jdp_ 2024-08-20 12:26:35 -04:00
parent c60bfbe2a5
commit 34a1339a2b
2 changed files with 87 additions and 14 deletions

View File

@ -643,23 +643,40 @@ if (ENABLE_QT_GUI)
endif() endif()
if (WIN32) if (WIN32)
target_link_libraries(shadps4 PRIVATE mincore winpthreads clang_rt.builtins-x86_64.lib) target_link_libraries(shadps4 PRIVATE mincore winpthreads)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
if (MSVC)
# MSVC likes putting opinions on what people can use, disable:
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
endif()
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
if (MSVC) if (MSVC)
# Needed for conflicts with time.h of windows.h # Needed for conflicts with time.h of windows.h
add_definitions(-D_TIMESPEC_DEFINED) add_definitions(-D_TIMESPEC_DEFINED)
endif() endif()
# Target Windows 10 RS5 # Target Windows 10 RS5
add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00) add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
# Increase stack commit area
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000) if (MSVC)
target_link_libraries(shadps4 PRIVATE clang_rt.builtins-x86_64.lib)
endif()
# Disable ASLR so we can reserve the user area # Disable ASLR so we can reserve the user area
if (MSVC) if (MSVC)
target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO) target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO)
else() else()
target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase) target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase)
endif() endif()
# Increase stack commit area (Needed, otherwise there are crashes)
if (MSVC)
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000)
else()
target_link_options(shadps4 PRIVATE -Wl,--stack,2097152)
endif()
endif() endif()
if (WIN32) if (WIN32)

View File

@ -5,21 +5,77 @@ SPDX-License-Identifier: GPL-2.0-or-later
# Build shadPS4 for Windows # Build shadPS4 for Windows
## Download Visual Studio Community 2022 This tutorial reads as if you have none of the prerequisites already installed. If you do, just ignore the steps regarding installation.
If you are building to contribute to the project, please omit `--depth 1` from the git invokations.
Download link: [**Visual Studio 2022**](https://visualstudio.microsoft.com/vs/) Note: **ARM64 is not supported!** As of writing, it will not build nor run. The instructions with respect to ARM64 are for developers only.
## Requirements ## Option 1: Visual Studio 2022
### From Visual Studio Community ### (Prerequisite) Download the Community edition from [**Visual Studio 2022**](https://visualstudio.microsoft.com/vs/)
- Desktop development with C++ Once you are within the installer:
1. Select `Desktop development with C++`
2. Go to "Individual Components" tab
3. Make sure `C++ Clang Compiler for Windows`, `MSBuild support for LLVM` and `C++ CMake Tools for Windows` are selected
4. Continue the installation
### From individual components tab install ### (Prerequisite) Download [**Qt**](https://doc.qt.io/qt-6/get-and-install-qt.html)
- C++ Clang Compiler for Windows (17.0.3) Beware, this requires you to create a Qt account. If you do not want to do this, please follow the MSYS2/MinGW compilation method instead.
- MSBuild support for LLVM (Clang-cl) toolset
- ## Compiling 1. Select Qt for Visual Studio plugin
2. Select `msvc2019_64` option or similar. If you are on Windows on ARM / Qualcomm Snapdragon Elite X, select `msvc2019_arm64`
- Open Visual Studio Community and select the **x64-Clang-Release**, **x64-Clang-Debug** or **x64-Clang-RelWithDebInfo**. It should compile just fine. Go through the installation normally. If you do not know what components to select, just select the newest Qt version it gives you.
If you know what you are doing, you may unselect individual components that eat up too much disk space.
Once you are finished, you will have to configure Qt within Visual Studio:
1. Tools -> Options -> Qt -> Versions
2. Add a new Qt version and navigate it to the correct folder. Should look like so: `C:\Qt\6.7.1\msvc2019_64`
3. Enable the default checkmark on the new version you just created.
### (Prerequisite) Download [**Git for Windows**](https://git-scm.com/download/win)
Go through the Git for Windows installation as normal
### Compiling with Visual Studio GUI
1. Open Git for Windows, navigate to a place where you want to store the shadPS4 source code folder
2. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
3. Open up Visual Studio, select `Open a local folder` and select the folder with the shadPS4 source code. The folder should contain `CMakeLists.txt`
4. Build -> Build All
## Option 2: MSYS2/MinGW
### (Prerequisite) Download [**MSYS2**](https://www.msys2.org/)
Go through the MSYS2 installation as normal
If you are building to distribute, please omit `-DCMAKE_CXX_FLAGS="-O2 -march=native"` within the build configuration step.
Normal x86-based computers, follow:
1. Open "MSYS2 MINGW64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-x86_64-binutils mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-qt6-base`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
7. Run `cmake --build build`
8. To run the finished product, run `./build/shadPS4.exe`
ARM64-based computers, follow:
1. Open "MSYS2 CLANGARM64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-clang-aarch64-binutils mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-qt6-base`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
7. Run `cmake --build build`
8. To run the finished product, run `./build/shadPS4.exe`
## Note on MSYS2 builds
These builds may not be easily copyable to people who do not also have a MSYS2 installation.
If you want to distribute these builds, you need to copy over the correct DLLs into a distribution folder.
In order to run them, you must be within the MSYS2 shell environment.