Skip to content

WIN32: add option to use system SDL3 libraries#130

Open
carlo-bramini wants to merge 1 commit into
OpenFodder:masterfrom
carlo-bramini:fix-mingw-build-3
Open

WIN32: add option to use system SDL3 libraries#130
carlo-bramini wants to merge 1 commit into
OpenFodder:masterfrom
carlo-bramini:fix-mingw-build-3

Conversation

@carlo-bramini

Copy link
Copy Markdown
Contributor

At the time of writing, compiling openfodder for WIN32 needs to download and build SDL3 libraries from sources.
However, it would be useful to add an option for selecting if system libraries could be used on Windows.
So, I added OPENFODDER_USE_SYSTEM_SDL for this task.
By default, this option is OFF to reproduce the same behaviour of current sources.
If OPENFODDER_USE_SYSTEM_SDL is ON, then SDL3 libraries are used if they are found.
This simplifies the build process a lot, if you are using MinGW or MSVC together with vcpkg, without trouble in my opinion.

@segrax

segrax commented Jun 26, 2026

Copy link
Copy Markdown
Member

hey @carlo-bramini,

is SDL3 complete/ready now? the only reason this was done, was I ran into trouble with some of the SDL3 stuff not being fully available/complete at the time it was implemented, otherwise it would of been VCPKG... as the compiling is a big pain.
cant remember the specifics but it was either only an older version available, or the mixer possibly?

im happy to completely switch it over to vcpkg if thats the case

@carlo-bramini

Copy link
Copy Markdown
Contributor Author

I usually build for MinGW, but I did a test and I successfully built openfodder also on MSVC.
It wasn't difficult at all to do it.
The biggest problem is that you need the patience to wait that vcpkg builds the libraries actually.
We must assume that the following prerequisites are installed:

  • A supported Visual Studio (I used Insiders 2026).
  • Git client (I use GitHub Desktop)
  • CMake (I used version 4.3.2).

As first step, I cloned the repositories:

  • My fork with the provided patch.
  • vcpkg (on my machine, these packages are cloned into the "e:\GitHub" directory).

Next, I installed vcpkg and needed packages.
I had to install SDL3, SDL3_mixer and FFmpeg.

Finally, I created a working directory and I executed this command:

"c:\Program Files\CMake\bin\cmake.exe" \
    e:\GitHub\openfodder \
    -DOPENFODDER_USE_SYSTEM_SDL3=ON \
    -DCMAKE_TOOLCHAIN_FILE=E:\GitHub\vcpkg\scripts\buildsystems\vcpkg.cmake \
    -DVCPKG_TARGET_TRIPLET=x64-windows \
    -DSDL3_DIR="E:/GitHub/vcpkg/installed/x64-windows/share/sdl3" \
    -DSDL3_mixer_DIR="E:/GitHub/vcpkg/installed/x64-windows/share/sdl3_mixer"

It seems that SDL3_DIR and SDL3_mixer_DIR are very important, otherwise CMake won't find those libraries.
After the configuration process finished, you can open the solution file, compile the sources, run and debug.
In my opinion, it wouldn't be a bad idea to keep existing code for grabbing and compiling SDL3 stuff.
It is an interesting option that you could make available for ALL platforms, if the OPENFODDER_USE_SYSTEM_SDL3 has not been activated.

I hope that you will find this report useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants