summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-26 20:13:05 -0400
committerDavid Robillard <d@drobilla.net>2022-10-26 20:13:05 -0400
commitaa6083928859207fe65d6710f5c6a6fbab61efef (patch)
tree0f3517d20513f7fa889763d5d992b77ae1fe8e25
parent124355ee047073166345df58234ef38a2dffac25 (diff)
downloadzix-aa6083928859207fe65d6710f5c6a6fbab61efef.tar.gz
zix-aa6083928859207fe65d6710f5c6a6fbab61efef.tar.bz2
zix-aa6083928859207fe65d6710f5c6a6fbab61efef.zip
Fix test build on systems with older or missing C++ compilers
-rw-r--r--meson.build44
1 files changed, 31 insertions, 13 deletions
diff --git a/meson.build b/meson.build
index 0885cf7..540537d 100644
--- a/meson.build
+++ b/meson.build
@@ -177,7 +177,7 @@ int main(void) { return sysconf(_SC_PAGE_SIZE) > 0L; }'''
(host_machine.system() != 'windows' and
cc.links(sysconf_code,
args: platform_c_args,
- name: 'sysconf')).to_int()),
+ name: 'sysconf')).to_int()),
]
endif
@@ -462,32 +462,50 @@ if not get_option('tests').disabled()
)
endif
- if add_languages(['cpp'], native: false, required: get_option('tests_cpp'))
+ if not get_option('tests_cpp').disabled() and add_languages(
+ ['cpp'],
+ native: false,
+ required: get_option('tests_cpp').enabled(),
+ )
cpp = meson.get_compiler('cpp')
+ cpp_test_args = []
+ if cpp.get_id() == 'clang'
+ cpp_test_args = ['-Wall']
+ elif cpp.get_id() == 'gcc'
+ cpp_test_args = ['-Wall']
+ elif cpp.get_id() == 'msvc'
+ cpp_test_args = ['/W3']
+ endif
+
test(
'test_headers_cpp',
executable(
'test_headers_cpp',
files('test/cpp/test_headers_cpp.cpp'),
- cpp_args: program_c_args,
+ cpp_args: cpp_test_args + program_c_args,
dependencies: [zix_dep],
include_directories: include_dirs,
link_args: program_link_args,
),
)
- test(
- 'test_path_std',
- executable(
+ filesystem_code = '''#include <filesystem>
+int main(void) { return 0; }'''
+
+ if cpp.links(filesystem_code, name: 'filesystem')
+ test(
'test_path_std',
- files('test/cpp/test_path_std.cpp'),
- cpp_args: program_c_args,
- dependencies: [zix_dep],
- include_directories: include_dirs,
- link_args: program_link_args,
- ),
- )
+ executable(
+ 'test_path_std',
+ files('test/cpp/test_path_std.cpp'),
+ cpp_args: cpp_test_args + program_c_args,
+ dependencies: [zix_dep],
+ include_directories: include_dirs,
+ link_args: program_link_args,
+ ),
+ )
+ endif
endif
endif