From d4d5023032683d50ad42c6142edfa14c1915113d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oona=20R=C3=A4is=C3=A4nen?= Date: Wed, 1 Jan 2025 20:13:26 +0200 Subject: [PATCH] Building tests is optional (#122) It's better to base the test-building condition on a command-line option instead of the presence of Catch2. Building the tests is not necessary for normal usage of redsea anyway. --- .github/workflows/build.yml | 2 +- meson.build | 8 +++++--- meson_options.txt | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 meson_options.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08794bb..fbaa9af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,7 +81,7 @@ jobs: - name: Install dependencies (brew) run: brew install meson libsndfile liquid-dsp nlohmann-json catch2 perl gcovr - name: meson setup - run: meson setup -Dwerror=true -Db_sanitize=address,undefined -Db_lundef=false -Db_coverage=true build + run: meson setup -Dwerror=true -Db_sanitize=address,undefined -Db_lundef=false -Db_coverage=true build -Dbuild_tests=true - name: compile & install run: cd build && meson install - name: download test data diff --git a/meson.build b/meson.build index 716214f..7a31aa2 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project( 'prefix=/usr/local', 'cpp_std=c++14', ], - version: '1.1.0', + version: '1.1.1-SNAPSHOT', ) # Store version number to be compiled in @@ -121,9 +121,11 @@ executable( ### Unit tests ### ################## -catch2 = dependency('catch2-with-main', required: false) +build_tests = get_option('build_tests') + +if build_tests + catch2 = dependency('catch2-with-main', required: true) -if catch2.found() unit_test_exe = executable( 'redsea-test-unit', [ diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..b0025f0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('build_tests', type: 'boolean', value: false, description: 'Build unit tests (requires Catch2)')