summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meson.build53
-rw-r--r--meson_options.txt1
2 files changed, 30 insertions, 24 deletions
diff --git a/meson.build b/meson.build
index f9a0455d7..a783bdda8 100644
--- a/meson.build
+++ b/meson.build
@@ -506,30 +506,35 @@ executable(
subdir('util')
+# Use `.auto() or .enabled()` instead of `.allowed()` to keep the minimum meson version as low as possible.
+# `.allowed()` gets introduced in 0.59.0
+if get_option('tests').auto() or get_option('tests').enabled()
# unit-test framework
cmocka_dep = dependency(
- 'cmocka',
- fallback: ['cmocka', 'cmocka_dep'],
- required: false
-)
-flashrom_test_dep = declare_dependency(
- include_directories : include_dir,
- sources : [
- srcs,
- 'cli_common.c',
- 'cli_output.c',
- 'flashrom.c',
- ],
- compile_args : [
- '-includestdlib.h',
- '-includeunittest_env.h',
- '-includehwaccess_x86_io_unittest.h'
- ],
- dependencies : [
- deps,
- ],
-)
-
-if cmocka_dep.found()
- subdir('tests')
+ 'cmocka',
+ fallback: ['cmocka', 'cmocka_dep'],
+ required : get_option('tests')
+ )
+
+ flashrom_test_dep = declare_dependency(
+ include_directories : include_dir,
+ sources : [
+ srcs,
+ 'cli_common.c',
+ 'cli_output.c',
+ 'flashrom.c',
+ ],
+ compile_args : [
+ '-includestdlib.h',
+ '-includeunittest_env.h',
+ '-includehwaccess_x86_io_unittest.h'
+ ],
+ dependencies : [
+ deps,
+ ],
+ )
+
+ if cmocka_dep.found()
+ subdir('tests')
+ endif
endif
diff --git a/meson_options.txt b/meson_options.txt
index 8022c740a..46ac763a3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -42,3 +42,4 @@ option('config_stlinkv3_spi', type : 'boolean', value : true, description : 'STM
option('config_lspcon_i2c_spi', type : 'boolean', value : false, description : 'Parade lspcon USB-C to HDMI protocol translator')
option('config_mediatek_i2c_spi', type : 'boolean', value : false, description : 'MediaTek LCD controller')
option('config_realtek_mst_i2c_spi', type : 'boolean', value : true, description : 'Realtek MultiStream Transport MST')
+option('tests', type : 'feature', value : 'auto', description : 'Build unit tests')