Skip to content

Conversation

@JoshuaVandaele
Copy link
Contributor

No description provided.

@JoshuaVandaele JoshuaVandaele force-pushed the testbranch branch 4 times, most recently from ddaa6a7 to 5c8dfae Compare January 14, 2026 16:50
@JoshuaVandaele JoshuaVandaele force-pushed the testbranch branch 4 times, most recently from 9fb2220 to 42700a5 Compare January 17, 2026 19:51
Currently, configuring from System>Bundled doesn't work, it instead produces cryptic errors. And configuring from Bundled>System wont produce errors, but wont use the system libraries either. This change produces a clear error in both cases.
This also fixes the CMake build on Windows, since it would fail to find our target defined in Externals and would fall back to trying to redefine it, which produces an error.
cURL tries to find ZSTD anyways due to the lack of setting it in CACHE, and for both ZLIB and ZSTD if we had done find_package previously, cURL would still use ZLIB/ZSTD regardless of the set variable.
Our FindLibUSB.cmake was previously entirely unused unless SDL was being built from Externals, we now rely on it again. It will use PkgConfig if applicable or fall back to looking around on the system, and more importantly it will always create an imported target.
Previously, SDL would `find_package(libusb)` which would actually overwrite the user preference in the case where both USE_SYSTEM_LIBUSB and USE_SYSTEM_SDL were OFF. This coincidentally also allows SDL to use libusb on Windows.

SDL is being updated slightly since commits 4a29b6a and bc68c1c are needed to fix using a static libusb and hidapi alongside SDL.
This introduces a CMakePresets file for both Linux and Windows that replace the old CMakeSettings.
It adds presets for **Debug** and **Release** profiles for both **x64** and **ARM64** architectures, as well as Generic builds, and can be used using Visual Studio's built-in CMakePresets support, or Visual Studio Code's CMake Tools extension.

They can also be used from the command line, like so:

x64/Linux:
Configure: `cmake --preset unix-release-x64`
Build: `cmake --build --preset unix-build-release-x64`
Configure + Build: `cmake --workflow --preset unix-release-x64`
ARM64/Windows:
Configure: `cmake --preset windows-release-arm64`
Build: `cmake --build --preset windows-build-release-arm64`
Configure + Build: `cmake --workflow --preset windows-release-arm64`

**Cross-compiling**

On Windows, the Visual Studio generator automatically takes care of selecting the cross-compiler if required.

On Linux, the Ninja generator is used. To cross-compile you need to install a cross-compiler and (optionally) a sysroot of the target system.
Here is an example to compile from x64 to ARM64 with a sysroot:

- `cmake --preset unix-release-arm64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_SYSROOT=/opt/sysroots/aarch64-linux-gnu`
- `cmake --build --preset unix-build-release-arm64`

You will need a sysroot to link against Qt, since we do not vendor it in on platforms other than Windows.

A `CMakeUserPresets.json` file may be created locally at the root of the project to further customize your presets.
For example, here are the user presets I used to test this PR on Arch Linux with a generic Arch Linux ARM sysroot:

```json
{
  "version": 10,
  "configurePresets": [
    {
      "name": "gcc-debug-arm64",
      "inherits": "unix-debug-arm64",
      "cacheVariables": {
        "CMAKE_C_COMPILER": "aarch64-linux-gnu-gcc",
        "CMAKE_CXX_COMPILER": "aarch64-linux-gnu-g++",
        "CMAKE_EXE_LINKER_FLAGS": "-L/opt/sysroots/ArchLinuxARM/lib",
        "CMAKE_SYSROOT": "/opt/sysroots/ArchLinuxARM"
      }
    },
    {
      "name": "clang-debug-arm64",
      "inherits": "unix-debug-arm64",
      "cacheVariables": {
        "CMAKE_C_COMPILER": "clang",
        "CMAKE_CXX_COMPILER": "clang++",
        "CMAKE_C_FLAGS": "-target aarch64-linux-gnu",
        "CMAKE_CXX_FLAGS": "-target aarch64-linux-gnu",
        "CMAKE_SYSROOT": "/opt/sysroots/ArchLinuxARM"
      }
    }
  ],
  "buildPresets": [
    {
      "name": "gcc-build-debug-arm64",
      "configurePreset": "gcc-debug-arm64"
    },
    {
      "name": "clang-build-debug-arm64",
      "configurePreset": "clang-debug-arm64"
    }
  ],
  "workflowPresets": [
    {
      "name": "gcc-debug-arm64",
      "steps": [
        { "type": "configure", "name": "gcc-debug-arm64" },
        { "type": "build", "name": "gcc-build-debug-arm64" }
      ]
    },
    {
      "name": "clang-debug-arm64",
      "steps": [
        { "type": "configure", "name": "clang-debug-arm64" },
        { "type": "build", "name": "clang-build-debug-arm64" }
      ]
    }
  ]
}
```

They are then used like so:
Configure + Build with GCC: `cmake --workflow --preset gcc-debug-arm64`
Configure + Build with Clang: `cmake --workflow --preset clang-debug-arm64`

These changes should also make it trivial to cross-compile from Linux to FreeBSD and vice-versa, however this is untested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant