|
8 | 8 | #include "CLI/Macros.hpp" |
9 | 9 |
|
10 | 10 | // [CLI11:verbatim] |
11 | | -#ifdef __has_include |
12 | 11 |
|
13 | 12 | // You can explicitly enable or disable support |
14 | | -// by defining these to 1 or 0. |
15 | | -#if defined(CLI11_CPP17) && __has_include(<optional>) && \ |
16 | | - !defined(CLI11_STD_OPTIONAL) |
| 13 | +// by defining to 1 or 0. Extra check here to ensure it's in the stdlib too. |
| 14 | +// We nest the check for __has_include and it's usage |
| 15 | +#ifndef CLI11_STD_OPTIONAL |
| 16 | +#ifdef __has_include |
| 17 | +#if defined(CLI11_CPP17) && __has_include(<optional>) |
17 | 18 | #define CLI11_STD_OPTIONAL 1 |
18 | | -#elif !defined(CLI11_STD_OPTIONAL) |
| 19 | +#else |
19 | 20 | #define CLI11_STD_OPTIONAL 0 |
20 | 21 | #endif |
| 22 | +#else |
| 23 | +#define CLI11_STD_OPTIONAL 0 |
| 24 | +#endif |
| 25 | +#endif |
21 | 26 |
|
22 | | -#if !defined(CLI11_EXPERIMENTAL_OPTIONAL) |
| 27 | +#ifndef CLI11_EXPERIMENTAL_OPTIONAL |
23 | 28 | #define CLI11_EXPERIMENTAL_OPTIONAL 0 |
24 | 29 | #endif |
25 | 30 |
|
26 | | -#if __has_include(<boost/optional.hpp>) && !defined(CLI11_BOOST_OPTIONAL) |
27 | | -#include <boost/version.hpp> |
28 | | -#if BOOST_VERSION >= 106100 |
29 | | -#define CLI11_BOOST_OPTIONAL 1 |
30 | | -#endif |
31 | | -#elif !defined(CLI11_BOOST_OPTIONAL) |
| 31 | +#ifndef CLI11_BOOST_OPTIONAL |
32 | 32 | #define CLI11_BOOST_OPTIONAL 0 |
33 | 33 | #endif |
34 | 34 |
|
| 35 | +#if CLI11_BOOST_OPTIONAL |
| 36 | +#include <boost/version.hpp> |
| 37 | +#if BOOST_VERSION < 106100 |
| 38 | +#error "This boost::optional version is not supported, use 1.61 or better" |
| 39 | +#endif |
35 | 40 | #endif |
36 | 41 |
|
37 | 42 | #if CLI11_STD_OPTIONAL |
|
0 commit comments