added meson option use_vendored_libs

This commit is contained in:
Mark Gillard
2022-05-01 15:09:09 +03:00
parent e47ef8cfb2
commit 27816dbbd1
8 changed files with 49 additions and 14 deletions

View File

@@ -21,7 +21,7 @@ If you wish to submit a PR, please be aware that:
<br>
## Building and running the tests
Testing is done using [Catch2], vendored in the respository at `vendor/catch.hpp`.
Testing is done using [Catch2].
### Testing on Windows with Visual Studio
@@ -60,9 +60,12 @@ cd build-gcc-debug && ninja && ninja test \
&& cd ..
```
> &#xFE0F; Note: To ensure parity between single-header and regular versions of the library, 50% of the tests
> &#xFE0F; To ensure parity between single-header and regular versions of the library, 50% of the tests
will be compiled using one, and 50% with the other. Ensure you've regenerated toml.hpp before running tests.
> &#xFE0F; Pass `-Duse_vendored_libs=false` to meson if you wish to use the system-installed version
of Catch2 rather than the vendored one.
<br>
## Testing with the [toml-test] suite

View File

@@ -10,3 +10,4 @@ option('ubsan_tests', type: 'boolean', value: false)
option('build_tt_encoder', type: 'boolean', value: false, description: 'Enable to build the toml-test encoder.')
option('build_tt_decoder', type: 'boolean', value: false, description: 'Enable to build the toml-test decoder.')
option('compile_library', type: 'boolean', value: false, description: 'Compile as a library')
option('use_vendored_libs', type: 'boolean', value: true, description: 'Use the libs from the vendor dir when building tests.')

View File

@@ -22,7 +22,15 @@
#pragma warning(disable : 5105)
#endif
#if !defined(USE_VENDORED_LIBS) || USE_VENDORED_LIBS
#include "../vendor/catch.hpp"
#elif __has_include(<Catch2/single_include/catch2/catch.hpp>)
#include <Catch2/single_include/catch2/catch.hpp>
#elif __has_include(<catch2/catch.hpp>)
#include <catch2/catch.hpp>
#else
#error Catch2 is missing!
#endif
#ifdef __clang__
#pragma clang diagnostic pop

View File

@@ -29,9 +29,10 @@ test_sources = [
'windows_compat.cpp'
]
test_deps = [tomlplusplus_dep]
fs = import('fs')
test_deps = [ tomlplusplus_dep ]
if not get_option('use_vendored_libs')
test_deps += dependency('catch2')
endif
#######################################################################################################################
# fast math check
@@ -210,6 +211,10 @@ foreach cpp20 : cpp20_modes
test_args += '-DUSE_SINGLE_HEADER=1'
endif
if not get_option('use_vendored_libs')
test_args += '-DUSE_VENDORED_LIBS=0'
endif
test_executables += [[
test_name,
executable(

View File

@@ -38,6 +38,9 @@ cd build_tt
ninja && toml-test ./toml-test/tt_decoder && toml-test ./toml-test/tt_encoder --encoder
```
> &#xFE0F; Pass `-Duse_vendored_libs=false` to meson if you wish to use the system-installed version
of nlohmann/json rather than the vendored one.
[toml-test]: https://github.com/BurntSushi/toml-test

View File

@@ -1,12 +1,19 @@
tt_deps = [
tomlplusplus_dep
]
tt_deps = [ tomlplusplus_dep ]
if not get_option('use_vendored_libs')
tt_deps += dependency('nlohmann_json', fallback: ['json', 'nlohmann_json_dep'])
endif
tt_args = []
tt_args += devel_args
if not get_option('use_vendored_libs')
tt_args += '-DUSE_VENDORED_LIBS=0'
endif
if get_option('build_tt_encoder')
executable(
'tt_encoder',
'tt_encoder.cpp',
cpp_args: devel_args,
cpp_args: tt_args,
dependencies: tt_deps
)
endif
@@ -15,7 +22,7 @@ if get_option('build_tt_decoder')
executable(
'tt_decoder',
'tt_decoder.cpp',
cpp_args: devel_args,
cpp_args: tt_args,
dependencies: tt_deps
)
endif

View File

@@ -15,8 +15,17 @@
#pragma warning(push, 0)
#endif
#define JSON_HAS_FILESYSTEM 0
#define JSON_HAS_FILESYSTEM 0
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
#if !defined(USE_VENDORED_LIBS) || USE_VENDORED_LIBS
#include "../vendor/json.hpp"
#elif __has_include(<json/single_include/nlohmann/json.hpp>)
#include <json/single_include/nlohmann/json.hpp>
#elif __has_include(<nlohmann/json.hpp>)
#include <nlohmann/json.hpp>
#else
#error nlohmann/json is missing!
#endif
#include <string>
#include <string_view>

5
vendor/README.md vendored
View File

@@ -2,7 +2,6 @@
The code files in this directory are third-party 'vendor' dependencies used by the various test applications.
⚠&#xFE0F; They are **not** required for regular use of toml++. ⚠&#xFE0F;
⚠&#xFE0F; They are not **not** `#included` anywhere in toml++. ⚠&#xFE0F;
⚠&#xFE0F; They are **not** required for regular use of toml++.
⚠&#xFE0F; They are **not** `#included` anywhere in toml++.