diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index cb93340ab..f3af9bed7 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -38,12 +38,13 @@ jobs: include: - os: macos-latest cache_path: ~/Library/Caches/ccache + extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake - os: ubuntu-latest cache_path: ~/.ccache - extra_cmake_args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_DISCORD_RICH_PRESENCE=OFF + extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake -DUSE_DISCORD_RICH_PRESENCE=OFF - os: windows-latest cache_path: ~\AppData\Local\Mozilla\sccache - extra_cmake_args: -DBOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + extra_cmake_args: -DBOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64 -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/windows-x64.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache steps: - name: Set up build environment (macos-latest) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ebc466df3..09f4b5453 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -60,7 +60,7 @@ jobs: - name: Build run: | - cmake -B build -DCI=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_DISCORD_RICH_PRESENCE=OFF -G Ninja + cmake -B build -DCI=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake -DUSE_DISCORD_RICH_PRESENCE=OFF -G Ninja cmake --build build --config ${{ matrix.config }} - name: Perform CodeQL Analysis diff --git a/_building/vs-cmd-prompt.png b/_building/vs-cmd-prompt.png new file mode 100755 index 000000000..db39fbefc Binary files /dev/null and b/_building/vs-cmd-prompt.png differ diff --git a/building.md b/building.md index 558746ee2..2c6a78f4b 100644 --- a/building.md +++ b/building.md @@ -1,37 +1,69 @@ # Build Vita3K -## Windows (Visual Studio) +Vita3K uses CMake for its project configuration and generation and should in theory be compatible with any project generator supported by CMake, C++17 compatible compiler and IDE with CMake support. However, the following settings are recommended to be used when compiling or developing: +Target OS | Host OS | [Project generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) (`-G`) | C/C++ Compiler (`-DCMAKE_C_COMPILER` and `-DCMAKE_CXX_COMPILER`) +--- | --- | --- | --- +Windows | Windows | Visual Studio / MSBuild | `cl` a.k.a Microsoft Visual C/C++ Compiler (included as a part of the [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) and the ` Dekstop development with C++` Visual Studio workload) +macOS | macOS | Xcode | Clang (`clang` and `clang++`) +Linux | Linux | Ninja | Clang (`clang` and `clang++`) + +Vita3K also comes bundled with CMake toolchain files found in `./cmake/toolchain` for each target platform that automatically set up platform-specific variables such as the C/C++ compiler to the values shown in table above and must always be used when generating projects using CMake. Despite this, if needed the set values can be overwritten at project generation as well via CMake `-D` arguments and the project generator will be either the default one for the host OS platform or the one the person building the emulator decides to use. + +**Note: Vita3K doesn't support compilation for 32-bit/x86/i386 platforms.** + +For convenience, the following building instructions are given as examples based on the information from the table: + +## Windows + +### Visual Studio 2019 - Install Visual Studio 2019 and choose to install `Desktop development with C++`. You will get compiler and `cmake` required for building. -Example for Visual Studio 2019: + Example for Visual Studio 2019: - +  - Install `git` to `clone` the project. Download and install `git` from [here](https://git-scm.com). - Clone this repo. -```cmd -git clone --recursive https://github.com/Vita3K/Vita3K -cd Vita3K -``` + ```cmd + git clone --recursive https://github.com/Vita3K/Vita3K + cd Vita3K + ``` -- Open `Developer Command Prompt` for your respective Visual Studio version. `cmake` and other `C/C++` toolchain only available on `Developer Command Prompt`. +- Run Visual Studio 2019. 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 setup the project for you. +- Use the [CMake Settings Editor](https://docs.microsoft.com/en-us/cpp/build/customize-cmake-settings?view=msvc-160) to set "CMake toolchain file" to `./cmake/toolchain/windows-x64.cmake`. If asked to do so, delete and re-generate the CMake cache. -Example for Visual Studio 2019: +From there, the project will be ready to build right from the Visual Studio UI. - -- Run `gen-windows.bat` to create Visual Studio project in `build-windows` directory. +### Build using terminal +- Install: + - [Git](https://git-scm.com) + - [CMake](https://cmake.org/download/) + - Either the [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) or Visual Studio 2019 with the ` Dekstop development with C++` workload. +- On the Start Menu, open the `x64 Native Tools Command Prompt for Visual Studio 2019`. +
+
+