build: make tests optional

Add a meson option -Dtests and --without-tests automake option
to disable the compilation of all available testcases.
This is useful for compiling projects with Flatpak such as
GNOME Control Center which disables all possible integrations since they
only need the DBus part of ModemManager.

Contributes to https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/1392
This commit is contained in:
Dylan Van Assche
2022-07-25 09:18:29 +02:00
parent 041f53af8b
commit ba96ccc615
9 changed files with 57 additions and 10 deletions

View File

@@ -88,6 +88,9 @@ cc_args = cc.get_supported_arguments([
'-Wno-missing-field-initializers',
])
# tests are enabled by default
enable_tests = get_option('tests')
# strict flags to use in debug builds
if get_option('buildtype').contains('debug')
cc_args += cc.get_supported_arguments([
@@ -266,7 +269,9 @@ if dist_version != ''
config_h.set('MM_DIST_VERSION', dist_version)
endif
util_dep = cc.find_library('util')
if enable_tests
util_dep = cc.find_library('util')
endif
# introspection support
enable_gir = get_option('introspection')
@@ -376,14 +381,19 @@ subdir('introspection')
subdir('include')
subdir('libqcdm/src')
subdir('libqcdm/tests')
if enable_tests
subdir('libqcdm/tests')
endif
subdir('libmm-glib')
subdir('src')
subdir('plugins')
subdir('cli')
subdir('test')
subdir('tools/tests')
if enable_tests
subdir('test')
subdir('tools/tests')
endif
subdir('examples/sms-c')