From bfb4fd3db104ce9d65129e8a24ab940ae2c968c5 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 18 Jul 2018 13:37:35 +0200 Subject: meson: test_minimal is written in C Signed-off-by: Igor Gnatenko --- meson.build | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 21e79f5..148fadf 100644 --- a/meson.build +++ b/meson.build @@ -11,12 +11,20 @@ cxx = meson.get_compiler('cpp') host_system = host_machine.system() pkg = import('pkgconfig') -test_cflags = [ +common_flags = [ '-Wno-unused-function', '-Wcast-qual', +] +test_cxxflags = common_flags + [ '-Woverloaded-virtual', ] -add_project_arguments(cxx.get_supported_arguments(test_cflags), language : 'cpp') +test_cflags = common_flags +add_project_arguments(cxx.get_supported_arguments(test_cxxflags), language : 'cpp') +if get_option('offline-tests') + add_languages('c', required: get_option('offline-tests')) + c = meson.get_compiler('c') + add_project_arguments(c.get_supported_arguments(test_cflags), language : 'c') +endif dep_hidapi = dependency('hidapi-libusb') @@ -129,7 +137,7 @@ tests = [] if get_option('offline-tests') tests += [ ['test_offline', 'test_offline.cc'], - ['test_minimal', 'test_minimal.cc'], + ['test_minimal', 'test_minimal.c'], ] endif if get_option('tests') -- cgit v1.2.3 From 586be530f0782499088708e34cf05073924ecb9c Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 18 Jul 2018 13:46:29 +0200 Subject: meson: fix usage of system-wide catch Signed-off-by: Igor Gnatenko --- meson.build | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 148fadf..c81fbbf 100644 --- a/meson.build +++ b/meson.build @@ -113,23 +113,19 @@ pkg.generate( ) if get_option('tests') or get_option('offline-tests') - # FIXME - _inc_catch = include_directories('/usr/include/catch') - if not cxx.has_header('catch.hpp', include_directories : _inc_catch) - error('Can\'t find catch.hpp') - endif + dep_catch = dependency('catch') _catch = static_library( 'catch', sources : [ 'unittest/catch_main.cpp', ], - include_directories : [ - _inc_catch, + dependencies : [ + dep_catch, ], ) _dep_catch = declare_dependency( link_with : _catch, - include_directories : _inc_catch, + dependencies : dep_catch, ) endif -- cgit v1.2.3 From 968b4027f4f13ebc311c3aab741fbc2eea50cca3 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 18 Jul 2018 13:52:16 +0200 Subject: meson: add support for bundled catch Better to use meson's subproject, but let's go with submodule for now. Signed-off-by: Igor Gnatenko --- README.md | 9 +++------ meson.build | 7 ++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1bc8ef9..b101114 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,11 @@ Other build options (all take either `ON` or `OFF`): It is possible to use Meson and Ninja to build the project as well (currently available only `master` branch). Please run: ``` -meson builddir -cd builddir -meson configure # to show available build flags -ninja +meson builddir +meson configure builddir # to show available build flags +ninja -C builddir ``` -Tests build with bundled Catch is not supported yet with this method. - # Using libnitrokey with Python To use libnitrokey with Python a [CFFI](http://cffi.readthedocs.io/en/latest/overview.html) library is required (either 2.7+ or 3.0+). It can be installed with: ```bash diff --git a/meson.build b/meson.build index c81fbbf..b14fe0c 100644 --- a/meson.build +++ b/meson.build @@ -113,7 +113,12 @@ pkg.generate( ) if get_option('tests') or get_option('offline-tests') - dep_catch = dependency('catch') + dep_catch = dependency('catch', required : false) + if not dep_catch.found() + dep_catch = declare_dependency( + include_directories : include_directories('unittest/Catch/single_include') + ) + endif _catch = static_library( 'catch', sources : [ -- cgit v1.2.3