diff --git a/app/meson.build b/app/meson.build index f7df69eb..ea078dbb 100644 --- a/app/meson.build +++ b/app/meson.build @@ -112,13 +112,19 @@ cc = meson.get_compiler('c') static = get_option('static') +sdl2_proj = subproject('sdl2') +sdl2_dep = sdl2_proj.get_variable('sdl2_dep') + +meson.override_dependency('sdl2', sdl2_dep) + dependencies = [ dependency('libavformat', version: '>= 57.33', static: static), dependency('libavcodec', version: '>= 57.37', static: static), dependency('libavutil', static: static), dependency('libswresample', static: static), - dependency('sdl2', version: '>= 2.0.5', static: static), + dependency('sdl2', static: static), ] +#dependency('sdl2', version: '>= 2.0.5', static: static), if v4l2_support dependencies += dependency('libavdevice', static: static) diff --git a/subprojects/packagefiles/sdl2/meson.build b/subprojects/packagefiles/sdl2/meson.build new file mode 100644 index 00000000..d89a4231 --- /dev/null +++ b/subprojects/packagefiles/sdl2/meson.build @@ -0,0 +1,77 @@ +project('sdl2', 'c') + +prefix = get_option('prefix') + +link_type = get_option('default_library') + +make_prog = find_program('make', required: true) + +configure_command = [] + +configure_args = [ + './configure', + '--prefix=' + prefix, +] + +if host_machine.system() == 'linux' + configure_args += [ + '--enable-video-wayland', + '--enable-video-x11', + ] +endif + +if link_type == 'static' + configure_args += [ + '--enable-static', + '--disable-shared', + ] +else + configure_args += [ + '--disable-static', + '--enable-shared', + ] +endif + +if meson.is_cross_build() + configure_args += [ + '--host=' + host_machine.cpu_family() + '-w64-mingw32', + ] +endif + +configure_env = environment() +configure_env.set('CFLAGS', '-O2') +configure_env.set('CXXFLAGS', '-O2') + +configure_target = custom_target('sdl2_configure', + output: 'config.h', + command: configure_args, + env: configure_env, + console: true +) + +if host_machine.system() == 'windows' and link_type == 'shared' + build_output = ['SDL2.dll'] +elif link_type == 'shared' + build_output = ['libSDL2.so'] +else + build_output = ['libSDL2.a'] +endif + +sdl2_build = custom_target('sdl2_build', + depends: configure_target, + output: build_output, + command: [make_prog, '-j'], + console: true, + build_by_default: true +) + +sdl2_install = custom_target('sdl2_install', + depends: sdl2_build, + output: 'install_done', + command: [make_prog, 'install', '&&', 'touch', '@OUTPUT@'], + console: true, + build_by_default: true, + install: false +) + +sdl2_dep = declare_dependency(sources: sdl2_install) diff --git a/subprojects/sdl2.wrap b/subprojects/sdl2.wrap new file mode 100644 index 00000000..6fc8b11a --- /dev/null +++ b/subprojects/sdl2.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = SDL-release-2.32.8 +source_url = https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.32.8.tar.gz +source_filename = libsdl2-2.32.8.tar.gz +source_hash = dd35e05644ae527848d02433bec24dd0ea65db59faecf1a0e5d1880c533dac2c +patch_directory = sdl2 + +[provide] +sdl2 = sdl2_dep