aboutsummaryrefslogtreecommitdiffstats
path: root/examples/meson.build
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-20 10:41:34 -0400
committerDavid Robillard <d@drobilla.net>2022-05-20 13:17:45 -0400
commit1118da579607bac768ae953fecadb6153818488d (patch)
tree67ff1ae9f7400be070ee30284b5d0bcdbb834b22 /examples/meson.build
parentd6ad1b79b97974ad3e3bd2a1b2c7474f0dd797b0 (diff)
downloadpugl-1118da579607bac768ae953fecadb6153818488d.tar.gz
pugl-1118da579607bac768ae953fecadb6153818488d.tar.bz2
pugl-1118da579607bac768ae953fecadb6153818488d.zip
MacOS: Build examples as application bundles
This is required on MacOS to make the examples usable. When run as bare programs, they don't show up as normal windows or receive keyboard input.
Diffstat (limited to 'examples/meson.build')
-rw-r--r--examples/meson.build131
1 files changed, 79 insertions, 52 deletions
diff --git a/examples/meson.build b/examples/meson.build
index d57fea4..a4bf84c 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -74,58 +74,85 @@ endif
subdir('shaders')
-# Build GL examples
-if opengl_dep.found()
- foreach example : gl_examples
- source = [example]
- target = example.split('.')[0]
- dependencies = [gl_backend_dep]
- defines = []
-
- if target == 'pugl_shader_demo'
- source += ['file_utils.c', 'glad/glad.c']
- dependencies += [dl_dep]
- defines += ['-D_POSIX_C_SOURCE=200809L']
- elif target == 'pugl_print_events'
- dependencies += [stub_backend_dep]
- endif
-
- executable(target, source,
- include_directories: includes,
- c_args: example_defines + example_c_args + defines,
- cpp_args: example_defines + example_cpp_args + defines,
- dependencies: dependencies)
- endforeach
-endif
+if host_machine.system() == 'darwin'
+ # On Darwin, build examples as application bundles (required to work properly)
-# Build Cairo examples
-if cairo_dep.found()
- foreach example : cairo_examples
- target = example.split('.')[0]
- executable(target, example,
- include_directories: includes,
- c_args: example_defines + example_c_args,
- dependencies: [pugl_dep, cairo_backend_dep])
- endforeach
-endif
+ subdir('pugl_cursor_demo.app')
+
+ if cairo_dep.found()
+ subdir('pugl_cairo_demo.app')
+ endif
-# Build Vulkan examples
-if vulkan_dep.found()
- foreach example : vulkan_examples
- source = [example]
- target = example.split('.')[0]
- dependencies = [dl_dep, vulkan_backend_dep]
- defines = []
-
- if target == 'pugl_vulkan_cpp_demo'
- source += ['file_utils.c']
- defines += ['-D_POSIX_C_SOURCE=200809L']
- endif
-
- executable(target, source,
- include_directories: includes,
- c_args: example_defines + example_c_args + defines,
- cpp_args: example_defines + example_cpp_args + defines,
- dependencies: dependencies)
- endforeach
+ if opengl_dep.found()
+ subdir('pugl_cpp_demo.app')
+ subdir('pugl_embed_demo.app')
+ subdir('pugl_shader_demo.app')
+ subdir('pugl_window_demo.app')
+ endif
+
+ if vulkan_dep.found()
+ subdir('pugl_vulkan_cpp_demo.app')
+ subdir('pugl_vulkan_demo.app')
+ endif
+
+else
+ # On all other platforms, build examples as simple programs
+
+ # Build GL examples
+ if opengl_dep.found()
+ foreach example : gl_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [gl_backend_dep]
+ defines = []
+
+ if target == 'pugl_shader_demo'
+ source += ['file_utils.c', 'glad/glad.c']
+ dependencies += [dl_dep]
+ defines += ['-D_POSIX_C_SOURCE=200809L']
+ elif target == 'pugl_print_events'
+ dependencies += [stub_backend_dep]
+ elif target == 'pugl_cpp_demo'
+ dependencies += [puglpp_dep]
+ endif
+
+ executable(target, source,
+ include_directories: includes,
+ c_args: example_defines + example_c_args + defines,
+ cpp_args: example_defines + example_cpp_args + defines,
+ dependencies: dependencies)
+ endforeach
+ endif
+
+ # Build Cairo examples
+ if cairo_dep.found()
+ foreach example : cairo_examples
+ target = example.split('.')[0]
+ executable(target, example,
+ include_directories: includes,
+ c_args: example_defines + example_c_args,
+ dependencies: [pugl_dep, cairo_backend_dep])
+ endforeach
+ endif
+
+ # Build Vulkan examples
+ if vulkan_dep.found()
+ foreach example : vulkan_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [dl_dep, vulkan_backend_dep]
+ defines = []
+
+ if target == 'pugl_vulkan_cpp_demo'
+ source += ['file_utils.c']
+ defines += ['-D_POSIX_C_SOURCE=200809L']
+ endif
+
+ executable(target, source,
+ include_directories: includes,
+ c_args: example_defines + example_c_args + defines,
+ cpp_args: example_defines + example_cpp_args + defines,
+ dependencies: dependencies)
+ endforeach
+ endif
endif