From cb7b5fcd5d16bd1e71a9529c4366a4a3de5b2fb0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 15 Nov 2020 19:32:46 +0100 Subject: Make tests and man pages optional Allows to build imv without these extra features. --- meson.build | 72 +++++++++++++++++++++++++++++-------------------------- meson_options.txt | 10 ++++++++ 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/meson.build b/meson.build index 6a48cbf..672ba1a 100644 --- a/meson.build +++ b/meson.build @@ -169,45 +169,49 @@ install_data( install_mode: 'rw-r--r--', ) -dep_cmocka = dependency('cmocka') +dep_cmocka = dependency('cmocka', required: get_option('test')) -foreach test : ['list', 'navigator'] - test( - 'test_@0@'.format(test), - executable( +if dep_cmocka.found() + foreach test : ['list', 'navigator'] + test( 'test_@0@'.format(test), - [files('test/@0@.c'.format(test), 'src/dummy_window.c'), files_common], - include_directories: include_directories('src'), - dependencies: [deps_for_imv, dep_cmocka], + executable( + 'test_@0@'.format(test), + [files('test/@0@.c'.format(test), 'src/dummy_window.c'), files_common], + include_directories: include_directories('src'), + dependencies: [deps_for_imv, dep_cmocka], + ) ) - ) -endforeach + endforeach +endif -prog_a2x = find_program('a2x') +prog_a2x = find_program('a2x', required: get_option('man')) -foreach man : [ - [1, 'imv'], - [1, 'imv-msg'], - [5, 'imv'], -] - _section = man[0] - _topic = man[1] - custom_target( - '@0@(@1@)'.format(_topic, _section), - input: 'doc/@0@.@1@.txt'.format(_topic, _section), - output: '@0@.@1@'.format(_topic, _section), - command: [ - prog_a2x, - '--no-xmllint', - '--doctype', 'manpage', - '--format', 'manpage', - '--destination-dir', meson.current_build_dir(), - '@INPUT@' - ], - install: true, - install_dir: '@0@/man@1@'.format(get_option('mandir'), _section) - ) -endforeach +if prog_a2x.found() + foreach man : [ + [1, 'imv'], + [1, 'imv-msg'], + [5, 'imv'], + ] + _section = man[0] + _topic = man[1] + custom_target( + '@0@(@1@)'.format(_topic, _section), + input: 'doc/@0@.@1@.txt'.format(_topic, _section), + output: '@0@.@1@'.format(_topic, _section), + command: [ + prog_a2x, + '--no-xmllint', + '--doctype', 'manpage', + '--format', 'manpage', + '--destination-dir', meson.current_build_dir(), + '@INPUT@' + ], + install: true, + install_dir: '@0@/man@1@'.format(get_option('mandir'), _section) + ) + endforeach +endif message('\n\n' + 'Building imv @0@\n\n'.format(meson.project_version()) diff --git a/meson_options.txt b/meson_options.txt index f7ecd79..e69badf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,6 +8,16 @@ option('windows', description : 'window system to use' ) +option('test', + type : 'feature', + description : 'enable tests' +) + +option('man', + type : 'feature', + description : 'enable man pages' +) + # Available backends: # FreeImage http://freeimage.sourceforge.net -- cgit v1.2.3