Files
Vita3K/building.md

8.0 KiB

Build Vita3K

Vita3K uses CMake for its project configuration and generation. In theory, it should be compatible with any project generator supported by CMake, C++20 compatible compiler and an IDE with CMake support.

The project provides CMake presets to allow configuring and building Vita3K without having to deal with adding the needed arguments through a command-line interface or using the user interface of your IDE. As long as your IDE or code editor supports CMake, the software should immediately detect the presets and let you choose which configuration settings you want to use to generate the program. Reference on how to use CMake presets with various IDEs and code editors can be found here:

All presets are named after <target_os>-<project_generator>-<compiler>, are automatically hidden and shown depending on your host OS and generate a binary folder of path <source_directory>/build/<preset_name>. For command-line users, run cmake --list-presets on the top directory of the repository to see which presets are available to you. For presets without <project_generator> and/or <compiler>, the project generator and/or the compiler haven't been explicitly specified in the preset to let CMake fallback to the platform defaults.

If you still want to use presets but none of them works for your setup, you can make new ones by creating a CMakeUserPresets.json file and you can check the specification here. Git will ignore this file.

Note: Vita3K doesn't support compilation for 32-bit/x86/i386 platforms.

For convenience, the following building instructions are given as examples:

Windows

Visual Studio 2022

  • Install Visual Studio 2022 and choose to install Desktop development with C++. You will get compiler and cmake required for building.

    Example for Visual Studio 2019:

    Required tools for VS 2022

  • Install git to clone the project. Download and install git from here.

  • Install Qt (6.11.x or later), and select the MSVC 2022 64-bit component during installation.

  • Clone this repo.

    git clone --recursive https://github.com/Vita3K/Vita3K
    cd Vita3K
    
  • Run Visual Studio 2022. On the project selection window open the local clone of the repository as a folder. Thanks to the integration between Visual Studio and CMake, Visual Studio will automatically detect the repository as a CMake project.

  • Wait for all components for Visual Studio to be loaded. At the top of the window, there should be three new menus that allow you to select the target (specific to Visual Studio), a CMake configure preset and a CMake build preset (if available). Recommended preset for Visual Studio 2022 is Windows with Visual Studio 2022.

From there, the project will be ready to build right from the Visual Studio UI.

If you aren't satisfied with the way the Visual Studio integrates CMake projects and you would like to just use regular Visual Studio solution files (.sln), you can close Visual Studio and then open the solution file found in build/<preset_name>/.

Build using terminal

  • Install:

  • On the Start Menu, open the x64 Native Tools Command Prompt for Visual Studio 2022.

  • Clone the repository:

    git clone --recursive https://github.com/Vita3K/Vita3K
    cd Vita3K
    
  • Generate the project:

    set Qt6_ROOT=C:\Qt\6.11.0\msvc2022_64
    cmake --preset windows-vs2022
    

    The line above will generate a Visual Studio 2022 project inside a folder called build/windows-vs2022.

  • Build the project:

    cmake --build build/windows-vs2022
    

macOS (Xcode)

  • Install Xcode at App Store.

  • Install brew.

  • Install dependencies with brew.

    brew install git cmake molten-vk openssl qt
    

    Ensure brew provides Qt 6.11 or newer. If it does not, install the official Qt 6.11 package and set Qt6_ROOT before configuring.

  • Clone this repo.

    git clone --recursive https://github.com/Vita3K/Vita3K
    cd Vita3K
    
  • Generate Xcode project.

    cmake --preset macos-xcode
    

    This example will generate a Xcode project inside a folder called build/macos-xcode.

  • Open Xcode project vita3k.xcodeproj generated in build/macos-xcode directory.

  • When prompted to create schemes, create one for the vita3k target only. The project builds many targets, so it will make your life easier if you create schemes as needed.

  • Build the project using the Xcode UI. If needed, the build process can be invoked as well the same way as with the other platforms using a terminal:

    cmake --build build/macos-xcode
    

Linux

  • Install dependencies.

Ubuntu/Debian

sudo apt install git cmake ninja-build libsdl2-dev pkg-config libgtk-3-dev clang lld xdg-desktop-portal openssl libssl-dev qt6-base-dev

Fedora

sudo dnf install git cmake ninja-build SDL2-devel pkg-config gtk3-devel clang lld xdg-desktop-portal openssl openssl-devel libstdc++-static qt6-qtbase-devel

Note: Your Qt packages must provide Qt 6.11 or newer. If your distro ships an older Qt, install the official Qt 6.11 package and set Qt6_ROOT before running CMake.

Note: The CMake preset linux-ninja-clang makes use of the LLD linker, which will need to be installed in your system along with Clang.

  • Clone this repo.

    git clone --recursive https://github.com/Vita3K/Vita3K
    cd Vita3K
    
  • Generate the project.

    cmake --preset linux-ninja-clang
    

    This example will generate a Ninja Multi-Config (ninja-build) project instead of a Make (make, the default project generator for Linux) one inside the folder build/linux-ninja-clang.

  • Build the project:

    cmake --build build/linux-ninja-clang
    

Android

  • Building the Android version requires both the Android SDK and Android NDK, both can be installed from Android Studio. You will need to set the environment variable ANDROID_NDK_HOME (and ANDROID_SDK_HOME when not using Android Studio) to their proper location.

  • The Android version of Vita3K relies on vcpkg to build some of its dependencies.

    vcpkg install --triplet arm64-android
    vcpkg install --triplet x64-android
    

    Run these commands from the repository root so vcpkg can consume the repository's vcpkg.json manifest. You will also need to set the environment variable VCPKG_ROOT to its proper location.

  • Building can be done with Android studio: select the Vita3K Android folder and click on the build icon or by command line:

    ./gradlew --stacktrace assembleReldebug
    

Note

  • After cloning or checking out a branch, you should always update submodules.

    git submodule update --init --recursive
    
  • If Boost failed to build, you can use the system Boost package (Linux and macOS only).

    brew install boost # for macOS
    sudo apt install libboost-filesystem-dev libboost-program-options-dev libboost-system-dev # for Ubuntu/Debian
    

    If needed, CMake options VITA3K_FORCE_CUSTOM_BOOST and VITA3K_FORCE_SYSTEM_BOOST can be set to change the way the CMake project looks for Boost.