Commit 4b3a6b6214952f2d266959e79c285231f56eae74

Authored by Henry Schreiner
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>
azure-pipelines.yml
... ... @@ -35,27 +35,26 @@ jobs:
35 35 - job: Native
36 36 strategy:
37 37 matrix:
38   - Linux:
  38 + Linux14:
39 39 vmImage: 'ubuntu-latest'
40   - macOS:
  40 + macOS17:
41 41 vmImage: 'macOS-latest'
42   - Windows:
  42 + cli11.std: 17
  43 + macOS11:
  44 + vmImage: 'macOS-latest'
  45 + cli11.std: 11
  46 + Windows17:
43 47 vmImage: 'vs2017-win2016'
  48 + cli11.std: 17
  49 + Windows11:
  50 + vmImage: 'vs2017-win2016'
  51 + cli11.std: 11
44 52 pool:
45 53 vmImage: $(vmImage)
46 54 steps:
47 55 - template: .ci/azure-build.yml
48 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 58 - job: Meson
60 59 pool:
61 60 vmImage: 'ubuntu-latest'
... ...
include/CLI/Validators.hpp
... ... @@ -2,6 +2,7 @@
2 2 // Distributed under the 3-Clause BSD License. See accompanying
3 3 // file LICENSE or https://github.com/CLIUtils/CLI11 for details.
4 4  
  5 +#include "CLI/Macros.hpp"
5 6 #include "CLI/StringTools.hpp"
6 7 #include "CLI/TypeTools.hpp"
7 8  
... ... @@ -14,15 +15,22 @@
14 15 #include <string>
15 16  
16 17 // [CLI11:verbatim]
17   -#if(defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
18   -#define CLI11_CPP17
19   -#endif
20 18  
21 19 // C standard library
22 20 // Only needed for existence checking
23 21 #if defined CLI11_CPP17 && defined __has_include && !defined CLI11_HAS_FILESYSTEM
24 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 29 #define CLI11_HAS_FILESYSTEM 1
  30 +#else
  31 +#define CLI11_HAS_FILESYSTEM 0
  32 +#endif
  33 +#endif
26 34 #endif
27 35 #endif
28 36  
... ...
tests/OptionalTest.cpp
... ... @@ -47,6 +47,13 @@
47 47  
48 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 57 TEST_F(TApp, StdOptionalTest) {
51 58 std::optional<int> opt;
52 59 app.add_option("-c,--count", opt);
... ... @@ -64,6 +71,10 @@ TEST_F(TApp, StdOptionalTest) {
64 71 EXPECT_EQ(*opt, 3);
65 72 }
66 73  
  74 +#ifdef _MSC_VER
  75 +#pragma warning(default : 4244)
  76 +#endif
  77 +
67 78 #endif
68 79 #if CLI11_EXPERIMENTAL_OPTIONAL
69 80  
... ...