Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMakePresets.json file to make building Player much easier #2878

Merged
merged 10 commits into from
Mar 5, 2023

Conversation

Ghabry
Copy link
Member

@Ghabry Ghabry commented Jan 2, 2023

Initial version of the CMakePresets.json.

This makes configuring with CMake a bit easier because you can omit some of the verbose commands ;).

Also created a python script because of combinatorics... The resulting file is imo a bit ugly (More than 2000 lines (!)) due to limitations in the presets format.

Following environment variables are required (except for the "system environment" presets)

  • EASYRPG_BUILDSCRIPTS: Path to easyrpg buildscripts repository
  • DEVKITPRO: (dkp only) Path to devkitPro install

If you do not want to provide them look in builds/cmake/CMakePresetsUser.json. This file provides an extension point :).

Example usage: To create a Release (With Debug symbols) build for 3DS that builds liblcf do:

cmake --preset 3ds-liblcf-relwithdebinfo

The output folder will be build/3ds-relwithdebinfo. This can be changed as usual with -B. Additional parameters can be added as usual with -D. So if you do not like a default it can still be changed.

To create a visual studio 2022 solution for x64 windows that does not build liblcf but a libretro core in debug mode:

cmake --preset windows-x64-vs2022-libretro-debug

How VSCode represents it when loading the folder. So you can just open it in VsCode or any other tool that supports presets and are good to go :).

Screenshot_20230102_125511

Screenshot_20230102_125554


Note: Windows stuff is omitted on non-Windows systems.

$ cmake --list-presets

Available configure presets:

  "debug"                                             - Use system environment (Debug)
  "relwithdebinfo"                                    - Use system environment (RelWithDebInfo)
  "release"                                           - Use system environment (Release)
  "liblcf-debug"                                      - Use system environment + Build liblcf (Debug)
  "liblcf-relwithdebinfo"                             - Use system environment + Build liblcf (RelWithDebInfo)
  "liblcf-release"                                    - Use system environment + Build liblcf (Release)
  "libretro-debug"                                    - Use system environment (libretro core) (Debug)
  "libretro-relwithdebinfo"                           - Use system environment (libretro core) (RelWithDebInfo)
  "libretro-release"                                  - Use system environment (libretro core) (Release)
  "libretro-liblcf-debug"                             - Use system environment (libretro core) + Build liblcf (Debug)
  "libretro-liblcf-relwithdebinfo"                    - Use system environment (libretro core) + Build liblcf (RelWithDebInfo)
  "libretro-liblcf-release"                           - Use system environment (libretro core) + Build liblcf (Release)
  "linux-debug"                                       - Linux (Debug)
  "linux-relwithdebinfo"                              - Linux (RelWithDebInfo)
  "linux-release"                                     - Linux (Release)
  "linux-liblcf-debug"                                - Linux + Build liblcf (Debug)
  "linux-liblcf-relwithdebinfo"                       - Linux + Build liblcf (RelWithDebInfo)
  "linux-liblcf-release"                              - Linux + Build liblcf (Release)
  "linux-libretro-debug"                              - Linux (libretro core) (Debug)
  "linux-libretro-relwithdebinfo"                     - Linux (libretro core) (RelWithDebInfo)
  "linux-libretro-release"                            - Linux (libretro core) (Release)
  "linux-libretro-liblcf-debug"                       - Linux (libretro core) + Build liblcf (Debug)
  "linux-libretro-liblcf-relwithdebinfo"              - Linux (libretro core) + Build liblcf (RelWithDebInfo)
  "linux-libretro-liblcf-release"                     - Linux (libretro core) + Build liblcf (Release)
  "windows-x86-debug"                                 - Windows (x86) (Debug)
  "windows-x86-relwithdebinfo"                        - Windows (x86) (RelWithDebInfo)
  "windows-x86-release"                               - Windows (x86) (Release)
  "windows-x86-liblcf-debug"                          - Windows (x86) + Build liblcf (Debug)
  "windows-x86-liblcf-relwithdebinfo"                 - Windows (x86) + Build liblcf (RelWithDebInfo)
  "windows-x86-liblcf-release"                        - Windows (x86) + Build liblcf (Release)
  "windows-x86-libretro-debug"                        - Windows (x86) (libretro core) (Debug)
  "windows-x86-libretro-relwithdebinfo"               - Windows (x86) (libretro core) (RelWithDebInfo)
  "windows-x86-libretro-release"                      - Windows (x86) (libretro core) (Release)
  "windows-x86-libretro-liblcf-debug"                 - Windows (x86) (libretro core) + Build liblcf (Debug)
  "windows-x86-libretro-liblcf-relwithdebinfo"        - Windows (x86) (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x86-libretro-liblcf-release"               - Windows (x86) (libretro core) + Build liblcf (Release)
  "windows-x86-vs2019-debug"                          - Windows (x86) using Visual Studio 2019 (Debug)
  "windows-x86-vs2019-relwithdebinfo"                 - Windows (x86) using Visual Studio 2019 (RelWithDebInfo)
  "windows-x86-vs2019-release"                        - Windows (x86) using Visual Studio 2019 (Release)
  "windows-x86-vs2019-liblcf-debug"                   - Windows (x86) using Visual Studio 2019 + Build liblcf (Debug)
  "windows-x86-vs2019-liblcf-relwithdebinfo"          - Windows (x86) using Visual Studio 2019 + Build liblcf (RelWithDebInfo)
  "windows-x86-vs2019-liblcf-release"                 - Windows (x86) using Visual Studio 2019 + Build liblcf (Release)
  "windows-x86-vs2019-libretro-debug"                 - Windows (x86) using Visual Studio 2019 (libretro core) (Debug)
  "windows-x86-vs2019-libretro-relwithdebinfo"        - Windows (x86) using Visual Studio 2019 (libretro core) (RelWithDebInfo)
  "windows-x86-vs2019-libretro-release"               - Windows (x86) using Visual Studio 2019 (libretro core) (Release)
  "windows-x86-vs2019-libretro-liblcf-debug"          - Windows (x86) using Visual Studio 2019 (libretro core) + Build liblcf (Debug)
  "windows-x86-vs2019-libretro-liblcf-relwithdebinfo" - Windows (x86) using Visual Studio 2019 (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x86-vs2019-libretro-liblcf-release"        - Windows (x86) using Visual Studio 2019 (libretro core) + Build liblcf (Release)
  "windows-x86-vs2022-debug"                          - Windows (x86) using Visual Studio 2022 (Debug)
  "windows-x86-vs2022-relwithdebinfo"                 - Windows (x86) using Visual Studio 2022 (RelWithDebInfo)
  "windows-x86-vs2022-release"                        - Windows (x86) using Visual Studio 2022 (Release)
  "windows-x86-vs2022-liblcf-debug"                   - Windows (x86) using Visual Studio 2022 + Build liblcf (Debug)
  "windows-x86-vs2022-liblcf-relwithdebinfo"          - Windows (x86) using Visual Studio 2022 + Build liblcf (RelWithDebInfo)
  "windows-x86-vs2022-liblcf-release"                 - Windows (x86) using Visual Studio 2022 + Build liblcf (Release)
  "windows-x86-vs2022-libretro-debug"                 - Windows (x86) using Visual Studio 2022 (libretro core) (Debug)
  "windows-x86-vs2022-libretro-relwithdebinfo"        - Windows (x86) using Visual Studio 2022 (libretro core) (RelWithDebInfo)
  "windows-x86-vs2022-libretro-release"               - Windows (x86) using Visual Studio 2022 (libretro core) (Release)
  "windows-x86-vs2022-libretro-liblcf-debug"          - Windows (x86) using Visual Studio 2022 (libretro core) + Build liblcf (Debug)
  "windows-x86-vs2022-libretro-liblcf-relwithdebinfo" - Windows (x86) using Visual Studio 2022 (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x86-vs2022-libretro-liblcf-release"        - Windows (x86) using Visual Studio 2022 (libretro core) + Build liblcf (Release)
  "windows-x64-debug"                                 - Windows (x64) (Debug)
  "windows-x64-relwithdebinfo"                        - Windows (x64) (RelWithDebInfo)
  "windows-x64-release"                               - Windows (x64) (Release)
  "windows-x64-liblcf-debug"                          - Windows (x64) + Build liblcf (Debug)
  "windows-x64-liblcf-relwithdebinfo"                 - Windows (x64) + Build liblcf (RelWithDebInfo)
  "windows-x64-liblcf-release"                        - Windows (x64) + Build liblcf (Release)
  "windows-x64-libretro-debug"                        - Windows (x64) (libretro core) (Debug)
  "windows-x64-libretro-relwithdebinfo"               - Windows (x64) (libretro core) (RelWithDebInfo)
  "windows-x64-libretro-release"                      - Windows (x64) (libretro core) (Release)
  "windows-x64-libretro-liblcf-debug"                 - Windows (x64) (libretro core) + Build liblcf (Debug)
  "windows-x64-libretro-liblcf-relwithdebinfo"        - Windows (x64) (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x64-libretro-liblcf-release"               - Windows (x64) (libretro core) + Build liblcf (Release)
  "windows-x64-vs2019-debug"                          - Windows (x64) using Visual Studio 2019 (Debug)
  "windows-x64-vs2019-relwithdebinfo"                 - Windows (x64) using Visual Studio 2019 (RelWithDebInfo)
  "windows-x64-vs2019-release"                        - Windows (x64) using Visual Studio 2019 (Release)
  "windows-x64-vs2019-liblcf-debug"                   - Windows (x64) using Visual Studio 2019 + Build liblcf (Debug)
  "windows-x64-vs2019-liblcf-relwithdebinfo"          - Windows (x64) using Visual Studio 2019 + Build liblcf (RelWithDebInfo)
  "windows-x64-vs2019-liblcf-release"                 - Windows (x64) using Visual Studio 2019 + Build liblcf (Release)
  "windows-x64-vs2019-libretro-debug"                 - Windows (x64) using Visual Studio 2019 (libretro core) (Debug)
  "windows-x64-vs2019-libretro-relwithdebinfo"        - Windows (x64) using Visual Studio 2019 (libretro core) (RelWithDebInfo)
  "windows-x64-vs2019-libretro-release"               - Windows (x64) using Visual Studio 2019 (libretro core) (Release)
  "windows-x64-vs2019-libretro-liblcf-debug"          - Windows (x64) using Visual Studio 2019 (libretro core) + Build liblcf (Debug)
  "windows-x64-vs2019-libretro-liblcf-relwithdebinfo" - Windows (x64) using Visual Studio 2019 (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x64-vs2019-libretro-liblcf-release"        - Windows (x64) using Visual Studio 2019 (libretro core) + Build liblcf (Release)
  "windows-x64-vs2022-debug"                          - Windows (x64) using Visual Studio 2022 (Debug)
  "windows-x64-vs2022-relwithdebinfo"                 - Windows (x64) using Visual Studio 2022 (RelWithDebInfo)
  "windows-x64-vs2022-release"                        - Windows (x64) using Visual Studio 2022 (Release)
  "windows-x64-vs2022-liblcf-debug"                   - Windows (x64) using Visual Studio 2022 + Build liblcf (Debug)
  "windows-x64-vs2022-liblcf-relwithdebinfo"          - Windows (x64) using Visual Studio 2022 + Build liblcf (RelWithDebInfo)
  "windows-x64-vs2022-liblcf-release"                 - Windows (x64) using Visual Studio 2022 + Build liblcf (Release)
  "windows-x64-vs2022-libretro-debug"                 - Windows (x64) using Visual Studio 2022 (libretro core) (Debug)
  "windows-x64-vs2022-libretro-relwithdebinfo"        - Windows (x64) using Visual Studio 2022 (libretro core) (RelWithDebInfo)
  "windows-x64-vs2022-libretro-release"               - Windows (x64) using Visual Studio 2022 (libretro core) (Release)
  "windows-x64-vs2022-libretro-liblcf-debug"          - Windows (x64) using Visual Studio 2022 (libretro core) + Build liblcf (Debug)
  "windows-x64-vs2022-libretro-liblcf-relwithdebinfo" - Windows (x64) using Visual Studio 2022 (libretro core) + Build liblcf (RelWithDebInfo)
  "windows-x64-vs2022-libretro-liblcf-release"        - Windows (x64) using Visual Studio 2022 (libretro core) + Build liblcf (Release)
  "emscripten-debug"                                  - Emscripten (Web) (Debug)
  "emscripten-relwithdebinfo"                         - Emscripten (Web) (RelWithDebInfo)
  "emscripten-release"                                - Emscripten (Web) (Release)
  "emscripten-liblcf-debug"                           - Emscripten (Web) + Build liblcf (Debug)
  "emscripten-liblcf-relwithdebinfo"                  - Emscripten (Web) + Build liblcf (RelWithDebInfo)
  "emscripten-liblcf-release"                         - Emscripten (Web) + Build liblcf (Release)
  "3ds-debug"                                         - Nintendo 3DS (Debug)
  "3ds-relwithdebinfo"                                - Nintendo 3DS (RelWithDebInfo)
  "3ds-release"                                       - Nintendo 3DS (Release)
  "3ds-liblcf-debug"                                  - Nintendo 3DS + Build liblcf (Debug)
  "3ds-liblcf-relwithdebinfo"                         - Nintendo 3DS + Build liblcf (RelWithDebInfo)
  "3ds-liblcf-release"                                - Nintendo 3DS + Build liblcf (Release)
  "3ds-libretro-debug"                                - Nintendo 3DS (libretro core) (Debug)
  "3ds-libretro-relwithdebinfo"                       - Nintendo 3DS (libretro core) (RelWithDebInfo)
  "3ds-libretro-release"                              - Nintendo 3DS (libretro core) (Release)
  "3ds-libretro-liblcf-debug"                         - Nintendo 3DS (libretro core) + Build liblcf (Debug)
  "3ds-libretro-liblcf-relwithdebinfo"                - Nintendo 3DS (libretro core) + Build liblcf (RelWithDebInfo)
  "3ds-libretro-liblcf-release"                       - Nintendo 3DS (libretro core) + Build liblcf (Release)
  "switch-debug"                                      - Nintendo Switch (Debug)
  "switch-relwithdebinfo"                             - Nintendo Switch (RelWithDebInfo)
  "switch-release"                                    - Nintendo Switch (Release)
  "switch-liblcf-debug"                               - Nintendo Switch + Build liblcf (Debug)
  "switch-liblcf-relwithdebinfo"                      - Nintendo Switch + Build liblcf (RelWithDebInfo)
  "switch-liblcf-release"                             - Nintendo Switch + Build liblcf (Release)
  "switch-libretro-debug"                             - Nintendo Switch (libretro core) (Debug)
  "switch-libretro-relwithdebinfo"                    - Nintendo Switch (libretro core) (RelWithDebInfo)
  "switch-libretro-release"                           - Nintendo Switch (libretro core) (Release)
  "switch-libretro-liblcf-debug"                      - Nintendo Switch (libretro core) + Build liblcf (Debug)
  "switch-libretro-liblcf-relwithdebinfo"             - Nintendo Switch (libretro core) + Build liblcf (RelWithDebInfo)
  "switch-libretro-liblcf-release"                    - Nintendo Switch (libretro core) + Build liblcf (Release)
  "wii-debug"                                         - Nintendo Wii (Debug)
  "wii-relwithdebinfo"                                - Nintendo Wii (RelWithDebInfo)
  "wii-release"                                       - Nintendo Wii (Release)
  "wii-liblcf-debug"                                  - Nintendo Wii + Build liblcf (Debug)
  "wii-liblcf-relwithdebinfo"                         - Nintendo Wii + Build liblcf (RelWithDebInfo)
  "wii-liblcf-release"                                - Nintendo Wii + Build liblcf (Release)
  "wii-libretro-debug"                                - Nintendo Wii (libretro core) (Debug)
  "wii-libretro-relwithdebinfo"                       - Nintendo Wii (libretro core) (RelWithDebInfo)
  "wii-libretro-release"                              - Nintendo Wii (libretro core) (Release)
  "wii-libretro-liblcf-debug"                         - Nintendo Wii (libretro core) + Build liblcf (Debug)
  "wii-libretro-liblcf-relwithdebinfo"                - Nintendo Wii (libretro core) + Build liblcf (RelWithDebInfo)
  "wii-libretro-liblcf-release"                       - Nintendo Wii (libretro core) + Build liblcf (Release)
  "psvita-debug"                                      - PlayStation Vita (Debug)
  "psvita-relwithdebinfo"                             - PlayStation Vita (RelWithDebInfo)
  "psvita-release"                                    - PlayStation Vita (Release)
  "psvita-liblcf-debug"                               - PlayStation Vita + Build liblcf (Debug)
  "psvita-liblcf-relwithdebinfo"                      - PlayStation Vita + Build liblcf (RelWithDebInfo)
  "psvita-liblcf-release"                             - PlayStation Vita + Build liblcf (Release)
  "psvita-libretro-debug"                             - PlayStation Vita (libretro core) (Debug)
  "psvita-libretro-relwithdebinfo"                    - PlayStation Vita (libretro core) (RelWithDebInfo)
  "psvita-libretro-release"                           - PlayStation Vita (libretro core) (Release)
  "psvita-libretro-liblcf-debug"                      - PlayStation Vita (libretro core) + Build liblcf (Debug)
  "psvita-libretro-liblcf-relwithdebinfo"             - PlayStation Vita (libretro core) + Build liblcf (RelWithDebInfo)
  "psvita-libretro-liblcf-release"                    - PlayStation Vita (libretro core) + Build liblcf (Release)

@Ghabry Ghabry added the Building label Jan 2, 2023
@Ghabry Ghabry added this to the 0.7.1 milestone Jan 2, 2023
@carstene1ns
Copy link
Member

Should add some "generated" tag for the presets file:

src/bitmapfont_rmg2000.h -diff linguist-generated

@Ghabry
Copy link
Member Author

Ghabry commented Jan 3, 2023

wow these CMake config files are also a shitshow.

SDL2 Builds on debian 10 and ubuntu 20.04 but fails on debian 11 and ubuntu 22.04 o_O

@Ghabry Ghabry force-pushed the cmake-presets branch 4 times, most recently from 8e1ead9 to c1a573c Compare January 4, 2023 10:40
@Ghabry
Copy link
Member Author

Ghabry commented Jan 4, 2023

I don't really like the liblcf preset but as long as they do not allow extending presets (https://gitlab.kitware.com/cmake/cmake/-/issues/23046) this is imo the best way to do it :/

(On command line you can obviously do "-DPLAYER_BUILD_LIBLCF=ON" but not in VsCode ^^')

@Ghabry Ghabry marked this pull request as draft January 4, 2023 14:08
@Ghabry
Copy link
Member Author

Ghabry commented Jan 6, 2023

hm looking through the VsCode documentation of the presets it states that buildPresets can be omited, then a default with no additional arguments is used.

This seems to also work for the command line invocation. That means I can use CMAKE_BUILD_TYPE instead and make the file 1000 lines shorter xD.


"Multi presets" would be cool. Then one could do stuff like --preset wii+liblcf+debug and it applies the settings of these 3 presets. But is not a feature available :(

@Ghabry
Copy link
Member Author

Ghabry commented Feb 2, 2023

Confirmed working after merging EasyRPG/buildscripts#142

Test script

#!/bin/bash
set -e

export EASYRPG_BUILDSCRIPTS=$PWD/easyrpg-buildscripts
cd easyrpg-player

# Native
echo "=== Native ==="
cmake . -GNinja --preset debug
cmake --build --preset debug

# Linux
echo "=== Linux ==="
cmake . -GNinja --preset linux-debug
cmake --build --preset linux-debug

cmake . -GNinja --preset linux-libretro-debug
cmake --build --preset linux-libretro-debug

# Vita
echo "=== Vita ==="
cmake . -GNinja --preset psvita-debug
cmake --build --preset psvita-debug

cmake . -GNinja --preset psvita-libretro-debug
cmake --build --preset psvita-libretro-debug

# 3DS
echo "=== 3ds ==="
cmake . -GNinja --preset 3ds-debug
cmake --build --preset 3ds-debug

cmake . -GNinja --preset 3ds-libretro-debug
cmake --build --preset 3ds-libretro-debug

# Wii
echo "=== Wii ==="
cmake . -GNinja --preset wii-debug
cmake --build --preset wii-debug

cmake . -GNinja --preset wii-libretro-debug
cmake --build --preset wii-libretro-debug

# Switch
echo "=== Switch ==="
cmake . -GNinja --preset switch-debug
cmake --build --preset switch-debug

cmake . -GNinja --preset switch-libretro-debug
cmake --build --preset switch-libretro-debug

# emscripten
echo "=== Emscripten ==="
cmake . -GNinja --preset emscripten-debug
cmake --build --preset emscripten-debug

@Ghabry Ghabry marked this pull request as ready for review February 2, 2023 11:05
@fdelapena fdelapena requested a review from carstene1ns February 4, 2023 05:41
@carstene1ns
Copy link
Member

How does cmake handle missing preset files? Reason is I would provide the user file as .template and put the real one in the ignore file.

@Ghabry
Copy link
Member Author

Ghabry commented Feb 5, 2023

When you ask something about CMakePresets the answer is usually "no". Officially they are now on version 6 and it is still barely usable for anything that is not trivial.

Version 6 added "workflow presets" and there are already bug reports about them because they have the same combinatorical problems like the other features. They just don't care.

See also:


How does cmake handle missing preset files?

Missing includes break the preset feature completely. The file must exist.

Reason is I would provide the user file as .template and put the real one in the ignore file.

The official way to provide user overrides is through CMakeUserPresets.json in the root directory but this file is next to useless because it can only add new presets. There are no extension points and you cannot override existing presets. You can also not include this file.

Oh and when two presets have the same name you get an error -_-

See also: https://gitlab.kitware.com/cmake/cmake/-/issues/23046

This user.json file I provide in builds/cmake is kinda a workaround for this missing extension point feature. If presets were properly designed there would be no need for this.

@carstene1ns
Copy link
Member

Okay, so best option for me is to use the env var and leave the file alone.

@Ghabry
Copy link
Member Author

Ghabry commented Feb 9, 2023

Jenkins: Test this please

Ghabry and others added 7 commits March 5, 2023 15:33
All the targets were updated to reflect the upstream targets.

As fallback still provide FindModules.
Is enforced by devkitPro, now we use it for everything.

Hopefully this does not break the build.
Add missing "configuration" field to buildPresets
…LAYER_BUILD_LIBLCF=ON

Fix build type
Remove VS2019 (Cmake too old)
Disable Windows in general (untested until VS2022 update)
…y pixman on Android does work properly inside function calls
@fdelapena fdelapena merged commit 16ef81d into EasyRPG:master Mar 5, 2023
@Ghabry Ghabry deleted the cmake-presets branch June 12, 2023 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants