diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index 4ab77f9..0000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Build -description: 'Build a CMake project with optional configuration and building parameters' - -inputs: - shell: - required: false - default: bash - cmake_build_type: - default: 'Release' - required: false - cmake_configuration_parameters: - required: false - cmake_build_paramters: - required: false - target: - default: 'all' - -runs: - using: "composite" - steps: - - name: Configure - shell: ${{inputs.shell}} - run: cmake -B build -DCMAKE_BUILD_TYPE=${{inputs.cmake_build_type}} ${{inputs.cmake_configuration_parameters}} - - - name: Build - shell: ${{inputs.shell}} - run: cmake --build build --config ${{inputs.cmake_build_type}} --verbose ${{inputs.cmake_build_paramters}} --target ${{inputs.target}} diff --git a/.github/actions/package/action.yml b/.github/actions/package/action.yml deleted file mode 100644 index d86345b..0000000 --- a/.github/actions/package/action.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Package -description: 'Package a CMake project with CPack support' - -inputs: - generators: - required: true - -runs: - using: "composite" - steps: - - name: Package - shell: bash - run: cpack --config build/CPackConfig.cmake --verbose -G "${{inputs.generators}}" - - - name: Upload DEB artifact - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - with: - name: sigutils-linux-deb.zip - path: build/dist/*.deb - - - name: Upload TGZ artifact - if: runner.os == 'Linux' - uses: actions/upload-artifact@v4 - with: - name: sigutils-linux-tgz.zip - path: build/dist/*.tar.gz - - - name: Upload TGZ artifact - if: runner.os == 'MacOS' - uses: actions/upload-artifact@v4 - with: - name: sigutils-macos-tgz.zip - path: build/dist/*.tar.gz - - - name: Upload ZIP artifact - if: runner.os == 'Windows' - uses: actions/upload-artifact@v4 - with: - name: sigutils-windows-zip.zip - path: build/dist/*.zip diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml deleted file mode 100644 index b04faaf..0000000 --- a/.github/actions/test/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Test -description: 'Test a CMake project with CTest support' - -inputs: - shell: - required: false - default: bash - -runs: - using: "composite" - steps: - - name: Test - shell: ${{inputs.shell}} - run: ctest --test-dir build -VV --rerun-failed --output-on-failure diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c2b68c3..371ecba 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,8 +8,3 @@ updates: target-branch: "master" schedule: interval: "weekly" - - package-ecosystem: "gitsubmodule" - directory: "/" - target-branch: "master" - schedule: - interval: "weekly" diff --git a/.github/labeler.yml b/.github/labeler.yml index 9ead540..251858e 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -7,6 +7,8 @@ build_system: - all: - changed-files: - any-glob-to-any-file: + - meson_options.txt + - '**/meson.build' - 'CMake*' - '**/CMakeLists.txt' - '**/*.cmake' @@ -15,16 +17,18 @@ sigutils: - all: - changed-files: - any-glob-to-any-file: 'src/**' - - all-globs-to-all-files: '!src/CMakeLists.txt' + - all-globs-to-all-files: '!**/meson.build' documentation: - all: - changed-files: - any-glob-to-any-file: 'doc/**' - - all-globs-to-all-files: '!doc/CMakeLists.txt' + - all-globs-to-all-files: '!**/meson.build' + - all-globs-to-all-files: '!**/CMakeLists.txt' tests: - all: - changed-files: - any-glob-to-any-file: 'tests/**' - - all-globs-to-all-files: '!tests/CMakeLists.txt' + - all-globs-to-all-files: '!**/meson.build' + - all-globs-to-all-files: '!**/CMakeLists.txt' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 79603b4..c5c26ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,138 +3,82 @@ name: Build on: [push, pull_request, workflow_dispatch] jobs: - build-linux: - runs-on: ubuntu-latest - steps: - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install libsndfile1-dev libvolk2-dev libfftw3-dev catch2 - - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 + build: + strategy: + matrix: + sys: + - { os: windows-latest, shell: 'msys2 {0}' } + - { os: ubuntu-latest, shell: bash } + - { os: macos-latest, shell: bash } - - name: Build - uses: "./.github/actions/build" - with: - target: sigutils - cmake_configuration_parameters: -DCMAKE_INSTALL_PREFIX=/usr - - - name: Build tests - uses: "./.github/actions/build" - with: - target: sigutils_test - - - name: Test - uses: "./.github/actions/test" + runs-on: ${{ matrix.sys.os }} - - name: Package - uses: "./.github/actions/package" - with: - generators: TGZ;DEB - - build-macos: - runs-on: macos-latest - steps: - - name: Install dependencies - run: brew install libsndfile volk fftw catch2 - - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 - - - name: Build - uses: "./.github/actions/build" - with: - target: sigutils - - - name: Build tests - uses: "./.github/actions/build" - with: - target: sigutils_test - - - name: Test - uses: "./.github/actions/test" - - - name: Package - uses: "./.github/actions/package" - with: - generators: TGZ - - build-windows: - runs-on: windows-latest defaults: run: - shell: msys2 {0} + shell: ${{ matrix.sys.shell }} + steps: - - name: Install dependencies + - name: Install dependencies (Ubuntu) + if: matrix.sys.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install meson libsndfile1-dev libvolk2-dev libfftw3-dev catch2 + + - name: Install dependencies (Mac OS) + if: matrix.sys.os == 'macos-latest' + run: brew install -vd meson libsndfile volk fftw catch2 + + - name: Install dependencies (Windows) + if: matrix.sys.os == 'windows-latest' uses: msys2/setup-msys2@v2 with: - msystem: MINGW64 - update: true - install: git mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-libsndfile mingw-w64-x86_64-fftw mingw-w64-x86_64-volk mingw-w64-x86_64-catch + msystem: UCRT64 + install: git mingw-w64-ucrt-x86_64-meson mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libsndfile mingw-w64-ucrt-x86_64-fftw mingw-w64-ucrt-x86_64-volk mingw-w64-ucrt-x86_64-catch - name: Checkout uses: actions/checkout@v4 with: - submodules: true fetch-depth: 0 - - name: Build - uses: "./.github/actions/build" - with: - shell: msys2 {0} - target: sigutils + - name: Configure + run: meson setup builddir - - name: Build tests - uses: "./.github/actions/build" - with: - shell: msys2 {0} - target: sigutils_test + - name: Build + run: meson compile -C builddir - name: Test - uses: "./.github/actions/test" - with: - shell: msys2 {0} - - - name: Package - uses: "./.github/actions/package" - with: - generators: ZIP - - release: - runs-on: "ubuntu-latest" - needs: - - build-linux - - build-macos - - build-windows - - steps: - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - - name: Download binaries - uses: actions/download-artifact@v4 - - - name: Release nightly - if: github.ref == 'refs/heads/master' - uses: marvinpinto/action-automatic-releases@v1.2.1 - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: true - title: "Sigutils nightly (${{steps.date.outputs.date}})" - files: sigutils*/* - - - name: Release stable - if: contains(github.ref, 'refs/tags/v') - uses: marvinpinto/action-automatic-releases@v1.2.1 - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - title: "Sigutils ${{github.ref_name}}" - files: sigutils*/* + run: meson test -C builddir + + # TODO: Package + # TODO: Upload artifacts + + # release: + # runs-on: "ubuntu-latest" + # needs: build + + # steps: + # - name: Get current date + # id: date + # run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + + # - name: Download binaries + # uses: actions/download-artifact@v4 + + # - name: Release nightly + # if: github.ref == 'refs/heads/master' + # uses: marvinpinto/action-automatic-releases@v1.2.1 + # with: + # repo_token: "${{ secrets.GITHUB_TOKEN }}" + # automatic_release_tag: "latest" + # prerelease: true + # title: "Sigutils nightly (${{steps.date.outputs.date}})" + # files: sigutils*/* + + # - name: Release stable + # if: contains(github.ref, 'refs/tags/v') + # uses: marvinpinto/action-automatic-releases@v1.2.1 + # with: + # repo_token: "${{ secrets.GITHUB_TOKEN }}" + # prerelease: false + # title: "Sigutils ${{github.ref_name}}" + # files: sigutils*/* diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bcfd681..52d8ac2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -28,7 +28,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - submodules: true fetch-depth: 0 - name: Initialize CodeQL @@ -37,8 +36,10 @@ jobs: languages: ${{ matrix.language }} - name: Install dependencies - run: sudo apt-get update && sudo apt-get install libsndfile1-dev libvolk2-dev libfftw3-dev - + run: | + sudo apt-get update + sudo apt-get install meson libsndfile1-dev libvolk2-dev libfftw3-dev + - name: Autobuild uses: github/codeql-action/autobuild@v3 diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 6e05f87..67f8dc8 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -14,7 +14,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install libsndfile1-dev libvolk2-dev libfftw3-dev doxygen python3-pip + sudo apt-get install meson libsndfile1-dev libvolk2-dev libfftw3-dev doxygen graphviz python3-pip sudo pip3 install coverxygen - name: Determine checkout ref @@ -30,18 +30,18 @@ jobs: with: ref: "${{ steps.fetch_ref.outputs.value }}" fetch-depth: 0 - submodules: true + + - name: Configure + run: meson setup builddir - name: Build documentation - uses: "./.github/actions/build" - with: - target: doxygen + run: meson compile -C builddir docs - name: Upload documentation artifact uses: actions/upload-artifact@v4 with: name: documentation - path: build/doc/html/ + path: builddir/doc/html/ - name: Setup Pages if: contains(github.ref, 'master') && (github.event_name != 'pull_request_target') @@ -53,7 +53,7 @@ jobs: if: contains(github.ref, 'master') && (github.event_name != 'pull_request_target') uses: actions/upload-pages-artifact@v3 with: - path: build/doc/html/ + path: builddir/doc/html/ - name: Deploy to GitHub Pages if: contains(github.ref, 'master') && (github.event_name != 'pull_request_target') @@ -61,16 +61,14 @@ jobs: - name: Documentation coverage if: github.event_name == 'pull_request_target' - uses: "./.github/actions/build" - with: - target: coverxygen_summary + run: meson compile -C builddir docs_coverage - name: Documentation coverage report generation if: github.event_name == 'pull_request_target' run: | EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "report<<$EOF" >> "$GITHUB_ENV" - cat build/doc/doc-coverage.markdown-summary.info >> "$GITHUB_ENV" + cat builddir/doc/coverxygen.md >> "$GITHUB_ENV" echo "$EOF" >> "$GITHUB_ENV" - name: Documentation coverage report diff --git a/doc/Building.md b/doc/Building.md index 5cfefd9..3e4987b 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -5,10 +5,10 @@ ## Getting the code -Just clone it from the GitHub repository. Make sure you pass `--recurse-submodules` to `git clone` so all required submodules are also cloned. +Just clone it from the GitHub repository. ```bash -git clone --recurse-submodules https://github.com/BatchDrake/sigutils.git +git clone https://github.com/BatchDrake/sigutils.git ``` @@ -16,7 +16,7 @@ git clone --recurse-submodules https://github.com/BatchDrake/sigutils.git The following libraries (along with their respective development files) must also be present: -* CMake 3.12.0 or higher is required for the build. +* Meson is required for the build. * sndfile (1.0.2 or later) * fftw3 (3.0 or later) * volk (1.0 or later) (Optional) @@ -24,19 +24,19 @@ The following libraries (along with their respective development files) must als ### Requirements and dependencies in Ubuntu ```bash -sudo apt-get install cmake libsndfile1-dev libvolk2-dev libfftw3-dev +sudo apt-get install meson libsndfile1-dev libvolk2-dev libfftw3-dev ``` ### Requirements and dependencies in Archlinux ```bash -sudo pacman -S libsndfile libvolk fftw cmake +sudo pacman -S meson libsndfile libvolk fftw ``` ### Requirements and dependencies in Windows MSYS2 MinGW64 ```bash -pacman -S mingw-w64-x86_64-cc mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-libsndfile mingw-w64-x86_64-fftw mingw-w64-x86_64-volk +pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-meson mingw-w64-ucrt-x86_64-libsndfile mingw-w64-ucrt-x86_64-fftw mingw-w64-ucrt-x86_64-volk ``` @@ -44,30 +44,21 @@ pacman -S mingw-w64-x86_64-cc mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw ### Configuring the project -You can configure the project into a `build/` folder by executing the following command. This will check for dependencies automatically. +You can configure the project into a `builddir/` folder by executing the following command. This will check for dependencies automatically. ```bash -cmake -B build . +meson setup builddir ``` You may want to specify extra options. -#### Configuring in Windows MSYS2 MinGW64 - -In Windows you may want to instruct that you want MSYS makefiles and the mingw PREFIX. - -```bash -/msys64/mingw64/bin/cmake -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/msys64/mingw64 -``` - - ### Building If the previous commands were successful, you can start the build by typing: ```bash -cmake --build build +meson compile -C builddir ``` @@ -76,5 +67,5 @@ cmake --build build You may want to install the built library in your system: ```bash -sudo cmake --build build --target install +sudo meson install -C builddir ``` diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..bf5351e --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,56 @@ +dep_doxygen = find_program('doxygen', required : false) +dep_python = import('python').find_installation(required : false) +dep_coverxygen = run_command(dep_python, '-c', 'import importlib.util; import sys; exit(1) if importlib.util.find_spec(\'coverxygen\') is None else exit(0)', check : false).returncode() == 0 + +if not dep_doxygen.found() + warning('Documentation disabled because doxygen was not found') +endif + +if not dep_coverxygen + warning('Documentation coverage report disabled because coverxygen was not found') +endif + +if dep_doxygen.found() + # Doxygen input folders... + doxygen_input = [ + meson.current_source_dir(), + join_paths(meson.current_source_dir(), '../src'), + join_paths(meson.current_source_dir(), '../src/include'), + join_paths(meson.current_source_dir(), '../src/include/sigutils'), + join_paths(meson.current_source_dir(), '../src/include/sigutils/specific'), + join_paths(meson.current_source_dir(), '../src/include/sigutils/util'), + join_paths(meson.current_source_dir(), '../src/sigutils'), + join_paths(meson.current_source_dir(), '../src/sigutils/specific'), + join_paths(meson.current_source_dir(), '../src/util'), + ] + + # Configure doxygen... + doxygen_conf_data = configuration_data() + doxygen_conf_data.set('VERSION', meson.project_version()) + doxygen_conf_data.set('INPUT', ' '.join(doxygen_input)) + doxygen_conf_data.set('OUTPUT_DIRECTORY', meson.current_build_dir()) + sigutils_doxygen_conf = configure_file( + input: 'sigutils.doxygen.in', + output: 'sigutils.doxygen', + configuration: doxygen_conf_data, + ) + + # Actual docs target + run_target('docs', + command : [dep_doxygen, sigutils_doxygen_conf] + ) +endif + +if dep_doxygen.found() and dep_coverxygen + run_target('docs_coverage', + command : [ + dep_python, + '-m', 'coverxygen', + '--xml-dir', join_paths(meson.current_build_dir(), 'xml'), + '--src-dir', meson.current_source_dir(), + '--output', join_paths(meson.current_build_dir(), 'coverxygen.md'), + '--format', 'markdown-summary' + ] + ) + +endif \ No newline at end of file diff --git a/doc/sigutils.doxygen.in b/doc/sigutils.doxygen.in new file mode 100644 index 0000000..8814265 --- /dev/null +++ b/doc/sigutils.doxygen.in @@ -0,0 +1,7 @@ +PROJECT_NAME = "Sigutils" +PROJECT_NUMBER = @VERSION@ +GENERATE_HTML = YES +GENERATE_XML = YES +GENERATE_LATEX = NO +INPUT = @INPUT@ +OUTPUT_DIRECTORY = @OUTPUT_DIRECTORY@ \ No newline at end of file diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1b2cd1b --- /dev/null +++ b/meson.build @@ -0,0 +1,5 @@ +project('sigutils', ['c', 'cpp'], version: '0.1', default_options: ['cpp_std=c++17']) + +subdir('src') +subdir('doc') +subdir('tests') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..3abd42d --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('double_precission', type : 'boolean', value : false) \ No newline at end of file diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..9d085ce --- /dev/null +++ b/src/meson.build @@ -0,0 +1,155 @@ +# Find dependencies +dep_thread = dependency('threads') +dep_sndfile = dependency('sndfile', version : '>=1.0.2') +dep_fftw3 = dependency('fftw3', version : '>=3.0') +dep_fftw3f = dependency('fftw3f', version : '>=3.0') +# This is a temporary fix until https://github.com/FFTW/fftw3/issues/180 gets solved +dep_fftw3f_threads = meson.get_compiler('c').find_library('fftw3f_threads', dirs: dep_fftw3.get_variable(pkgconfig: 'libdir')) +dep_volk = dependency('volk', version : '>=1.0', required : false) +dep_math = meson.get_compiler('c').find_library('m', required : false) +dep_ws2 = meson.get_compiler('c').find_library('ws2_32', required : target_machine.system() == 'windows') + +# Library +srcs = files([ + 'sigutils/specific/apt.c', + 'sigutils/agc.c', + 'sigutils/block.c', + 'sigutils/clock.c', + 'sigutils/coef.c', + 'sigutils/dc_corrector.c', + 'sigutils/detect.c', + 'sigutils/equalizer.c', + 'sigutils/iir.c', + 'sigutils/lfsr.c', + 'sigutils/lib.c', + 'sigutils/log.c', + 'sigutils/matfile.c', + 'sigutils/ncqo.c', + 'sigutils/pll.c', + 'sigutils/property.c', + 'sigutils/smoothpsd.c', + 'sigutils/softtune.c', + 'sigutils/specific/apt.c', + 'sigutils/specttuner.c', + 'sigutils/taps.c', + 'sigutils/tvproc.c', + 'sigutils/version.c', + 'util/util.c', +]) + +if target_machine.system() == 'windows' + srcs += files([ + 'util/win32-fcntl.c', + 'util/win32-mman.c', + 'util/win32-poll.c', + 'util/win32-pwd.c', + 'util/win32-statvfs.c', + 'util/win32-stdlib.c', + 'util/win32-termios.c', + 'util/win32-time.c', + 'util/win32-unistd.c', + ]) +endif + +includes = include_directories([ + 'include/', + # This is a fix. It is not clear why fftw3 include dirs are not picked up by pkg-config... + dep_fftw3.get_variable(pkgconfig: 'includedir'), +]) + +c_args = [] +if dep_volk.found() + c_args += '-DHAVE_VOLK' +endif +if not get_option('double_precission') + c_args += '-D_SU_SINGLE_PRECISION' +endif + +lib_sigutils = shared_library('sigutils', srcs, + include_directories : includes, + dependencies : [dep_thread, dep_sndfile, dep_fftw3, dep_fftw3f, dep_fftw3f_threads, dep_volk, dep_math, dep_ws2], + c_args : c_args, + version : meson.project_version(), + install : true) + +pkg = import('pkgconfig') +pkg.generate(lib_sigutils, extra_cflags : c_args) + +# Headers +install_headers( + files([ + 'include/sigutils/agc.h', + 'include/sigutils/block.h', + 'include/sigutils/clock.h', + 'include/sigutils/coef.h', + 'include/sigutils/dc_corrector.h', + 'include/sigutils/decider.h', + 'include/sigutils/defs.h', + 'include/sigutils/detect.h', + 'include/sigutils/equalizer.h', + 'include/sigutils/iir.h', + 'include/sigutils/lfsr.h', + 'include/sigutils/log.h', + 'include/sigutils/matfile.h', + 'include/sigutils/ncqo.h', + 'include/sigutils/pll.h', + 'include/sigutils/property.h', + 'include/sigutils/sampling.h', + 'include/sigutils/sigutils.h', + 'include/sigutils/smoothpsd.h', + 'include/sigutils/softtune.h', + 'include/sigutils/specttuner.h', + 'include/sigutils/taps.h', + 'include/sigutils/tvproc.h', + 'include/sigutils/types.h', + 'include/sigutils/version.h', + ]), + subdir : 'sigutils') + +install_headers( + files([ + 'include/sigutils/specific/apt.h', + ]), + subdir : 'sigutils/specific') + +install_headers( + files([ + 'include/sigutils/util/compat-fcntl.h', + 'include/sigutils/util/compat-in.h', + 'include/sigutils/util/compat-inet.h', + 'include/sigutils/util/compat-mman.h', + 'include/sigutils/util/compat-netdb.h', + 'include/sigutils/util/compat-poll.h', + 'include/sigutils/util/compat-pwd.h', + 'include/sigutils/util/compat-select.h', + 'include/sigutils/util/compat-socket.h', + 'include/sigutils/util/compat-stat.h', + 'include/sigutils/util/compat-statvfs.h', + 'include/sigutils/util/compat-stdlib.h', + 'include/sigutils/util/compat-termios.h', + 'include/sigutils/util/compat-time.h', + 'include/sigutils/util/compat-unistd.h', + 'include/sigutils/util/util.h', + 'include/sigutils/util/win32-fcntl.h', + 'include/sigutils/util/win32-in.h', + 'include/sigutils/util/win32-inet.h', + 'include/sigutils/util/win32-mman.h', + 'include/sigutils/util/win32-netdb.h', + 'include/sigutils/util/win32-poll.h', + 'include/sigutils/util/win32-pwd.h', + 'include/sigutils/util/win32-socket.h', + 'include/sigutils/util/win32-stat.h', + 'include/sigutils/util/win32-statvfs.h', + 'include/sigutils/util/win32-stdlib.h', + 'include/sigutils/util/win32-termios.h', + 'include/sigutils/util/win32-time.h', + 'include/sigutils/util/win32-unistd.h', + ]), + subdir : 'sigutils/util') + +# Create a dep for the test executables +dep_sigutils = declare_dependency( + include_directories : includes, + link_with : lib_sigutils, + compile_args : c_args +) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..ee0250e --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,34 @@ +dep_catch2 = dependency('catch2-with-main', required : false) +if not dep_catch2.found() + dep_catch2 = dependency('catch2', required : false) +endif + +if not dep_catch2.found() + warning('Testing is disabled because catch2 was not found') +endif + +if dep_catch2.found() + # Test sources + test_srcs = files([ + 'test_ncqo.cpp', + ]) + + # Catch hack to be compatible with v2 and v3... + test_cpp_args = [] + if dep_catch2.version().version_compare('>3') + test_cpp_args += '-DCATCH2_V3' + else + test_cpp_args += '-DCATCH2_V2' + endif + + # Test executable + test_exe = executable('sigutils_test', + test_srcs, + cpp_args : test_cpp_args, + dependencies : [dep_sigutils, dep_catch2], + build_by_default : false, + install : false) + + # Let meson know what our executable is + test('Sigutils tests', test_exe) +endif