diff --git a/.ci/azure-build.yml b/.ci/azure-build.yml index e6b37f8e..b7cb5bb5 100644 --- a/.ci/azure-build.yml +++ b/.ci/azure-build.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b950705..020d7cf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0c2f5baf..45840db3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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: diff --git a/include/CLI/Optional.hpp b/include/CLI/Optional.hpp index 6e60fb60..510af3b3 100644 --- a/include/CLI/Optional.hpp +++ b/include/CLI/Optional.hpp @@ -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() && \ - !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() #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() && !defined(CLI11_BOOST_OPTIONAL) -#include -#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 +#if BOOST_VERSION < 106100 +#error "This boost::optional version is not supported, use 1.61 or better" +#endif #endif #if CLI11_STD_OPTIONAL diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ec1f931a..460a315e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)