Fix warnings and small issues (#1178)

try some things with no standard libraries
Add arm64 and freebsd build and tests
fix a discrepancy in the handling of chars on Arm processors

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2025-07-18 07:18:26 -07:00
committed by GitHub
parent 587129a170
commit c5153634db
10 changed files with 117 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
if(CLI11_SANITIZERS AND ${CMAKE_VERSION} VERSION_GREATER "3.13.0")
if(CLI11_SANITIZERS AND ${CMAKE_VERSION} VERSION_GREATER "3.15.0")
message(STATUS "Using arsenm/sanitizers-cmake")
FetchContent_Declare(
sanitizers
@@ -6,11 +6,7 @@ if(CLI11_SANITIZERS AND ${CMAKE_VERSION} VERSION_GREATER "3.13.0")
GIT_SHALLOW 1
GIT_TAG 0573e2e)
FetchContent_GetProperties(sanitizers)
if(NOT sanitizers_POPULATED)
FetchContent_Populate(sanitizers)
endif()
FetchContent_MakeAvailable(sanitizers)
list(APPEND CMAKE_MODULE_PATH "${sanitizers_SOURCE_DIR}/cmake")
@@ -119,6 +115,7 @@ foreach(DATA_FILE IN LISTS DATA_FILES)
VERBATIM)
endforeach()
add_custom_target(cli11_test_data DEPENDS ${DATA_FILES})
set_target_properties(cli11_test_data PROPERTIES FOLDER "Tests/Apps")
# Make a shim if we are building single file tests
if(CLI11_SINGLE_FILE AND CLI11_INSTALL_PACKAGE_TESTS)
@@ -132,6 +129,7 @@ set(CLI11_DEPENDENT_APPLICATIONS ensure_utf8 ensure_utf8_twice)
foreach(APP IN LISTS CLI11_DEPENDENT_APPLICATIONS)
add_executable(${APP} applications/${APP}.cpp)
target_include_directories(${APP} PRIVATE ${CMAKE_SOURCE_DIR}/include)
set_target_properties(${APP} PROPERTIES FOLDER "Tests/Apps")
endforeach()
function(add_dependent_application_definitions TARGET)
@@ -139,6 +137,10 @@ function(add_dependent_application_definitions TARGET)
string(TOUPPER ${APP} APP_UPPERCASE)
target_compile_definitions(${TARGET}
PRIVATE CLI11_${APP_UPPERCASE}_EXE="$<TARGET_FILE:${APP}>")
if(WIN32)
target_link_libraries(${APP} PRIVATE Shell32)
endif()
endforeach()
endfunction()
@@ -246,6 +248,7 @@ if(CLI11_FORCE_LIBCXX)
PROPERTY LINK_FLAGS -stdlib=libc++)
endif()
set_target_properties(informational PROPERTIES FOLDER "Tests/Apps")
# Force this to be in a standard location so CTest can find it
set_target_properties(
informational

View File

@@ -274,7 +274,7 @@ TEST_CASE("StringTools: binaryEscapeConversion", "[helpers]") {
testString2.push_back(0);
testString2.push_back(static_cast<char>(197));
testString2.push_back(78);
testString2.push_back(-34);
testString2.push_back(static_cast<char>(-34));
rstring = CLI::detail::extract_binary_string(CLI::detail::binary_escape_string(testString2));
CHECK(rstring == testString2);
@@ -294,8 +294,8 @@ TEST_CASE("StringTools: binaryEscapeConversion2", "[helpers]") {
testString.push_back(0);
testString.push_back(0);
testString.push_back(56);
testString.push_back(-112);
testString.push_back(-112);
testString.push_back(static_cast<char>(-112));
testString.push_back(static_cast<char>(-112));
testString.push_back(39);
testString.push_back(97);
std::string estring = CLI::detail::binary_escape_string(testString);
@@ -310,8 +310,8 @@ TEST_CASE("StringTools: binaryEscapeConversion_withX", "[helpers]") {
testString.push_back(0);
testString.push_back(0);
testString.push_back(56);
testString.push_back(-112);
testString.push_back(-112);
testString.push_back(static_cast<char>(-112));
testString.push_back(static_cast<char>(-112));
testString.push_back(39);
testString.push_back(97);
std::string estring = CLI::detail::binary_escape_string(testString);
@@ -324,12 +324,12 @@ TEST_CASE("StringTools: binaryEscapeConversion_withBrackets", "[helpers]") {
std::string vstr = R"raw('B"([\xb0\x0a\xb0/\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0\xb0])"')raw";
std::string testString("[");
testString.push_back(-80);
testString.push_back(static_cast<char>(-80));
testString.push_back('\n');
testString.push_back(-80);
testString.push_back(static_cast<char>(-80));
testString.push_back('/');
for(int ii = 0; ii < 13; ++ii) {
testString.push_back(-80);
testString.push_back(static_cast<char>(-80));
}
testString.push_back(']');

View File

@@ -112,8 +112,8 @@ CLI11_INLINE void check_identical_files(const char *path1, const char *path2) {
file1.seekg(0);
file2.seekg(0);
std::array<uint8_t, 10240> buffer1;
std::array<uint8_t, 10240> buffer2;
static std::array<uint8_t, 10240> buffer1;
static std::array<uint8_t, 10240> buffer2;
for(size_t ibuffer = 0; file1.good(); ++ibuffer) {
// Flawfinder: ignore