| 1 |
project( |
| 2 |
'imgui', |
| 3 |
'cpp', |
| 4 |
license: 'MIT', |
| 5 |
version: '1.91.6', |
| 6 |
meson_version: '>=0.50.0', |
| 7 |
) |
| 8 |
|
| 9 |
if host_machine.system() == 'darwin' |
| 10 |
add_languages('objcpp') |
| 11 |
endif |
| 12 |
|
| 13 |
include_dirs = include_directories('.', 'backends') |
| 14 |
sources = files( |
| 15 |
'imgui.cpp', |
| 16 |
'imgui_demo.cpp', |
| 17 |
'imgui_draw.cpp', |
| 18 |
'imgui_tables.cpp', |
| 19 |
'imgui_widgets.cpp', |
| 20 |
'misc/cpp/imgui_stdlib.cpp', |
| 21 |
) |
| 22 |
|
| 23 |
cpp = meson.get_compiler('cpp') |
| 24 |
dependencies = [] |
| 25 |
|
| 26 |
# renderer backends |
| 27 |
dependencies += cpp.find_library( |
| 28 |
'd3dcompiler', |
| 29 |
required: host_machine.system() == 'windows', |
| 30 |
) |
| 31 |
dx9_dep = cpp.find_library( |
| 32 |
'd3d9', |
| 33 |
required: get_option('dx9'), |
| 34 |
) |
| 35 |
if dx9_dep.found() |
| 36 |
sources += 'backends/imgui_impl_dx9.cpp' |
| 37 |
dependencies += dx9_dep |
| 38 |
endif |
| 39 |
dx10_dep = cpp.find_library( |
| 40 |
'd3d10', |
| 41 |
required: get_option('dx10'), |
| 42 |
) |
| 43 |
if dx10_dep.found() |
| 44 |
sources += 'backends/imgui_impl_dx10.cpp' |
| 45 |
dependencies += dx10_dep |
| 46 |
endif |
| 47 |
dx11_dep = cpp.find_library( |
| 48 |
'd3d11', |
| 49 |
required: get_option('dx11'), |
| 50 |
) |
| 51 |
if dx11_dep.found() |
| 52 |
sources += 'backends/imgui_impl_dx11.cpp' |
| 53 |
dependencies += dx11_dep |
| 54 |
endif |
| 55 |
dx12_dep = cpp.find_library( |
| 56 |
'd3d12', |
| 57 |
required: get_option('dx12'), |
| 58 |
) |
| 59 |
# MinGW does not work. See https://github.com/ocornut/imgui/pull/4604 |
| 60 |
if dx12_dep.found() and cpp.get_argument_syntax() == 'msvc' |
| 61 |
sources += 'backends/imgui_impl_dx12.cpp' |
| 62 |
dependencies += dx12_dep |
| 63 |
endif |
| 64 |
metal_dep = dependency( |
| 65 |
'appleframeworks', |
| 66 |
modules: ['Foundation', 'AppKit', 'GameController', 'Metal'], |
| 67 |
required: get_option('metal'), |
| 68 |
) |
| 69 |
if metal_dep.found() |
| 70 |
sources += 'backends/imgui_impl_metal.mm' |
| 71 |
dependencies += metal_dep |
| 72 |
endif |
| 73 |
libgl_dep = dependency( |
| 74 |
'gl', |
| 75 |
required: get_option('opengl'), |
| 76 |
) |
| 77 |
if libgl_dep.found() |
| 78 |
sources += 'backends/imgui_impl_opengl3.cpp' |
| 79 |
dependencies += libgl_dep |
| 80 |
dependencies += cpp.find_library( |
| 81 |
'dl', |
| 82 |
required: false, |
| 83 |
) |
| 84 |
endif |
| 85 |
sdl2_renderer_dep = dependency( |
| 86 |
'sdl2', |
| 87 |
version: '>=2.0.17', |
| 88 |
required: get_option('sdl2_renderer'), |
| 89 |
) |
| 90 |
if sdl2_renderer_dep.found() |
| 91 |
sources += 'backends/imgui_impl_sdlrenderer2.cpp' |
| 92 |
dependencies += sdl2_renderer_dep |
| 93 |
endif |
| 94 |
sdl3_renderer_dep = dependency( |
| 95 |
'sdl3', |
| 96 |
version: '>=3.1.3', |
| 97 |
required: get_option('sdl3_renderer'), |
| 98 |
) |
| 99 |
if sdl3_renderer_dep.found() |
| 100 |
sources += 'backends/imgui_impl_sdlrenderer3.cpp' |
| 101 |
dependencies += sdl3_renderer_dep |
| 102 |
endif |
| 103 |
vulkan_dep = dependency( |
| 104 |
'vulkan', |
| 105 |
required: get_option('vulkan'), |
| 106 |
) |
| 107 |
if vulkan_dep.found() |
| 108 |
sources += 'backends/imgui_impl_vulkan.cpp' |
| 109 |
dependencies += vulkan_dep |
| 110 |
endif |
| 111 |
if cpp.has_header( |
| 112 |
'webgpu/webgpu.h', |
| 113 |
required: get_option('webgpu'), |
| 114 |
) |
| 115 |
sources += 'backends/imgui_impl_wgpu.cpp' |
| 116 |
endif |
| 117 |
|
| 118 |
# platform backends |
| 119 |
glfw_dep = dependency( |
| 120 |
'glfw3', |
| 121 |
required: get_option('glfw'), |
| 122 |
) |
| 123 |
if glfw_dep.found() |
| 124 |
sources += 'backends/imgui_impl_glfw.cpp' |
| 125 |
dependencies += glfw_dep |
| 126 |
endif |
| 127 |
sdl2_dep = dependency( |
| 128 |
'sdl2', |
| 129 |
required: get_option('sdl2'), |
| 130 |
) |
| 131 |
if sdl2_dep.found() |
| 132 |
sources += 'backends/imgui_impl_sdl2.cpp' |
| 133 |
dependencies += sdl2_dep |
| 134 |
endif |
| 135 |
sdl3_dep = dependency( |
| 136 |
'sdl3', |
| 137 |
required: get_option('sdl3'), |
| 138 |
) |
| 139 |
if sdl3_dep.found() |
| 140 |
sources += 'backends/imgui_impl_sdl3.cpp' |
| 141 |
dependencies += sdl3_dep |
| 142 |
endif |
| 143 |
osx_dep = dependency( |
| 144 |
'appleframeworks', |
| 145 |
modules: ['Carbon', 'Cocoa', 'GameController'], |
| 146 |
required: get_option('osx'), |
| 147 |
) |
| 148 |
if osx_dep.found() |
| 149 |
sources += 'backends/imgui_impl_osx.mm' |
| 150 |
endif |
| 151 |
win_dep = cpp.find_library( |
| 152 |
'dwmapi', |
| 153 |
required: get_option('win'), |
| 154 |
) |
| 155 |
if win_dep.found() |
| 156 |
sources += 'backends/imgui_impl_win32.cpp' |
| 157 |
dependencies += win_dep |
| 158 |
endif |
| 159 |
|
| 160 |
# frameworks |
| 161 |
allegro5_dep = dependency( |
| 162 |
'allegro-5', |
| 163 |
required: get_option('allegro5'), |
| 164 |
) |
| 165 |
allegro5_primitives_dep = dependency( |
| 166 |
'allegro_primitives-5', |
| 167 |
required: get_option('allegro5'), |
| 168 |
) |
| 169 |
if allegro5_dep.found() and allegro5_primitives_dep.found() |
| 170 |
sources += 'backends/imgui_impl_allegro5.cpp' |
| 171 |
dependencies += [allegro5_dep, allegro5_primitives_dep] |
| 172 |
endif |
| 173 |
|
| 174 |
api = '-DIMGUI_API=__attribute__((visibility("default")))' |
| 175 |
if host_machine.system() == 'windows' |
| 176 |
api = '-DIMGUI_API=@0@'.format( |
| 177 |
get_option('default_library') != 'static' ? '__declspec(dllexport)' : '', |
| 178 |
) |
| 179 |
endif |
| 180 |
|
| 181 |
# workaround issue (#14939) in Meson 1.8.4 - 1.9.0, where |
| 182 |
# default_options:['cpp_std=c++17'] doesn't work under certain circumstances |
| 183 |
override_opts = ['cpp_std=c++17'] |
| 184 |
|
| 185 |
imgui = static_library( |
| 186 |
'imgui', |
| 187 |
sources, |
| 188 |
cpp_args: api, |
| 189 |
gnu_symbol_visibility: 'hidden', |
| 190 |
dependencies: dependencies, |
| 191 |
include_directories: include_dirs, |
| 192 |
install: false, |
| 193 |
override_options: override_opts, |
| 194 |
) |
| 195 |
|
| 196 |
if host_machine.system() == 'windows' |
| 197 |
api = '-DIMGUI_API=@0@'.format( |
| 198 |
get_option('default_library') != 'static' ? '__declspec(dllimport)' : '', |
| 199 |
) |
| 200 |
endif |
| 201 |
|
| 202 |
imgui_dep = declare_dependency( |
| 203 |
compile_args: api, |
| 204 |
include_directories: include_dirs, |
| 205 |
link_with: imgui, |
| 206 |
) |