diff --git a/.appveyor.yml b/.appveyor.yml index 816f16d..4362bda 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,7 +20,6 @@ build_script: test_script: - cd build - ctest --output-on-failure -C Debug - - tests\OptionalTest notifications: - provider: Webhook diff --git a/.ci/make_and_test.sh b/.ci/make_and_test.sh index 9d76a03..2ba81ae 100755 --- a/.ci/make_and_test.sh +++ b/.ci/make_and_test.sh @@ -15,7 +15,6 @@ echo "Testing..." set -evx ctest --output-on-failure -./tests/OptionalTest set +evx echo -en "travis_fold:end:script.test\\r" diff --git a/include/CLI/Optional.hpp b/include/CLI/Optional.hpp index d0a5b4a..160f264 100644 --- a/include/CLI/Optional.hpp +++ b/include/CLI/Optional.hpp @@ -60,10 +60,10 @@ template std::istream &operator>>(std::istream &in, boost::optional // Export the best optional to the CLI namespace #if defined(CLI11_STD_OPTIONAL) using std::optional; -#elif CLI11_EXPERIMENTAL_OPTIONAL +#elif defined(CLI11_EXPERIMENTAL_OPTIONAL) using std::experimental::optional; -#elif CLI11_BOOST_OPTIONAL -using boost::optionall +#elif defined(CLI11_BOOST_OPTIONAL) +using boost::optional; #endif // This is true if any optional is found diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dcac95f..36acc9a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,3 +53,13 @@ set_target_properties(link_test_1 PROPERTIES FOLDER "Tests") add_executable(link_test_2 link_test_2.cpp) target_link_libraries(link_test_2 PUBLIC CLI11 link_test_1) add_gtest(link_test_2) + +# Add informational printout +add_executable(informational informational.cpp) +target_link_libraries(informational PUBLIC CLI11) +set_property(TARGET informational PROPERTY + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +file(WRITE "${PROJECT_BINARY_DIR}/CTestCustom.cmake" + "set(CTEST_CUSTOM_PRE_TEST \"${CMAKE_BINARY_DIR}/informational\")" + ) diff --git a/tests/OptionalTest.cpp b/tests/OptionalTest.cpp index cbe036a..d6767a4 100644 --- a/tests/OptionalTest.cpp +++ b/tests/OptionalTest.cpp @@ -3,7 +3,7 @@ #include "app_helper.hpp" -#if CLI11_OPTIONAL +#ifdef CLI11_OPTIONAL TEST_F(TApp, OptionalTest) { optional opt; diff --git a/tests/informational.cpp b/tests/informational.cpp new file mode 100644 index 0000000..ef9448a --- /dev/null +++ b/tests/informational.cpp @@ -0,0 +1,43 @@ +#ifdef CLI11_SINGLE_FILE +#include "CLI11.hpp" +#else +#include "CLI/CLI.hpp" +#endif + +#include + +int main() { + std::cout << "\nCLI11 information:\n"; + + std::cout << " C++ standard: "; +#if defined(CLI11_CPP20) + std::cout << 20; +#elif defined(CLI11_CPP17) + std::cout << 17; +#elif defined(CLI11_CPP14) + std::cout << 14; +#else + std::cout << 11; +#endif + std::cout << "\n"; + +#ifdef CLI11_OPTIONAL + std::cout << " [Available as CLI::optional]"; +#else + std::cout << " No optional library found\n"; +#endif + +#ifdef CLI11_STD_OPTIONAL + std::cout << " std::optional support active\n"; +#endif + +#ifdef CLI11_EXPERIMENTAL_OPTIONAL + std::cout << " std::experimental::optional support active\n"; +#endif + +#ifdef CLI11_BOOST_OPTIONAL + std::cout << " boost::optional support active\n"; +#endif + + std::cout << std::endl; +}