Commit 4b3a6b6214952f2d266959e79c285231f56eae74
Committed by
GitHub
1 parent
a609605d
Add std checking and try to fix filesystem being used on macOS 10.14 (#397)
* Add std checking and try to fix filesystem being used on macOS 10.14 * Adding extra check recommeded by @phlptp * suppress the double to int warning in msvc 2019 in the optional test Co-authored-by: Philip Top <top1@llnl.gov>
Showing
3 changed files
with
33 additions
and
15 deletions
azure-pipelines.yml
| @@ -35,27 +35,26 @@ jobs: | @@ -35,27 +35,26 @@ jobs: | ||
| 35 | - job: Native | 35 | - job: Native |
| 36 | strategy: | 36 | strategy: |
| 37 | matrix: | 37 | matrix: |
| 38 | - Linux: | 38 | + Linux14: |
| 39 | vmImage: 'ubuntu-latest' | 39 | vmImage: 'ubuntu-latest' |
| 40 | - macOS: | 40 | + macOS17: |
| 41 | vmImage: 'macOS-latest' | 41 | vmImage: 'macOS-latest' |
| 42 | - Windows: | 42 | + cli11.std: 17 |
| 43 | + macOS11: | ||
| 44 | + vmImage: 'macOS-latest' | ||
| 45 | + cli11.std: 11 | ||
| 46 | + Windows17: | ||
| 43 | vmImage: 'vs2017-win2016' | 47 | vmImage: 'vs2017-win2016' |
| 48 | + cli11.std: 17 | ||
| 49 | + Windows11: | ||
| 50 | + vmImage: 'vs2017-win2016' | ||
| 51 | + cli11.std: 11 | ||
| 44 | pool: | 52 | pool: |
| 45 | vmImage: $(vmImage) | 53 | vmImage: $(vmImage) |
| 46 | steps: | 54 | steps: |
| 47 | - template: .ci/azure-build.yml | 55 | - template: .ci/azure-build.yml |
| 48 | - template: .ci/azure-test.yml | 56 | - template: .ci/azure-test.yml |
| 49 | 57 | ||
| 50 | -- job: Clang11 | ||
| 51 | - pool: | ||
| 52 | - vmImage: 'macOS-latest' | ||
| 53 | - variables: | ||
| 54 | - cli11.std: 11 | ||
| 55 | - steps: | ||
| 56 | - - template: .ci/azure-build.yml | ||
| 57 | - - template: .ci/azure-test.yml | ||
| 58 | - | ||
| 59 | - job: Meson | 58 | - job: Meson |
| 60 | pool: | 59 | pool: |
| 61 | vmImage: 'ubuntu-latest' | 60 | vmImage: 'ubuntu-latest' |
include/CLI/Validators.hpp
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | // Distributed under the 3-Clause BSD License. See accompanying | 2 | // Distributed under the 3-Clause BSD License. See accompanying |
| 3 | // file LICENSE or https://github.com/CLIUtils/CLI11 for details. | 3 | // file LICENSE or https://github.com/CLIUtils/CLI11 for details. |
| 4 | 4 | ||
| 5 | +#include "CLI/Macros.hpp" | ||
| 5 | #include "CLI/StringTools.hpp" | 6 | #include "CLI/StringTools.hpp" |
| 6 | #include "CLI/TypeTools.hpp" | 7 | #include "CLI/TypeTools.hpp" |
| 7 | 8 | ||
| @@ -14,15 +15,22 @@ | @@ -14,15 +15,22 @@ | ||
| 14 | #include <string> | 15 | #include <string> |
| 15 | 16 | ||
| 16 | // [CLI11:verbatim] | 17 | // [CLI11:verbatim] |
| 17 | -#if(defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) | ||
| 18 | -#define CLI11_CPP17 | ||
| 19 | -#endif | ||
| 20 | 18 | ||
| 21 | // C standard library | 19 | // C standard library |
| 22 | // Only needed for existence checking | 20 | // Only needed for existence checking |
| 23 | #if defined CLI11_CPP17 && defined __has_include && !defined CLI11_HAS_FILESYSTEM | 21 | #if defined CLI11_CPP17 && defined __has_include && !defined CLI11_HAS_FILESYSTEM |
| 24 | #if __has_include(<filesystem>) | 22 | #if __has_include(<filesystem>) |
| 23 | +// Filesystem cannot be used if targeting macOS < 10.15 | ||
| 24 | +#if defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 | ||
| 25 | +#define CLI11_HAS_FILESYSTEM 0 | ||
| 26 | +#else | ||
| 27 | +#include <filesystem> | ||
| 28 | +#if defined __cpp_lib_filesystem && __cpp_lib_filesystem >= 201703 | ||
| 25 | #define CLI11_HAS_FILESYSTEM 1 | 29 | #define CLI11_HAS_FILESYSTEM 1 |
| 30 | +#else | ||
| 31 | +#define CLI11_HAS_FILESYSTEM 0 | ||
| 32 | +#endif | ||
| 33 | +#endif | ||
| 26 | #endif | 34 | #endif |
| 27 | #endif | 35 | #endif |
| 28 | 36 |
tests/OptionalTest.cpp
| @@ -47,6 +47,13 @@ | @@ -47,6 +47,13 @@ | ||
| 47 | 47 | ||
| 48 | #if CLI11_STD_OPTIONAL | 48 | #if CLI11_STD_OPTIONAL |
| 49 | 49 | ||
| 50 | +#ifdef _MSC_VER | ||
| 51 | +// this warning suppresses double to int conversions that are inherent in the test | ||
| 52 | +// on windows. This may be able to removed in the future as the add_option capability | ||
| 53 | +// improves | ||
| 54 | +#pragma warning(disable : 4244) | ||
| 55 | +#endif | ||
| 56 | + | ||
| 50 | TEST_F(TApp, StdOptionalTest) { | 57 | TEST_F(TApp, StdOptionalTest) { |
| 51 | std::optional<int> opt; | 58 | std::optional<int> opt; |
| 52 | app.add_option("-c,--count", opt); | 59 | app.add_option("-c,--count", opt); |
| @@ -64,6 +71,10 @@ TEST_F(TApp, StdOptionalTest) { | @@ -64,6 +71,10 @@ TEST_F(TApp, StdOptionalTest) { | ||
| 64 | EXPECT_EQ(*opt, 3); | 71 | EXPECT_EQ(*opt, 3); |
| 65 | } | 72 | } |
| 66 | 73 | ||
| 74 | +#ifdef _MSC_VER | ||
| 75 | +#pragma warning(default : 4244) | ||
| 76 | +#endif | ||
| 77 | + | ||
| 67 | #endif | 78 | #endif |
| 68 | #if CLI11_EXPERIMENTAL_OPTIONAL | 79 | #if CLI11_EXPERIMENTAL_OPTIONAL |
| 69 | 80 |