shadps4-emu Build Output Directory: Where Compiled Binaries Are Generated
shadps4-emu generates build artifacts in the CMake binary directory specified during configuration, defaulting to a build/ folder in the repository root where the shadps4 executable is created.
When compiling the shadPS4 PlayStation 4 emulator from source, understanding the shadps4-emu build output directory structure is essential for locating executables and managing your development workflow. The project uses a standard CMake build system that places all compiled binaries, intermediate objects, and final executables in a dedicated binary directory that you specify during the configuration phase.
Default Build Output Location in shadps4-emu
By convention, the shadPS4 documentation recommends creating a directory named build/ inside the repository root. When you invoke CMake with the -B option pointing to this directory, all build artifacts are generated there:
cmake -S . -B build/ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
This command establishes build/ as the binary directory (also called the build tree). According to the Linux build guide in documents/building-linux.md (lines 84-90 and 100-104), this is the standard approach for compiling the emulator.
After compilation completes, the main executable resides at:
./build/shadps4
How CMake Configures the Output Directory
The shadPS4 project relies on CMake's default output location behavior rather than overriding it. In the root CMakeLists.txt (lines 1104-1118), the add_executable(shadps4 ...) target is defined without modifying the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable.
Because the project does not override CMAKE_RUNTIME_OUTPUT_DIRECTORY, CMake defaults to placing the runtime executable in the binary directory itself. This means:
- Runtime binaries (the
shadps4executable) →${CMAKE_BINARY_DIR}/ - Library outputs →
${CMAKE_BINARY_DIR}/(unless overridden) - Archive outputs →
${CMAKE_BINARY_DIR}/(unless overridden)
The entry point in src/main.cpp is compiled into this executable, which then loads the emulator core libraries from the same directory structure.
Customizing the Build Output Directory
If you need to redirect build artifacts to a custom location, you can override CMake's output variables during configuration. This is useful for packaging, CI/CD pipelines, or keeping multiple build configurations (debug, release) separate.
To specify a custom runtime output directory:
cmake -S . -B out/ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=out/bin
cmake --build out/
After building, the executable would be located at out/bin/shadps4 instead of the default location.
For complete control over all output types, set these variables:
CMAKE_RUNTIME_OUTPUT_DIRECTORY— For executables likeshadps4CMAKE_LIBRARY_OUTPUT_DIRECTORY— For shared librariesCMAKE_ARCHIVE_OUTPUT_DIRECTORY— For static libraries
Building and Running the Emulator
Here is the complete workflow for building shadPS4 and locating the output:
# 1. Clone the repository
git clone https://github.com/shadps4-emu/shadPS4.git
cd shadPS4
# 2. Create the build directory and configure
cmake -S . -B build/ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
# 3. Compile using all available cores
cmake --build ./build --parallel$(nproc)
# 4. Verify the executable exists
ls -la ./build/shadps4
# 5. Run the emulator
./build/shadps4 --help
./build/shadps4 /path/to/your/game.iso
The src/main.cpp file contains the entry point that initializes the emulator core, loads configuration from config.toml, and starts the Qt-based GUI or headless mode depending on build options.
Summary
- shadps4-emu uses standard CMake conventions for its build output directory, defaulting to a
build/folder in the repository root. - The main executable is generated at
./build/shadps4because the project does not overrideCMAKE_RUNTIME_OUTPUT_DIRECTORY. - Configuration occurs in the root
CMakeLists.txt(lines 1104-1118), while build instructions are documented indocuments/building-linux.md. - You can customize output locations by setting
CMAKE_RUNTIME_OUTPUT_DIRECTORYduring the CMake configuration phase.
Frequently Asked Questions
Where is the shadps4 executable located after compilation?
By default, the shadps4 executable is located at ./build/shadps4 relative to the repository root. This assumes you followed the standard build instructions and used build/ as your CMake binary directory. If you specified a different directory with the -B option, the executable will be in that location instead.
Can I change the build output directory in shadps4-emu?
Yes, you can specify a custom build output directory by using CMake's -B option to set the binary directory, or by overriding CMAKE_RUNTIME_OUTPUT_DIRECTORY during configuration. For example: cmake -S . -B out/ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=out/bin. This flexibility allows you to maintain separate debug and release builds or integrate with custom packaging workflows.
Does shadps4-emu override CMake's default output locations?
No, the project does not override CMAKE_RUNTIME_OUTPUT_DIRECTORY, CMAKE_LIBRARY_OUTPUT_DIRECTORY, or CMAKE_ARCHIVE_OUTPUT_DIRECTORY in its root CMakeLists.txt. Because the add_executable(shadps4 ...) target at lines 1104-1118 relies on CMake defaults, all build artifacts are placed directly in the binary directory specified during configuration, following standard CMake behavior.
What CMake option specifies the build directory?
The -B option specifies the build directory (binary directory) where CMake generates build artifacts. For shadPS4, the standard invocation is cmake -S . -B build/, which creates and uses a build/ directory inside the repository. This directory contains all intermediate files, Makefiles or Ninja files, and the final shadps4 executable.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →