From e123cd3ef8ae782329ead1af1e8dbe448a728f27 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Tue, 6 Aug 2019 10:58:56 -0400 Subject: [PATCH] meson testing template --- .travis.yml | 30 +++++++++++++++++------------- README.md | 5 ----- cmake/compilers.cmake | 13 ++++--------- meson.build | 24 ++++++++++++++++++------ 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe24ec9a..b674cd11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: minimal +language: python group: travis_latest dist: xenial @@ -17,17 +17,21 @@ matrix: include: - os: linux env: FC=gfortran-6 - - os: osx - env: FC=gfortran - before_install: - - brew update > /dev/null - - brew upgrade cmake > /dev/null - - brew install gcc > /dev/null - - brew install hdf5 > /dev/null +# OSX OK, but move to Azure for speed + # - os: osx + # env: FC=gfortran + # before_install: + # - brew update > /dev/null + # - brew upgrade cmake > /dev/null + # - brew install gcc > /dev/null + # - brew install hdf5 > /dev/null -install: -- cd build -- cmake .. -- cmake --build . --parallel +before_install: +- git -C $HOME clone https://github.com/mesonbuild/meson +- python -m pip install -e $HOME/meson +- curl -Ls https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip -o ninja-linux.zip +- sudo unzip ninja-linux.zip -d /usr/local/bin/ -script: ctest --parallel --output-on-failure +install: meson build + +script: meson test -C build diff --git a/README.md b/README.md index afa54bf6..8f2740f9 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,6 @@ The library `libh5oo` is built, link it into your program as usual. ```sh meson build -ninja -C build -``` - -Optionally test via: -```sh meson test -C build ``` diff --git a/cmake/compilers.cmake b/cmake/compilers.cmake index 0af80903..76e0cbd5 100644 --- a/cmake/compilers.cmake +++ b/cmake/compilers.cmake @@ -1,15 +1,10 @@ - -message(STATUS "CMake Build Type: ${CMAKE_BUILD_TYPE}") - if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - if(NOT WIN32) - set(FFLAGS -stand f18 -implicitnone -traceback -warn -heap-arrays) + set(FFLAGS -stand f18 -warn declarations -traceback -warn -heap-arrays) else() - set(FFLAGS /stand:f18 /4Yd /traceback /warn /heap-arrays) + set(FFLAGS /stand:f18 /warn:declarations /traceback /warn /heap-arrays) # Note: -g is /debug:full for ifort Windows endif() - elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) list(APPEND FFLAGS -march=native -fimplicit-none) @@ -23,9 +18,9 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) list(APPEND FFLAGS -Wall -Wextra -Wpedantic -Werror=array-bounds -Warray-temporaries) elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI) - + set(FFLAGS -C -Mdclchk) elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Flang) - + set(FFLAGS -W) elseif(CMAKE_Fortran_COMPILER_ID STREQUAL NAG) list(APPEND FFLAGS -u -C=all) endif() diff --git a/meson.build b/meson.build index 2b076c7f..215da7d4 100644 --- a/meson.build +++ b/meson.build @@ -1,24 +1,36 @@ project('Object-oriented HDF5 Fortran', 'fortran', - meson_version : '>=0.50', + meson_version : '>=0.51.2', version : '1.0.0') +quiet = ['-w'] + fc = meson.get_compiler('fortran') if fc.get_id() == 'gcc' - add_global_arguments('-O', '-fimplicit-none', '-Wextra', '-Wpedantic', language : 'fortran') + add_project_arguments('-O', '-fimplicit-none', '-Wextra', '-Wpedantic', language : 'fortran') quiet = ['-Wno-compare-reals', '-Wno-maybe-uninitialized'] -else - quiet = ['-w'] + if fc.version().version_compare('>=8') + add_project_arguments('-std=f2018', language : 'fortran') + endif +elif fcid == 'intel' + add_project_arguments('-warn', '-heap-arrays', '-stand f18', language : 'fortran') +elif fcid == 'intel-cl' + add_project_arguments('/warn', '/heap-arrays', '/stand:f18', language : 'fortran') +elif fcid == 'pgi' + add_project_arguments('-C', '-Mdclchk', language : 'fortran') endif hdf5 = dependency('hdf5', language : 'fortran') -h5run = fc.run('use h5lt; end', dependencies: hdf5) +h5run = fc.run('use h5lt; end', dependencies: hdf5, name: 'HDF5') if h5run.returncode() != 0 error('HDF5 linking problems: ' + h5run.stderr()) endif subdir('src') -ooh5 = library('oohdf5', hdf5_src, dependencies: hdf5) +ooh5 = library('oohdf5', + sources: hdf5_src, + dependencies: hdf5 +) # --- testing subdir('tests')