media-libs/imgui: improve meson build system

Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte@gmail.com>
This commit is contained in:
Gonçalo Negrier Duarte 2024-06-03 11:39:31 +01:00
parent 5331bf76cb
commit d38b1ad7fc
No known key found for this signature in database
GPG Key ID: C7FE9710C90868CC
5 changed files with 55 additions and 102 deletions

View File

@ -20,6 +20,8 @@ sources = files(
'imgui_widgets.cpp', 'imgui_widgets.cpp',
) )
headers = files()
cpp = meson.get_compiler('cpp') cpp = meson.get_compiler('cpp')
dependencies = [] dependencies = []
@ -29,46 +31,66 @@ dx9_dep = cpp.find_library('d3d9', required: get_option('dx9'))
if dx9_dep.found() if dx9_dep.found()
sources += 'backends/imgui_impl_dx9.cpp' sources += 'backends/imgui_impl_dx9.cpp'
dependencies += dx9_dep dependencies += dx9_dep
headers += files('backends/imgui_impl_dx9.h')
endif endif
dx10_dep = cpp.find_library('d3d10', required: get_option('dx10')) dx10_dep = cpp.find_library('d3d10', required: get_option('dx10'))
if dx10_dep.found() if dx10_dep.found()
sources += 'backends/imgui_impl_dx10.cpp' sources += 'backends/imgui_impl_dx10.cpp'
dependencies += dx10_dep dependencies += dx10_dep
headers += files('backends/imgui_impl_dx10.h')
endif endif
dx11_dep = cpp.find_library('d3d11', required: get_option('dx11')) dx11_dep = cpp.find_library('d3d11', required: get_option('dx11'))
if dx11_dep.found() if dx11_dep.found()
sources += 'backends/imgui_impl_dx11.cpp' sources += 'backends/imgui_impl_dx11.cpp'
dependencies += dx11_dep dependencies += dx11_dep
headers += files('backends/imgui_impl_dx11.h')
endif endif
dx12_dep = cpp.find_library('d3d12', required: get_option('dx12')) dx12_dep = cpp.find_library('d3d12', required: get_option('dx12'))
# MinGW does not work. See https://github.com/ocornut/imgui/pull/4604 # MinGW does not work. See https://github.com/ocornut/imgui/pull/4604
if dx12_dep.found() and cpp.get_argument_syntax() == 'msvc' if dx12_dep.found() and cpp.get_argument_syntax() == 'msvc'
sources += 'backends/imgui_impl_dx12.cpp' sources += 'backends/imgui_impl_dx12.cpp'
dependencies += dx12_dep dependencies += dx12_dep
headers += files('backends/imgui_impl_dx12.h')
endif endif
metal_dep = dependency('appleframeworks', modules: ['Foundation', 'AppKit', 'GameController', 'Metal'], required: get_option('metal')) metal_dep = dependency('appleframeworks', modules: ['Foundation', 'AppKit', 'GameController', 'Metal'], required: get_option('metal'))
if metal_dep.found() if metal_dep.found()
sources += 'backends/imgui_impl_metal.mm' sources += 'backends/imgui_impl_metal.mm'
dependencies += metal_dep dependencies += metal_dep
headers += files('backends/imgui_impl_metal.h')
endif endif
libgl_dep = dependency('gl', required: get_option('opengl')) libgl_dep = dependency('gl', required: get_option('opengl'))
opengl_src = files(
'backends/imgui_impl_opengl2.cpp',
'backends/imgui_impl_opengl3.cpp')
if libgl_dep.found() if libgl_dep.found()
sources += 'backends/imgui_impl_opengl3.cpp' sources += opengl_src
dependencies += libgl_dep dependencies += libgl_dep
dependencies += cpp.find_library('dl', required: false) dependencies += cpp.find_library('dl', required: false)
headers = files('backends/imgui_impl_opengl2.h',
'backends/imgui_impl_opengl3.h',
'backends/imgui_impl_opengl3_loader.h')
endif endif
sdl2_renderer_dep = dependency('sdl2', version: '>=2.0.17', required: get_option('sdl_renderer')) sdl2_renderer_dep = dependency('sdl2', version: '>=2.0.17', required: get_option('sdl2_renderer'))
if sdl2_renderer_dep.found() if sdl2_renderer_dep.found()
sources += 'backends/imgui_impl_sdlrenderer2.cpp' sources += 'backends/imgui_impl_sdlrenderer2.cpp'
dependencies += sdl2_renderer_dep dependencies += sdl2_renderer_dep
headers += files('backends/imgui_impl_sdlrenderer2.h')
endif
sdl3_renderer_dep = dependency('sdl3', version: '>=3.0.0', required: get_option('sdl3_renderer'))
if sdl3_renderer_dep.found()
sources += 'backends/imgui_impl_sdlrenderer3.cpp'
dependencies += sdl3_renderer_dep
headers += files('backends/imgui_impl_sdlrenderer3.h')
endif endif
vulkan_dep = dependency('vulkan', required: get_option('vulkan')) vulkan_dep = dependency('vulkan', required: get_option('vulkan'))
if vulkan_dep.found() if vulkan_dep.found()
sources += 'backends/imgui_impl_vulkan.cpp' sources += 'backends/imgui_impl_vulkan.cpp'
dependencies += vulkan_dep dependencies += vulkan_dep
headers += files('backends/imgui_impl_vulkan.h')
endif endif
if cpp.has_header('webgpu/webgpu.h', required: get_option('webgpu')) if cpp.has_header('webgpu/webgpu.h', required: get_option('webgpu'))
sources += 'backends/imgui_impl_wgpu.cpp' sources += 'backends/imgui_impl_wgpu.cpp'
headers += files('backends/imgui_impl_wgpu.h')
endif endif
# platform backends # platform backends
@ -76,20 +98,30 @@ glfw_dep = dependency('glfw3', required: get_option('glfw'))
if glfw_dep.found() if glfw_dep.found()
sources += 'backends/imgui_impl_glfw.cpp' sources += 'backends/imgui_impl_glfw.cpp'
dependencies += glfw_dep dependencies += glfw_dep
headers += files('backends/imgui_impl_glfw.h')
endif endif
sdl2_dep = dependency('sdl2', required: get_option('sdl2')) sdl2_dep = dependency('sdl2', required: get_option('sdl2'))
if sdl2_dep.found() if sdl2_dep.found()
sources += 'backends/imgui_impl_sdl2.cpp' sources += 'backends/imgui_impl_sdl2.cpp'
dependencies += sdl2_dep dependencies += sdl2_dep
headers += files('backends/imgui_impl_sdl2.h')
endif
sdl3_dep = dependency('sdl3', required: get_option('sdl3'))
if sdl3_dep.found()
sources += 'backends/imgui_impl_sdl3.cpp'
dependencies += sdl3_dep
headers += files('backends/imgui_impl_sdl3.h')
endif endif
osx_dep = dependency('appleframeworks', modules: ['Carbon', 'Cocoa', 'GameController'], required: get_option('osx')) osx_dep = dependency('appleframeworks', modules: ['Carbon', 'Cocoa', 'GameController'], required: get_option('osx'))
if osx_dep.found() if osx_dep.found()
sources += 'backends/imgui_impl_osx.mm' sources += 'backends/imgui_impl_osx.mm'
headers += files('backends/imgui_impl_osx.h')
endif endif
win_dep = cpp.find_library('dwmapi', required: get_option('win')) win_dep = cpp.find_library('dwmapi', required: get_option('win'))
if win_dep.found() if win_dep.found()
sources += 'backends/imgui_impl_win32.cpp' sources += 'backends/imgui_impl_win32.cpp'
dependencies += win_dep dependencies += win_dep
headers += files('backends/imgui_impl_win32.h')
endif endif
# frameworks # frameworks
@ -98,6 +130,7 @@ allegro5_primitives_dep = dependency('allegro_primitives-5', required: get_optio
if allegro5_dep.found() and allegro5_primitives_dep.found() if allegro5_dep.found() and allegro5_primitives_dep.found()
sources += 'backends/imgui_impl_allegro5.cpp' sources += 'backends/imgui_impl_allegro5.cpp'
dependencies += [allegro5_dep, allegro5_primitives_dep] dependencies += [allegro5_dep, allegro5_primitives_dep]
headers+= files('backends/imgui_impl_allegro5.h')
endif endif
api = '-DIMGUI_API=__attribute__((visibility("default")))' api = '-DIMGUI_API=__attribute__((visibility("default")))'
@ -116,38 +149,20 @@ imgui = library(
install: true install: true
) )
pkg_mod = import('pkgconfig') headers += files(
pkg_mod.generate(imgui,
description : 'Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies'
)
install_headers(
'imconfig.h', 'imconfig.h',
'imgui.h', 'imgui.h',
'imgui_internal.h', 'imgui_internal.h',
'imstb_rectpack.h', 'imstb_rectpack.h',
'imstb_textedit.h', 'imstb_textedit.h',
'imstb_truetype.h', 'imstb_truetype.h',)
'backends/imgui_impl_allegro5.h',
'backends/imgui_impl_android.h', install_headers(headers, subdir: 'imgui')
'backends/imgui_impl_dx10.h',
'backends/imgui_impl_dx11.h', pkg_mod = import('pkgconfig')
'backends/imgui_impl_dx12.h', pkg_mod.generate(imgui,
'backends/imgui_impl_glfw.h', description : 'Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies'
'backends/imgui_impl_glut.h', )
'backends/imgui_impl_metal.h',
'backends/imgui_impl_opengl2.h',
'backends/imgui_impl_opengl3.h',
'backends/imgui_impl_opengl3_loader.h',
'backends/imgui_impl_osx.h',
'backends/imgui_impl_sdl2.h',
'backends/imgui_impl_sdl3.h',
'backends/imgui_impl_sdlrenderer2.h',
'backends/imgui_impl_sdlrenderer3.h',
'backends/imgui_impl_vulkan.h',
'backends/imgui_impl_wgpu.h',
'backends/imgui_impl_win32.h',
subdir: 'imgui')
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
api = '-DIMGUI_API=@0@'.format(get_option('default_library') != 'static' ? '__declspec(dllimport)' : '') api = '-DIMGUI_API=@0@'.format(get_option('default_library') != 'static' ? '__declspec(dllimport)' : '')

View File

@ -5,13 +5,15 @@ option('dx11', type : 'feature', value : 'auto')
option('dx12', type : 'feature', value : 'auto') option('dx12', type : 'feature', value : 'auto')
option('metal', type : 'feature', value : 'auto') option('metal', type : 'feature', value : 'auto')
option('opengl', type : 'feature', value : 'auto') option('opengl', type : 'feature', value : 'auto')
option('sdl_renderer', type : 'feature', value : 'auto') option('sdl2_renderer', type : 'feature', value : 'auto')
option('sdl3_renderer', type : 'feature', value : 'auto')
option('vulkan', type : 'feature', value : 'auto') option('vulkan', type : 'feature', value : 'auto')
option('webgpu', type : 'feature', value : 'auto') option('webgpu', type : 'feature', value : 'auto')
# platform backends # platform backends
option('glfw', type : 'feature', value : 'auto') option('glfw', type : 'feature', value : 'auto')
option('sdl2', type : 'feature', value : 'auto') option('sdl2', type : 'feature', value : 'auto')
option('sdl3', type : 'feature', value : 'auto')
option('osx', type : 'feature', value : 'auto') option('osx', type : 'feature', value : 'auto')
option('win', type : 'feature', value : 'auto') option('win', type : 'feature', value : 'auto')

View File

@ -17,7 +17,7 @@ SRC_URI="https://github.com/ocornut/imgui/archive/v${PV}.tar.gz -> imgui-${PV}.t
LICENSE="MIT" LICENSE="MIT"
SLOT="0/${PV}" SLOT="0/${PV}"
KEYWORDS="~amd64" KEYWORDS="~amd64"
IUSE="opengl vulkan glfw sdl2 sdl_renderer webgpu allegro5" IUSE="opengl vulkan glfw sdl2 sdl3 sdl2_renderer sdl3_renderer webgpu allegro5"
RDEPEND=" RDEPEND="
dev-libs/stb:= dev-libs/stb:=
@ -26,7 +26,7 @@ RDEPEND="
glfw? ( media-libs/glfw:0[${MULTILIB_USEDEP}] ) glfw? ( media-libs/glfw:0[${MULTILIB_USEDEP}] )
opengl? ( virtual/opengl[${MULTILIB_USEDEP}] ) opengl? ( virtual/opengl[${MULTILIB_USEDEP}] )
sdl2? ( media-libs/libsdl2[${MULTILIB_USEDEP}] ) sdl2? ( media-libs/libsdl2[${MULTILIB_USEDEP}] )
sdl_renderer? ( media-libs/libsdl2[${MULTILIB_USEDEP}] ) sdl2_renderer? ( media-libs/libsdl2[${MULTILIB_USEDEP}] )
vulkan? ( media-libs/vulkan-loader[${MULTILIB_USEDEP}] ) vulkan? ( media-libs/vulkan-loader[${MULTILIB_USEDEP}] )
webgpu? ( dev-util/webgpu-headers ) webgpu? ( dev-util/webgpu-headers )
" "
@ -58,7 +58,9 @@ multilib_src_configure() {
$(meson_feature vulkan) $(meson_feature vulkan)
$(meson_feature glfw) $(meson_feature glfw)
$(meson_feature sdl2) $(meson_feature sdl2)
$(meson_feature sdl_renderer) $(meson_feature sdl2_renderer)
-Dsdl3=disabled
-Dsdl3_renderer=disabled
$(meson_feature webgpu) $(meson_feature webgpu)
-Dosx=disabled -Dosx=disabled
-Dwin=disabled -Dwin=disabled

View File

@ -1,68 +0,0 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit meson-multilib
MESON_WRAP_VER="1"
DESCRIPTION="Bloat-free graphical user interface library for C++"
HOMEPAGE="
https://github.com/ocornut/imgui
"
SRC_URI="https://github.com/ocornut/imgui/archive/v${PV}.tar.gz -> imgui-${PV}.tar.gz"
LICENSE="MIT"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="opengl vulkan glfw sdl2 sdl_renderer webgpu allegro5"
RDEPEND="
dev-libs/stb:=
media-libs/glew[${MULTILIB_USEDEP}]
allegro5? ( media-libs/allegro:5[${MULTILIB_USEDEP}] )
glfw? ( media-libs/glfw:0[${MULTILIB_USEDEP}] )
opengl? ( virtual/opengl[${MULTILIB_USEDEP}] )
sdl2? ( media-libs/libsdl2[${MULTILIB_USEDEP}] )
sdl_renderer? ( media-libs/libsdl2[${MULTILIB_USEDEP}] )
vulkan? ( media-libs/vulkan-loader[${MULTILIB_USEDEP}] )
webgpu? ( dev-util/webgpu-headers )
"
DEPEND="
${RDEPEND}
vulkan? ( dev-util/vulkan-headers )
"
BDEPEND="
virtual/pkgconfig
"
src_prepare() {
default
# Use custom meson.build and meson_options.txt to install instead of relay on packages
cp "${FILESDIR}/${PN}-meson.build" "${S}/meson.build" || die
cp "${FILESDIR}/${PN}-meson_options.txt" "${S}/meson_options.txt" || die
sed -i "s/ version: 'PV',/ version: '${PV}',/g" "${S}/meson.build" || die
}
multilib_src_configure() {
local emesonargs=(
-Ddx9=disabled
-Ddx10=disabled
-Ddx11=disabled
-Ddx12=disabled
-Dmetal=disabled
$(meson_feature opengl)
$(meson_feature vulkan)
$(meson_feature glfw)
$(meson_feature sdl2)
$(meson_feature sdl_renderer)
$(meson_feature webgpu)
-Dosx=disabled
-Dwin=disabled
$(meson_feature allegro5)
)
meson_src_configure
}

View File

@ -15,7 +15,9 @@
<flag name="opengl">Enable opengl renderer</flag> <flag name="opengl">Enable opengl renderer</flag>
<flag name="vulkan">Enable vulkan renderer</flag> <flag name="vulkan">Enable vulkan renderer</flag>
<flag name="sdl2">Enable SDL2 backend</flag> <flag name="sdl2">Enable SDL2 backend</flag>
<flag name="sdl_renderer">Enable SDL renderer backend</flag> <flag name="sdl2_renderer">Enable SDL2 renderer backend</flag>
<flag name="sdl3">Enable SDL3 backend</flag>
<flag name="sdl2_renderer">Enable SDL3 renderer backend</flag>
<flag name="webgpu">Enable webgpu renderer backend</flag> <flag name="webgpu">Enable webgpu renderer backend</flag>
</use> </use>
</pkgmetadata> </pkgmetadata>