From 7a030e36aee261f3e810c6cb0f74f9491a485127 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 7 Jan 2021 22:13:14 +0100 Subject: [PATCH] build/meson: Build and run tests closes #97 --- meson.build | 3 +++ meson_options.txt | 5 ++++ src/external/meson.build | 1 + tests/meson.build | 53 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 tests/meson.build diff --git a/meson.build b/meson.build index e521a8f51..0ba5ad1ea 100644 --- a/meson.build +++ b/meson.build @@ -231,6 +231,9 @@ if build_docs subdir('doc') endif +if not get_option('tests').disabled() + subdir('tests') +endif # # Final bits diff --git a/meson_options.txt b/meson_options.txt index cf30e2afb..9dc75564a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -12,6 +12,11 @@ option('docs', value: 'auto', description: 'Build the documentation') +option('tests', + type: 'feature', + value: 'auto', + description: 'Build the tests') + option('doxygen-warn-undocumented', type: 'boolean', value: false, diff --git a/src/external/meson.build b/src/external/meson.build index ab83322cd..045ecc529 100644 --- a/src/external/meson.build +++ b/src/external/meson.build @@ -8,3 +8,4 @@ glad_include = include_directories('glad/include') hungarian_include = include_directories('hungarian') imgui_include = include_directories('imgui') openxr_include = include_directories('openxr_includes') +catch2_include = include_directories('Catch2') diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 000000000..7502b751d --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,53 @@ +# Copyright 2020, Collabora, Ltd. SPDX-License-Identifier: BSL-1.0 + +tests_main = static_library( + 'tests_main', + files( + 'tests_main.cpp' + ), + include_directories: [ + catch2_include, + ] +) + + +hack_deps = [] +hack_src = [ '../src/xrt/targets/openxr/oxr_sdl2_hack.c'] +hack_libs = [] +hack_incs = [ + glad_include, + imgui_include, +] + +if sdl2.found() + hack_deps += sdl2 + hack_src += [ + '../src/external/imgui/imgui/cimgui_sdl.cpp', + '../src/external/imgui/imgui/imgui_impl_sdl.cpp', + '../src/external/imgui/imgui/imgui_impl_sdl.h', + ] + hack_libs += lib_st_gui + hack_incs += [ + st_include, + ] +endif + + +tests_input_transform = executable( + 'tests_input_transform', + files( + 'tests_input_transform.cpp', + hack_src, + ), + include_directories: [ + xrt_include, + aux_include, + st_include, + openxr_include, + catch2_include, + ] + hack_incs, + dependencies: [pthreads, driver_deps, compositor_deps, aux_ogl, aux_vk] + hack_deps, + link_whole: [lib_target_instance_no_comp, lib_st_oxr, lib_comp, driver_libs, tests_main] + hack_libs, +) + +test('tests_input_transform', tests_input_transform)