summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-07-18 14:21:22 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-07-18 14:21:22 +0200
commit42c934681970381a15aa1714822e65492bd51cc3 (patch)
treec0d19346fe7ba77bb042aa88d2d29578f51b9a76 /meson.build
parent2b118a33f65866295eeb716c9bc6401082ca4c8e (diff)
parent968b4027f4f13ebc311c3aab741fbc2eea50cca3 (diff)
downloadlibnitrokey-42c934681970381a15aa1714822e65492bd51cc3.tar.gz
libnitrokey-42c934681970381a15aa1714822e65492bd51cc3.tar.bz2
Merge branch 'pr_128'
Meson fixes for tests build Fixes #128
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build29
1 files changed, 19 insertions, 10 deletions
diff --git a/meson.build b/meson.build
index 21e79f5..b14fe0c 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')
@@ -105,23 +113,24 @@ 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')
+ 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 : [
'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
@@ -129,7 +138,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')