Commit b6e3fb126a5abddc11e7afbf9611d1eb6a3711d4
Committed by
GitHub
1 parent
10e4b078
Boost optional is no longer automatic (#279)
* Boost optional is no longer automatic * Tighten up optional a bit * Check times
Showing
5 changed files
with
33 additions
and
25 deletions
.ci/azure-build.yml
| ... | ... | @@ -5,7 +5,7 @@ steps: |
| 5 | 5 | cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options) |
| 6 | 6 | displayName: 'Configure' |
| 7 | 7 | |
| 8 | -- script: cmake --build . $(cli11.threadopt) | |
| 8 | +- script: cmake --build . | |
| 9 | 9 | displayName: 'Build' |
| 10 | 10 | workingDirectory: build |
| 11 | 11 | ... | ... |
CMakeLists.txt
| ... | ... | @@ -11,6 +11,9 @@ else() |
| 11 | 11 | cmake_policy(VERSION 3.14) |
| 12 | 12 | endif() |
| 13 | 13 | |
| 14 | +# TESTING: remove this later | |
| 15 | +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") | |
| 16 | + | |
| 14 | 17 | set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") |
| 15 | 18 | |
| 16 | 19 | # Read in the line containing the version | ... | ... |
azure-pipelines.yml
| ... | ... | @@ -11,7 +11,7 @@ variables: |
| 11 | 11 | cli11.std: 14 |
| 12 | 12 | cli11.build_type: Debug |
| 13 | 13 | cli11.options: |
| 14 | - cli11.threadopt: -j | |
| 14 | + CMAKE_BUILD_PARALLEL_LEVEL: 4 | |
| 15 | 15 | |
| 16 | 16 | jobs: |
| 17 | 17 | |
| ... | ... | @@ -21,7 +21,7 @@ jobs: |
| 21 | 21 | cli11.options: -DCLANG_TIDY_FIX=ON |
| 22 | 22 | cli11.std: 11 |
| 23 | 23 | cli11.single: OFF |
| 24 | - cli11.threadopt: | |
| 24 | + CMAKE_BUILD_PARALLEL_LEVEL: 1 | |
| 25 | 25 | pool: |
| 26 | 26 | vmImage: 'ubuntu-16.04' |
| 27 | 27 | container: silkeh/clang:5 |
| ... | ... | @@ -37,9 +37,9 @@ jobs: |
| 37 | 37 | strategy: |
| 38 | 38 | matrix: |
| 39 | 39 | Linux: |
| 40 | - vmImage: 'ubuntu-16.04' | |
| 40 | + vmImage: 'ubuntu-latest' | |
| 41 | 41 | macOS: |
| 42 | - vmImage: 'macOS-10.14' | |
| 42 | + vmImage: 'macOS-latest' | |
| 43 | 43 | Windows: |
| 44 | 44 | vmImage: 'vs2017-win2016' |
| 45 | 45 | pool: |
| ... | ... | @@ -52,7 +52,7 @@ jobs: |
| 52 | 52 | variables: |
| 53 | 53 | cli11.single: OFF |
| 54 | 54 | pool: |
| 55 | - vmImage: 'ubuntu-16.04' | |
| 55 | + vmImage: 'ubuntu-latest' | |
| 56 | 56 | strategy: |
| 57 | 57 | matrix: |
| 58 | 58 | gcc9: | ... | ... |
include/CLI/Optional.hpp
| ... | ... | @@ -8,30 +8,35 @@ |
| 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 | ... | ... |
tests/CMakeLists.txt
| ... | ... | @@ -115,15 +115,15 @@ file(WRITE "${PROJECT_BINARY_DIR}/CTestCustom.cmake" |
| 115 | 115 | find_package(Boost 1.61) |
| 116 | 116 | if(Boost_FOUND) |
| 117 | 117 | if(TARGET Boost::boost) |
| 118 | - target_link_libraries(informational PUBLIC Boost::boost) | |
| 119 | - target_link_libraries(OptionalTest PUBLIC Boost::boost) | |
| 118 | + target_link_libraries(informational PRIVATE Boost::boost) | |
| 119 | + target_link_libraries(OptionalTest PRIVATE Boost::boost) | |
| 120 | 120 | else() |
| 121 | - target_include_directories(informational PUBLIC ${Boost_INCLUDE_DIRS}) | |
| 122 | - target_include_directories(OptionalTest PUBLIC ${Boost_INCLUDE_DIRS}) | |
| 121 | + target_include_directories(informational PRIVATE ${Boost_INCLUDE_DIRS}) | |
| 122 | + target_include_directories(OptionalTest PRIVATE ${Boost_INCLUDE_DIRS}) | |
| 123 | 123 | endif() |
| 124 | - # Enforce Boost::Optional even if __has_include is missing on your compiler | |
| 125 | - target_compile_definitions(informational PUBLIC CLI11_BOOST_OPTIONAL) | |
| 126 | - target_compile_definitions(OptionalTest PUBLIC CLI11_BOOST_OPTIONAL) | |
| 124 | + | |
| 125 | + target_compile_definitions(informational PRIVATE CLI11_BOOST_OPTIONAL) | |
| 126 | + target_compile_definitions(OptionalTest PRIVATE CLI11_BOOST_OPTIONAL) | |
| 127 | 127 | endif() |
| 128 | 128 | |
| 129 | 129 | if(CMAKE_BUILD_TYPE STREQUAL Coverage) | ... | ... |