diff --git a/examples/help_usage.cpp b/examples/help_usage.cpp index f7e3d8bbc..681f994aa 100644 --- a/examples/help_usage.cpp +++ b/examples/help_usage.cpp @@ -7,13 +7,14 @@ #include #include -int main(int argc, char **argv) { +int main(int argc, char *argv[]) { std::string input_file_name, output_file_name; int level{5}, subopt{0}; // app caption CLI::App app{"CLI11 help"}; - + // this tests out some of the wide character support, mainly for compilation checking + argv = app.ensure_utf8(argv); app.require_subcommand(1); // subcommands options and flags CLI::App *const encode = app.add_subcommand("e", "encode")->ignore_case(); // ignore case diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad0288567..b85585e83 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,10 @@ if(CMAKE_CXX_STANDARD LESS 14) target_compile_features(CLI11 INTERFACE cxx_std_11) endif() +if(WIN32) + target_link_libraries(CLI11 ${PUBLIC_OR_INTERFACE} Shell32) +endif() + if(CLI11_INSTALL OR CLI11_FULL_INSTALL) # Make an export target diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 632c6b207..595811f45 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,7 +29,13 @@ endif() # Add boost to test boost::optional (currently explicitly requested)" option(CLI11_BOOST "Turn on boost test (currently may fail with Boost 1.70)" OFF) if(CLI11_BOOST) - find_package(Boost 1.61 REQUIRED) + find_package(Boost 1.61 QUIET CONFIG) + if(NOT Boost_FOUND) + find_package(Boost 1.61 QUIET) + endif() + if(NOT Boost_FOUND) + message(FATAL_ERROR "Boost 1.61+ requested via CLI11_BOOST, but not found.") + endif() endif() set(boost-optional-def $<$:CLI11_BOOST_OPTIONAL>) @@ -71,7 +77,7 @@ endif() set(CLI11_MULTIONLY_TESTS TimerTest) -find_package(Catch2 CONFIG) +find_package(Catch2 CONFIG QUIET) if(Catch2_FOUND) if(NOT TARGET Catch2::Catch2) @@ -88,18 +94,29 @@ if(Catch2_FOUND) target_compile_definitions(Catch2::Catch2WithMain INTERFACE -DCLI11_CATCH3) endif() else() - message(STATUS "Downloading Catch2") - - # FetchContent would be better, but requires newer CMake. - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch2") - set(url https://github.com/philsquared/Catch/releases/download/v2.13.10/catch.hpp) - file( - DOWNLOAD ${url} "${CMAKE_CURRENT_BINARY_DIR}/catch2/catch.hpp" - STATUS status - EXPECTED_HASH SHA256=3725c0f0a75f376a5005dde31ead0feb8f7da7507644c201b814443de8355170) - list(GET status 0 error) - if(error) - message(FATAL_ERROR "Could not download ${url}, and Catch2 not found on your system.") + set(catch2_url https://github.com/philsquared/Catch/releases/download/v2.13.10/catch.hpp) + set(catch2_header "${CMAKE_CURRENT_BINARY_DIR}/catch2/catch.hpp") + set(catch2_hash "3725c0f0a75f376a5005dde31ead0feb8f7da7507644c201b814443de8355170") + + if(EXISTS "${catch2_header}") + file(SHA256 "${catch2_header}" catch2_cached_hash) + endif() + + if(EXISTS "${catch2_header}" AND catch2_cached_hash STREQUAL catch2_hash) + message(STATUS "Using cached Catch2 header") + else() + message(STATUS "Catch2 not found; downloading Catch2") + + # FetchContent would be better, but requires newer CMake. + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch2") + file( + DOWNLOAD ${catch2_url} "${catch2_header}" + STATUS status + EXPECTED_HASH SHA256=${catch2_hash}) + list(GET status 0 error) + if(error) + message(FATAL_ERROR "Could not download ${catch2_url}, and Catch2 not found on your system.") + endif() endif() add_library(catch_main main.cpp catch.hpp) target_include_directories(catch_main PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" @@ -275,18 +292,24 @@ file(WRITE "${PROJECT_BINARY_DIR}/CTestCustom.cmake" target_compile_definitions(informational PRIVATE ${boost-optional-def}) target_compile_definitions(OptionalTest PRIVATE ${boost-optional-def}) -if(TARGET Boost::boost) - message(STATUS "including boost target") - target_link_libraries(informational PRIVATE Boost::boost) - target_link_libraries(OptionalTest PRIVATE Boost::boost) - target_link_libraries(BoostOptionTypeTest PRIVATE Boost::boost) +if(TARGET Boost::headers) + set(cli11_boost_target Boost::headers) +elseif(TARGET Boost::boost) + set(cli11_boost_target Boost::boost) +endif() + +if(DEFINED cli11_boost_target) + message(STATUS "Using Boost target ${cli11_boost_target}") + target_link_libraries(informational PRIVATE ${cli11_boost_target}) + target_link_libraries(OptionalTest PRIVATE ${cli11_boost_target}) + target_link_libraries(BoostOptionTypeTest PRIVATE ${cli11_boost_target}) if(CLI11_SINGLE_FILE AND CLI11_SINGLE_FILE_TESTS) - target_link_libraries(OptionalTest_Single PRIVATE Boost::boost) - target_link_libraries(BoostOptionTypeTest_Single PRIVATE Boost::boost) + target_link_libraries(OptionalTest_Single PRIVATE ${cli11_boost_target}) + target_link_libraries(BoostOptionTypeTest_Single PRIVATE ${cli11_boost_target}) endif() - message(STATUS "Boost libs=${Boost_INCLUDE_DIRS}") -elseif(BOOST_FOUND) - message(STATUS "no boost target") + message(STATUS "Boost includes=${Boost_INCLUDE_DIRS}") +elseif(Boost_FOUND) + message(STATUS "Using Boost include directories") target_include_directories(informational PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(OptionalTest PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(BoostOptionTypeTest PRIVATE ${Boost_INCLUDE_DIRS}) @@ -294,8 +317,8 @@ elseif(BOOST_FOUND) target_include_directories(OptionalTest_Single PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(BoostOptionTypeTest_Single PRIVATE ${Boost_INCLUDE_DIRS}) endif() - message(STATUS "Boost libs=${Boost_INCLUDE_DIRS}") -else() + message(STATUS "Boost includes=${Boost_INCLUDE_DIRS}") +elseif(CLI11_BOOST) message(STATUS "Boost not found, not adding boost tests") endif()