1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-01 05:03:52 +00:00

Boost optional is no longer automatic (#279)

* Boost optional is no longer automatic

* Tighten up optional a bit

* Check times
This commit is contained in:
Henry Schreiner 2019-05-16 23:34:29 +02:00 committed by GitHub
parent 10e4b0784b
commit b6e3fb126a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 25 deletions

View File

@ -5,7 +5,7 @@ steps:
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)
displayName: 'Configure'
- script: cmake --build . $(cli11.threadopt)
- script: cmake --build .
displayName: 'Build'
workingDirectory: build

View File

@ -11,6 +11,9 @@ else()
cmake_policy(VERSION 3.14)
endif()
# TESTING: remove this later
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
# Read in the line containing the version

View File

@ -11,7 +11,7 @@ variables:
cli11.std: 14
cli11.build_type: Debug
cli11.options:
cli11.threadopt: -j
CMAKE_BUILD_PARALLEL_LEVEL: 4
jobs:
@ -21,7 +21,7 @@ jobs:
cli11.options: -DCLANG_TIDY_FIX=ON
cli11.std: 11
cli11.single: OFF
cli11.threadopt:
CMAKE_BUILD_PARALLEL_LEVEL: 1
pool:
vmImage: 'ubuntu-16.04'
container: silkeh/clang:5
@ -37,9 +37,9 @@ jobs:
strategy:
matrix:
Linux:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-latest'
macOS:
vmImage: 'macOS-10.14'
vmImage: 'macOS-latest'
Windows:
vmImage: 'vs2017-win2016'
pool:
@ -52,7 +52,7 @@ jobs:
variables:
cli11.single: OFF
pool:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-latest'
strategy:
matrix:
gcc9:

View File

@ -8,30 +8,35 @@
#include "CLI/Macros.hpp"
// [CLI11:verbatim]
#ifdef __has_include
// You can explicitly enable or disable support
// by defining these to 1 or 0.
#if defined(CLI11_CPP17) && __has_include(<optional>) && \
!defined(CLI11_STD_OPTIONAL)
// by defining to 1 or 0. Extra check here to ensure it's in the stdlib too.
// We nest the check for __has_include and it's usage
#ifndef CLI11_STD_OPTIONAL
#ifdef __has_include
#if defined(CLI11_CPP17) && __has_include(<optional>)
#define CLI11_STD_OPTIONAL 1
#elif !defined(CLI11_STD_OPTIONAL)
#else
#define CLI11_STD_OPTIONAL 0
#endif
#else
#define CLI11_STD_OPTIONAL 0
#endif
#endif
#if !defined(CLI11_EXPERIMENTAL_OPTIONAL)
#ifndef CLI11_EXPERIMENTAL_OPTIONAL
#define CLI11_EXPERIMENTAL_OPTIONAL 0
#endif
#if __has_include(<boost/optional.hpp>) && !defined(CLI11_BOOST_OPTIONAL)
#include <boost/version.hpp>
#if BOOST_VERSION >= 106100
#define CLI11_BOOST_OPTIONAL 1
#endif
#elif !defined(CLI11_BOOST_OPTIONAL)
#ifndef CLI11_BOOST_OPTIONAL
#define CLI11_BOOST_OPTIONAL 0
#endif
#if CLI11_BOOST_OPTIONAL
#include <boost/version.hpp>
#if BOOST_VERSION < 106100
#error "This boost::optional version is not supported, use 1.61 or better"
#endif
#endif
#if CLI11_STD_OPTIONAL

View File

@ -115,15 +115,15 @@ file(WRITE "${PROJECT_BINARY_DIR}/CTestCustom.cmake"
find_package(Boost 1.61)
if(Boost_FOUND)
if(TARGET Boost::boost)
target_link_libraries(informational PUBLIC Boost::boost)
target_link_libraries(OptionalTest PUBLIC Boost::boost)
target_link_libraries(informational PRIVATE Boost::boost)
target_link_libraries(OptionalTest PRIVATE Boost::boost)
else()
target_include_directories(informational PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories(OptionalTest PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories(informational PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(OptionalTest PRIVATE ${Boost_INCLUDE_DIRS})
endif()
# Enforce Boost::Optional even if __has_include is missing on your compiler
target_compile_definitions(informational PUBLIC CLI11_BOOST_OPTIONAL)
target_compile_definitions(OptionalTest PUBLIC CLI11_BOOST_OPTIONAL)
target_compile_definitions(informational PRIVATE CLI11_BOOST_OPTIONAL)
target_compile_definitions(OptionalTest PRIVATE CLI11_BOOST_OPTIONAL)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Coverage)