From 4b3a6b6214952f2d266959e79c285231f56eae74 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 9 Jan 2020 13:48:19 -0500 Subject: [PATCH] Add std checking and try to fix filesystem being used on macOS 10.14 (#397) --- azure-pipelines.yml | 23 +++++++++++------------ include/CLI/Validators.hpp | 14 +++++++++++--- tests/OptionalTest.cpp | 11 +++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3d68064..bd4e426 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,27 +35,26 @@ jobs: - job: Native strategy: matrix: - Linux: + Linux14: vmImage: 'ubuntu-latest' - macOS: + macOS17: vmImage: 'macOS-latest' - Windows: + cli11.std: 17 + macOS11: + vmImage: 'macOS-latest' + cli11.std: 11 + Windows17: vmImage: 'vs2017-win2016' + cli11.std: 17 + Windows11: + vmImage: 'vs2017-win2016' + cli11.std: 11 pool: vmImage: $(vmImage) steps: - template: .ci/azure-build.yml - template: .ci/azure-test.yml -- job: Clang11 - pool: - vmImage: 'macOS-latest' - variables: - cli11.std: 11 - steps: - - template: .ci/azure-build.yml - - template: .ci/azure-test.yml - - job: Meson pool: vmImage: 'ubuntu-latest' diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index d51d6b3..90dfed6 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -2,6 +2,7 @@ // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. +#include "CLI/Macros.hpp" #include "CLI/StringTools.hpp" #include "CLI/TypeTools.hpp" @@ -14,15 +15,22 @@ #include // [CLI11:verbatim] -#if(defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) -#define CLI11_CPP17 -#endif // C standard library // Only needed for existence checking #if defined CLI11_CPP17 && defined __has_include && !defined CLI11_HAS_FILESYSTEM #if __has_include() +// Filesystem cannot be used if targeting macOS < 10.15 +#if defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 +#define CLI11_HAS_FILESYSTEM 0 +#else +#include +#if defined __cpp_lib_filesystem && __cpp_lib_filesystem >= 201703 #define CLI11_HAS_FILESYSTEM 1 +#else +#define CLI11_HAS_FILESYSTEM 0 +#endif +#endif #endif #endif diff --git a/tests/OptionalTest.cpp b/tests/OptionalTest.cpp index 048b5c3..5acfdf6 100644 --- a/tests/OptionalTest.cpp +++ b/tests/OptionalTest.cpp @@ -47,6 +47,13 @@ #if CLI11_STD_OPTIONAL +#ifdef _MSC_VER +// this warning suppresses double to int conversions that are inherent in the test +// on windows. This may be able to removed in the future as the add_option capability +// improves +#pragma warning(disable : 4244) +#endif + TEST_F(TApp, StdOptionalTest) { std::optional opt; app.add_option("-c,--count", opt); @@ -64,6 +71,10 @@ TEST_F(TApp, StdOptionalTest) { EXPECT_EQ(*opt, 3); } +#ifdef _MSC_VER +#pragma warning(default : 4244) +#endif + #endif #if CLI11_EXPERIMENTAL_OPTIONAL -- libgit2 0.21.4