From 5a7936d7979e53c4db0e5443b4c0d2d0c880f3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20V=C3=A1zquez?= Date: Mon, 18 Dec 2023 00:14:29 +0100 Subject: [PATCH] Meson build system support --- .github/actions/build/action.yml | 27 ------ .github/actions/package/action.yml | 41 -------- .github/actions/test/action.yml | 14 --- .github/dependabot.yml | 5 - .github/workflows/build.yml | 111 ++++++---------------- .github/workflows/codeql.yml | 7 +- .github/workflows/doc.yml | 20 ++-- .gitmodules | 3 - CMakeLists.txt | 70 -------------- cmake/cmake-gitversiondetect | 1 - cmake/cmake-pcfilegenerator | 1 - cmake/cmake-relativefilemacro | 1 - cmake/modules/CodeAnalysis.cmake | 32 ------- cmake/modules/FindCoverxygen.cmake | 34 ------- cmake/modules/FindCppCheck.cmake | 140 --------------------------- doc/Building.md | 29 ++---- doc/CMakeLists.txt | 34 ------- doc/meson.build | 56 +++++++++++ doc/sigutils.doxygen.in | 7 ++ meson.build | 5 + src/CMakeLists.txt | 141 --------------------------- src/meson.build | 148 +++++++++++++++++++++++++++++ tests/CMakeLists.txt | 24 ----- tests/meson.build | 34 +++++++ 24 files changed, 301 insertions(+), 684 deletions(-) delete mode 100644 .github/actions/build/action.yml delete mode 100644 .github/actions/package/action.yml delete mode 100644 .github/actions/test/action.yml delete mode 100644 CMakeLists.txt delete mode 160000 cmake/cmake-gitversiondetect delete mode 160000 cmake/cmake-pcfilegenerator delete mode 160000 cmake/cmake-relativefilemacro delete mode 100644 cmake/modules/CodeAnalysis.cmake delete mode 100644 cmake/modules/FindCoverxygen.cmake delete mode 100644 cmake/modules/FindCppCheck.cmake delete mode 100644 doc/CMakeLists.txt create mode 100644 doc/meson.build create mode 100644 doc/sigutils.doxygen.in create mode 100644 meson.build delete mode 100644 src/CMakeLists.txt create mode 100644 src/meson.build delete mode 100644 tests/CMakeLists.txt create mode 100644 tests/meson.build 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 de9f06e..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@v3 - with: - name: linux-deb.zip - path: build/dist/*.deb - - - name: Upload TGZ artifact - if: runner.os == 'Linux' - uses: actions/upload-artifact@v3 - with: - name: linux-tgz.zip - path: build/dist/*.tar.gz - - - name: Upload TGZ artifact - if: runner.os == 'MacOS' - uses: actions/upload-artifact@v3 - with: - name: macos-tgz.zip - path: build/dist/*.tar.gz - - - name: Upload ZIP artifact - if: runner.os == 'Windows' - uses: actions/upload-artifact@v3 - with: - name: 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 5a1353e..bf006c8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,8 +8,3 @@ updates: target-branch: "develop" schedule: interval: "weekly" - - package-ecosystem: "gitsubmodule" - directory: "/" - target-branch: "develop" - schedule: - interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 153e983..1aacb5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,104 +3,49 @@ 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 - - - 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" - - - 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 + build: + strategy: + matrix: + sys: + - { os: windows-latest, shell: 'msys2 {0}' } + - { os: ubuntu-latest, shell: bash } + - { os: macos-latest, shell: bash } - - name: Build tests - uses: "./.github/actions/build" - with: - target: sigutils_test + runs-on: ${{ matrix.sys.os }} - - 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 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 + install: git mingw-w64-x86_64-meson mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc mingw-w64-x86_64-libsndfile mingw-w64-x86_64-fftw mingw-w64-x86_64-volk mingw-w64-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 + run: meson test -C builddir diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a78ae51..b12e985 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@v2 diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 491749e..9d5e76f 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@v3 with: name: documentation - path: build/doc/html/ + path: builddir/doc/html/ - name: Setup Pages if: contains(github.ref, 'develop') && (github.event_name != 'pull_request_target') @@ -53,7 +53,7 @@ jobs: if: contains(github.ref, 'develop') && (github.event_name != 'pull_request_target') uses: actions/upload-pages-artifact@v2 with: - path: build/doc/html/ + path: builddir/doc/html/ - name: Deploy to GitHub Pages if: contains(github.ref, 'develop') && (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/.gitmodules b/.gitmodules index 0baef4f..7681bac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "cmake/cmake-gitversiondetect"] path = cmake/cmake-gitversiondetect url = https://github.com/antoniovazquezblanco/cmake-gitversiondetect.git -[submodule "cmake/cmake-pcfilegenerator"] - path = cmake/cmake-pcfilegenerator - url = https://github.com/antoniovazquezblanco/cmake-pcfilegenerator.git [submodule "cmake/cmake-relativefilemacro"] path = cmake/cmake-relativefilemacro url = https://github.com/antoniovazquezblanco/cmake-relativefilemacro.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 6355b75..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ -# -# CMakeLists.txt: CMake configuration file for sigutils -# -# Copyright (C) 2019 Gonzalo José Carracedo Carballal -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# -# -# - -cmake_minimum_required(VERSION 3.20.0) - -# CMake modules search path -file(GLOB MODULE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*/" LIST_DIRECTORIES true) -list(APPEND CMAKE_MODULE_PATH "${MODULE_DIRS}") - -# Check that all required submodules are there -set( - GIT_CMAKE_SUBMODULES - cmake-gitversiondetect - cmake-pcfilegenerator - cmake-relativefilemacro) - -foreach (submodule IN ITEMS ${GIT_CMAKE_SUBMODULES}) - if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${submodule}/.git") - message( FATAL_ERROR "Required CMake submodule `${submodule}' not found. This \ - is most likely caused by an incomplete clone from the main repository. Please run: - $ git submodule update --init --recursive -to clone all required submodules and run CMake again.") - endif() -endforeach() - -# Use git version detect to obtain a project version based on tags -include(GitVersionDetect) -set(SIGUTILS_VERSION_MAJOR ${GITVERSIONDETECT_VERSION_MAJOR}) -set(SIGUTILS_VERSION_MINOR ${GITVERSIONDETECT_VERSION_MINOR}) -set(SIGUTILS_VERSION_PATCH ${GITVERSIONDETECT_VERSION_PATCH}) -set(SIGUTILS_VERSION ${SIGUTILS_VERSION_MAJOR}.${SIGUTILS_VERSION_MINOR}.${SIGUTILS_VERSION_PATCH}) - -# Define the project -project( - sigutils - VERSION ${SIGUTILS_VERSION} - DESCRIPTION "Small signal processing utility library" - HOMEPAGE_URL "http://github.org/BatchDrake/sigutils" - LANGUAGES C CXX) - -# Always use top level dir for generated targets to avoid linker problems -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -# The library code is in src -add_subdirectory(src) - -# The documentation is in doc -add_subdirectory(doc) - -# Tests are in the tests dir -include(CTest) -add_subdirectory(tests) diff --git a/cmake/cmake-gitversiondetect b/cmake/cmake-gitversiondetect deleted file mode 160000 index 0b35a72..0000000 --- a/cmake/cmake-gitversiondetect +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0b35a729aedc600669cfb73ff6bc5bd954164771 diff --git a/cmake/cmake-pcfilegenerator b/cmake/cmake-pcfilegenerator deleted file mode 160000 index c6012b1..0000000 --- a/cmake/cmake-pcfilegenerator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6012b18c68d7ede8ec9bbd4bc05dfd1d6923b82 diff --git a/cmake/cmake-relativefilemacro b/cmake/cmake-relativefilemacro deleted file mode 160000 index 3d0e4c5..0000000 --- a/cmake/cmake-relativefilemacro +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3d0e4c529dd5d83920e4299fecfb4355a4b9113c diff --git a/cmake/modules/CodeAnalysis.cmake b/cmake/modules/CodeAnalysis.cmake deleted file mode 100644 index 3e4d8e2..0000000 --- a/cmake/modules/CodeAnalysis.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -CodeAnalysis -------- - -Add code format target. - -Custom Targets -^^^^^^^^^^^^^^^^ - -This module provides the following custom target, if found: - -``cppcheck-analysis`` - The code analysis custom target. - -#]=======================================================================] - -if(TARGET codeanalysis) - return() -endif() - -find_package(CppCheck) - -if(CppCheck_FOUND) - message("Cppcheck analysis already added") - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck) - add_custom_target(codeanalysis - COMMAND ${CPPCHECK_COMMAND}) -endif() diff --git a/cmake/modules/FindCoverxygen.cmake b/cmake/modules/FindCoverxygen.cmake deleted file mode 100644 index 5a801b9..0000000 --- a/cmake/modules/FindCoverxygen.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later -# Copyright 2023 Antonio Vázquez Blanco - -# This package uses FindPython3, set min ver acordingly -cmake_minimum_required(VERSION 3.12.0) - -# Check if python is available... -find_package(Python3 COMPONENTS Interpreter) - -if(Python3_Interpreter_FOUND) - # Python found. Try to find the module... - execute_process( - COMMAND ${Python3_EXECUTABLE} -c "import coverxygen" - RESULT_VARIABLE EXIT_CODE - OUTPUT_QUIET - ) - if (${EXIT_CODE} EQUAL 0) - set(Coverxygen_FOUND ON) - set(Coverxygen_COMMAND "${Python3_EXECUTABLE} -m coverxygen") - endif() -endif() - -if (NOT Coverxygen_FOUND) - message("Coverxygen not found") -endif() - -function(coverxygen_add_report targetName srcDir doxygenTarget reportFormat) - get_filename_component(absSrcDir "${srcDir}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - add_custom_target(${targetName} VERBATIM - COMMAND "${Python3_EXECUTABLE}" -m coverxygen --xml-dir "${CMAKE_CURRENT_BINARY_DIR}/xml" --src-dir "${absSrcDir}" --output "${CMAKE_CURRENT_BINARY_DIR}/doc-coverage.${reportFormat}.info" --format ${reportFormat} - DEPENDS ${doxygenTarget} - COMMENT "Generate documentation coverage report in ${reportFormat} for ${targetName}" - ) -endfunction() diff --git a/cmake/modules/FindCppCheck.cmake b/cmake/modules/FindCppCheck.cmake deleted file mode 100644 index f2a30da..0000000 --- a/cmake/modules/FindCppCheck.cmake +++ /dev/null @@ -1,140 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindCppCheck -------- - -Finds the CppCheck Tool. - -Custom Targets -^^^^^^^^^^^^^^^^ - -This module provides the following custom targets, if found: - -``cppcheck-analysis`` - The CppCheck custom target - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``CppCheck_FOUND`` - True if the system has the cppcheck tool. -``CppCheck_VERSION`` - Version of cppcheck tool. - -#]=======================================================================] - -if(CPPCHECK_ROOT_DIR) - find_program(CPPCHECK_BIN - NAMES - cppcheck - PATHS - "${CPPCHECK_ROOT_DIR}" - NO_DEFAULT_PATH) -endif() - -if(NOT CPPCHECK_BIN) - find_program(CPPCHECK_BIN NAMES cppcheck) -endif() - -if(CPPCHECK_BIN) - execute_process( - COMMAND ${CPPCHECK_BIN} --version - OUTPUT_VARIABLE CppCheck_VERSION - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - set(CPPCHECK_THREADS_ARG "-j4" - CACHE STRING "The number of threads to use") - set(CPPCHECK_PROJECT_ARG "--project=${PROJECT_BINARY_DIR}/compile_commands.json" - CACHE STRING "The project directory to use") - set(CPPCHECK_BUILD_DIR_ARG "--cppcheck-build-dir=${PROJECT_BINARY_DIR}/analysis/cppcheck" - CACHE STRING "The build directory to use") - - # Don't show these errors - if(EXISTS "${CMAKE_SOURCE_DIR}/.cppcheck-suppressions") - set(CPPCHECK_SUPPRESSIONS "--suppressions-list=${CMAKE_SOURCE_DIR}/.cppcheck-suppressions" - CACHE STRING "The suppressions file to use") - else() - set(CPPCHECK_SUPPRESSIONS "" - CACHE STRING "The suppressions file to use") - endif() - - # Show these errors but don't fail the build - if(EXISTS "${CMAKE_SOURCE_DIR}/.cppcheck-exitcode-suppressions") - set(CPPCHECK_EXITCODE_SUPPRESSIONS "--exitcode-suppressions=${CMAKE_SOURCE_DIR}/.cppcheck-exitcode-suppressions" - CACHE STRING "The exitcode suppressions file to use") - else() - set(CPPCHECK_EXITCODE_SUPPRESSIONS "" - CACHE STRING "The exitcode suppressions file to use") - endif() - - set(CPPCHECK_ERROR_EXITCODE_ARG "--error-exitcode=1" - CACHE STRING "The exitcode to use if an error is found") - set(CPPCHECK_CHECKS_ARGS "--enable=warning" - CACHE STRING "Arguments for the checks to run") - set(CPPCHECK_OTHER_ARGS "" - CACHE STRING "Other arguments") - - set(_CPPCHECK_EXCLUDES) - foreach(ex ${CPPCHECK_EXCLUDES}) - list(APPEND _CPPCHECK_EXCLUDES "-i${ex}") - endforeach(ex) - - set(CPPCHECK_ALL_ARGS - ${CPPCHECK_THREADS_ARG} - ${CPPCHECK_PROJECT_ARG} - ${CPPCHECK_BUILD_DIR_ARG} - ${CPPCHECK_ERROR_EXITCODE_ARG} - ${CPPCHECK_SUPPRESSIONS} - ${CPPCHECK_EXITCODE_SUPPRESSIONS} - ${CPPCHECK_CHECKS_ARGS} - ${CPPCHECK_OTHER_ARGS} - ${_CPPCHECK_EXCLUDES} - ) - - if(NOT CPPCHECK_XML_OUTPUT) - set(CPPCHECK_COMMAND - ${CPPCHECK_BIN} - ${CPPCHECK_ALL_ARGS} - ) - else() - set(CPPCHECK_COMMAND - ${CPPCHECK_BIN} - ${CPPCHECK_ALL_ARGS} - --xml - --xml-version=2 - 2> ${CPPCHECK_XML_OUTPUT}) - endif() -endif() - -# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - CppCheck - DEFAULT_MSG - CPPCHECK_BIN) - -mark_as_advanced( - CPPCHECK_BIN - CPPCHECK_THREADS_ARG - CPPCHECK_PROJECT_ARG - CPPCHECK_BUILD_DIR_ARG - CPPCHECK_SUPPRESSIONS - CPPCHECK_EXITCODE_SUPPRESSIONS - CPPCHECK_ERROR_EXITCODE_ARG - CPPCHECK_CHECKS_ARGS - CPPCHECK_OTHER_ARGS) - -if(CppCheck_FOUND) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck) - add_custom_target(cppcheck-analysis - COMMAND ${CPPCHECK_COMMAND}) - message("CppCheck found. Use cppcheck-analysis targets to run it") -else() - message("CppCheck not found") -endif() diff --git a/doc/Building.md b/doc/Building.md index 49828b2..dbecede 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, and `-b develop` to get the latest changes from the development branch. +Just clone it from the GitHub repository. Make sure you pass `-b develop` to get the latest changes from the development branch. ```bash -git clone -b develop --recurse-submodules https://github.com/BatchDrake/sigutils.git +git clone -b develop https://github.com/BatchDrake/sigutils.git ``` @@ -16,7 +16,7 @@ git clone -b develop --recurse-submodules https://github.com/BatchDrake/sigutils 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-x86_64-cc mingw-w64-x86_64-ninja mingw-w64-x86_64-meson mingw-w64-x86_64-libsndfile mingw-w64-x86_64-fftw mingw-w64-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/CMakeLists.txt b/doc/CMakeLists.txt deleted file mode 100644 index 4e39652..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# Check for the required dependencies -find_package(Doxygen) -find_package(Coverxygen) - -if (NOT DOXYGEN_FOUND) - message("Doxygen needs to be installed to generate the documentation") -else() - # Select doxygen output formats - set(DOXYGEN_GENERATE_HTML YES) - if(${Coverxygen_FOUND}) - set(DOXYGEN_GENERATE_XML YES) - endif() - - # Other doxy options - set(DOXYGEN_EXTRACT_ALL YES) - set(DOXYGEN_EXTRACT_PRIVATE YES) - set(DOXYGEN_EXTRACT_PACKAGE YES) - set(DOXYGEN_EXTRACT_STATIC YES) - set(DOXYGEN_EXTRACT_LOCAL_CLASSES YES) - set(DOXYGEN_EXTRACT_LOCAL_METHODS YES) - set(DOXYGEN_EXTRACT_ANON_NSPACES YES) - set(DOXYGEN_MACRO_EXPANSION YES) - get_target_property(DOXYGEN_INCLUDE_PATH sigutils INCLUDE_DIRECTORIES) - set(DOXYGEN_SKIP_FUNCTION_MACROS NO) - - # Add a Doxygen target - doxygen_add_docs(doxygen "../src" ".") -endif() - -if (DOXYGEN_FOUND AND NOT Coverxygen_FOUND) - message("Coverxygen needs to be installed to generate the documentation coverage reports") -else() - coverxygen_add_report(coverxygen_summary "../src" doxygen markdown-summary) -endif() 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/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index e7e70b0..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ -# -# CMakeLists.txt: CMake configuration file for sigutils -# -# Copyright (C) 2019 Gonzalo José Carracedo Carballal -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# -# -# - -# Set the ABI version manually -set(SIGUTILS_ABI_VERSION 1) - -# Late module imports that depend on project definitions -include(FindPkgConfig) -include(CodeAnalysis) -include(GNUInstallDirs) -include(RelativeFileMacro) -include(PcFileGenerator) - -# Find requirements -find_package(Threads) - -pkg_check_modules(SNDFILE REQUIRED sndfile>=1.0.2) -include_directories(${SNDFILE_INCLUDE_DIRS}) -link_directories(${SNDFILE_LIBRARY_DIRS}) - -pkg_check_modules(FFTW3 REQUIRED fftw3f>=3.0) -include_directories(${FFTW3_INCLUDE_DIRS}) -link_directories(${FFTW3_LIBRARY_DIRS}) - -pkg_check_modules(VOLK volk>=1.0) -if(VOLK_FOUND) - include_directories(${VOLK_INCLUDE_DIRS}) - link_directories(${VOLK_LIBRARY_DIRS}) -endif() - -# Project build options -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) -endif() -if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math -s") -endif() - -option(SIGUTILS_SINGLE_PRECISSION "Use single precission data types" ON) - -if (DEFINED PKGVERSION) - # If you are building sigutils for your own software distribution, you may want - # to set PKGVERSION to some descriptive string. - add_compile_definitions(SIGUTILS_PKGVERSION="${PKGVERSION}") -endif() - -# Source location -file(GLOB_RECURSE SRCS LIST_DIRECTORIES false *.c) -file(GLOB_RECURSE SRCS_WIN LIST_DIRECTORIES false win32-*.c) -if(NOT WIN32) - list(REMOVE_ITEM SRCS ${SRCS_WIN}) -endif() - -# Define the library target -add_library(sigutils SHARED ${SRCS}) - -# Define relative filename macros -target_add_relative_file_macro(sigutils) - -# Add public include directories -target_include_directories(sigutils PUBLIC include/) - -# Extra compilation definitions -if(SIGUTILS_SINGLE_PRECISSION) - target_compile_definitions(sigutils PUBLIC _SU_SINGLE_PRECISION) -endif() - -if(VOLK_FOUND) - target_compile_definitions(sigutils PUBLIC HAVE_VOLK) -endif() - -# Target properties -set_property(TARGET sigutils PROPERTY VERSION ${SIGUTILS_VERSION}) -set_property(TARGET sigutils PROPERTY SOVERSION ${SIGUTILS_ABI_VERSION}) - -# Target dependencies -target_link_libraries(sigutils ${SNDFILE_LIBRARIES}) -target_link_libraries(sigutils ${FFTW3_LIBRARIES}) -target_link_libraries(sigutils fftw3f_threads) -target_link_libraries(sigutils ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(sigutils m) - -if(WIN32) - target_link_libraries(sigutils ws2_32) -endif() - -if(VOLK_FOUND) - target_link_libraries(sigutils ${VOLK_LIBRARIES}) -endif() - -# PC file generation -target_pc_file_generate(sigutils "Digital signal processing utility library") - -# File install -install(TARGETS sigutils LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT LIB) -install(DIRECTORY include/sigutils DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT DEVEL) -install(FILES ${PROJECT_BINARY_DIR}/src/sigutils.pc DESTINATION ${CMAKE_INSTALL_PKGCONFIGDIR} COMPONENT DEVEL) - -# General packaging settings -set(CPACK_PACKAGE_NAME sigutils) -set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/dist) - -# DEB packaging settings -set(CPACK_DEB_COMPONENT_INSTALL ON) -if(GITVERSIONDETECT_VERSION_COMMIT_NUM) - set(CPACK_DEBIAN_PACKAGE_VERSION ${GITVERSIONDETECT_VERSION}) -endif() -set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "arf20 ") -set(CPACK_DEBIAN_LIB_PACKAGE_DEPENDS "libsndfile1 (>= 1.0.31-2build1), libvolk2.5 (>= 2.5.1-1), libfftw3-single3 (>= 3.3.8-2)") -set(CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS "libsndfile1-dev (>= 1.0.31-2build1), libvolk2-dev (>= 2.5.1-1), libfftw3-dev (>= 3.3.8-2)") -set(CPACK_DEBIAN_LIB_PACKAGE_NAME "libsigutils") -set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME "libsigutils-dev") -set(CPACK_DEBIAN_LIB_PACKAGE_SECTION "libs") -set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION "libdevel") - -# Include CPack -include(CPack) - -# CPack component information -cpack_add_component(LIB DISPLAY_NAME "Runtime library") -cpack_add_component(DEVEL DISPLAY_NAME "Development files" DEPENDS LIB) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..e3e5992 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,148 @@ +# 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') +dep_fftw3f_threads = meson.get_compiler('c').find_library('fftw3_threads') +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/', +]) + +args = [] +if dep_volk.found() + args += '-DHAVE_VOLK' +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 : args, + version : meson.project_version(), + install : true) + +pkg = import('pkgconfig') +pkg.generate(lib_sigutils) + +# 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 +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 9eec302..0000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -find_package(Catch2) - -if(Catch2_FOUND) - # General options - file(GLOB_RECURSE TEST_SRCS LIST_DIRECTORIES false *.cpp) - add_executable(sigutils_test EXCLUDE_FROM_ALL ${TEST_SRCS}) - target_include_directories(sigutils_test PUBLIC $) - target_compile_definitions(sigutils_test PUBLIC $) - target_link_libraries(sigutils_test $) - include(Catch) - catch_discover_tests(sigutils_test) - - if(Catch2_VERSION_MAJOR EQUAL 2) - target_compile_definitions(sigutils_test PUBLIC CATCH2_V2) - target_link_libraries(sigutils_test Catch2::Catch2) - elseif(Catch2_VERSION_MAJOR EQUAL 3) - target_compile_definitions(sigutils_test PUBLIC CATCH2_V3) - target_link_libraries(sigutils_test Catch2::Catch2WithMain) - else() - message("Unsuported Catch2 version") - endif() -else() - message("Catch2 needs to be installed to perform unit testing") -endif() 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