Commit 7121e323 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

Add support for meson


Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 8fe2af53
......@@ -10,8 +10,44 @@ Moreover, a custom main() function that takes care of setting up the
environment is provided in xorg-gtest_main.cpp. This can be used as a
replacement for libgtest_main.a
Using X.org GTest in a project
==============================
Using X.org GTest in a meson project
=========================================
First, initialize xorg-gtest in the `subprojects/` folder of your project,
ideally as git submodule:
```
$ mkdir subprojects && cd subprojects
$ git submodule add https://gitlab.freedesktop.org/xorg/test/xorg-gtest/
$ git submodule init
```
Then use this as subproject in `meson.build`:
```
xorg_gtest = subproject('xorg-gtest')
my_dependencies = [
dependency('somelibrary'),
dependency('other_library'),
... other dependencies ...
xorg_gtest.get_variable('xorg_gtest_dependency')
]
my_includes = [
include_directories('src'),
... other includes ...
xorg_gtest.get_variable('xorg_gtest_includes')
]
executable('mytest',
'test.cpp',
dependencies: my_dependencies,
include_directories: my_includes)
```
Using X.org GTest in an autotools project
=========================================
The X.org GTest does not provide precompiled libraries. Each project must build
the X.org GTest sources. To facilitate this, aclocal and automake include files
......
# Note: this project is to be used as a *source* dependency and as
# subproject in a parent project.
# see the PUBLIC API comment at the bottom for which variables may be used
#
project('xorg-gtest', 'cpp',
version: '0.7.1',
license: 'MIT/Expat',
default_options: ['warning_level=2'])
pkgconfig = import('pkgconfig')
dep_x11 = dependency('x11')
dep_xi = dependency('xi')
dep_evemu = dependency('evemu')
dummy_conf = join_paths(meson.current_source_dir(), 'data', 'xorg', 'gtest', 'dummy.conf')
#
# build gtest itself as static library
#
gtest_sources = files(
'gtest/include/gtest/gtest.h',
'gtest/include/gtest/gtest-spi.h',
'gtest/src/gtest-all.cc',
)
gtest_includes = [
include_directories('gtest/include'),
include_directories('gtest/'),
]
gtest_deps = [
dependency('threads'),
]
libgtest = static_library('gtest',
gtest_sources,
dependencies: gtest_deps,
include_directories: gtest_includes)
dep_gtest = declare_dependency(link_with: libgtest)
xorg_gtest_sources = files(
'include/xorg/gtest/xorg-gtest-environment.h',
'include/xorg/gtest/xorg-gtest-process.h',
'include/xorg/gtest/xorg-gtest-test.h',
'include/xorg/gtest/xorg-gtest-xserver.h',
'include/xorg/gtest/evemu/xorg-gtest-device.h',
'include/xorg/gtest/xorg-gtest.h',
'src/defines.h',
'src/xorg-gtest_main.cpp',
'src/environment.cpp',
'src/device.cpp',
'src/process.cpp',
'src/test.cpp',
'src/xserver.cpp',
'src/xorg-gtest-all.cpp',
)
xorg_gtest_incs = [
gtest_includes,
include_directories('include'),
]
xorg_gtest_dependencies = [
dep_gtest,
dep_evemu,
dep_x11,
dep_xi,
]
lib_xorg_gtest = static_library('xorg-gtest',
xorg_gtest_sources,
include_directories: xorg_gtest_incs,
dependencies: xorg_gtest_dependencies,
cpp_args: [
'-DDUMMY_CONF_PATH="@0@"'.format(dummy_conf),
'-DLOGFILE_DIR="@0@"'.format(get_option('logpath')),
],
)
dep_xorg_gtest = declare_dependency(link_with: lib_xorg_gtest,
include_directories: [gtest_includes, xorg_gtest_incs])
#
# tests
#
recordings = [
'test/SynPS2-Synaptics-TouchPad.desc',
'test/PIXART-USB-OPTICAL-MOUSE.desc'
]
foreach r: recordings
configure_file(input: r, output: '@PLAINNAME@', copy: true, install: false)
endforeach
executable('process-test-helper',
'test/process-test-helper.cpp',
install: false)
test('test-process',
executable('test-process',
'test/process-test.cpp',
dependencies: dep_xorg_gtest,
cpp_args: [
'-DTEST_ROOT_DIR="@0@/test/"'.format(meson.current_source_dir()),
'-DTEST_BUILD_DIR="@0@/"'.format(meson.current_build_dir()),
],
install: false,
),
is_parallel: false,
)
test('test-device',
executable('test-device',
'test/device-test.cpp',
dependencies: dep_xorg_gtest,
cpp_args: [
'-DTEST_ROOT_DIR="@0@/test/"'.format(meson.current_source_dir()),
],
install: false,
),
is_parallel: false,
)
executable('xserver-test-helper',
'test/xserver-test-helper.cpp',
install: false)
test('test-xserver',
executable('test-xserver',
'test/xserver-test.cpp',
dependencies: dep_xorg_gtest,
cpp_args: [
'-DTEST_ROOT_DIR="@0@/test/"'.format(meson.current_source_dir()),
'-DTEST_BUILD_DIR="@0@/"'.format(meson.current_build_dir()),
'-DDUMMY_CONF_PATH="@0@"'.format(dummy_conf),
'-DLOGFILE_DIR="@0@"'.format(get_option('logpath')),
],
install: false,
),
is_parallel: false,
)
#
# PUBLIC API:
# The variables below are the ones that may be used by any parent
# projects.
#
# Use with:
# xorg_gest = subproject('xorg-gtest')
# executable('foo',
# dependencies: xorg_gtest.get_variable('xorg_gtest_dependency'),
# include_directories: xorg_gtest.get_variable('xorg_gtest_includes'))
#
xorg_gtest_dependency = dep_xorg_gtest
xorg_gtest_includes = xorg_gtest_incs
option('logpath', type: 'string', value: '/tmp',
description: 'Base path for server log and config files (default: /tmp)')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment