Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.78k stars 474 forks source link

sdl2-sys build should pass a version range to pkg-config #1061

Open LunarLambda opened 3 years ago

LunarLambda commented 3 years ago

The bundled feature exists to allow building SDL2 from source on systems that do not provide the correct version of SDL2 (i.e. LTS systems with <= 2.0.5) [citation needed]

However, there are currently no guards in place to make sure building against a native SDL2 fails if versions don't match. Likely, the user will get a confusing linker error, and be none the wiser.

The pkg-config crate allows specifying a range of acceptable versions using the atleast_version, exactly_version, and range_version methods on Config.

This should be added to computer_include_paths and pkg_config_print.

If the pkg-config probe returns Error::Failure, we should print the message, and suggest to try using the bundled feature, noting that it will require cmake.

Additionally, note that the versions of SDL2_image, SDL2_ttf, SDL2_mixer, and SDL2_gfx are not linked to the version of SDL2. This means we need to either skip this check for them, or figure out which versions we are currently expecting.

Note about vcpkg

vcpkg currently does not support version selection. The vcpkg crate does not provide a way to query the found version, either. When the vcpkg sdl2 port eventually updates to 2.0.14, users may (but in theory, shouldn't?) run into build failures.

LunarLambda commented 3 years ago

heads up: vcpkg has updated its sdl2 port to 2.0.14. https://github.com/microsoft/vcpkg/commit/0a262e7d6111af798669c4b481eb2f30b3b86fb1