From a04284fc2c650f52e0d09cbc6c6d688fbf64cca9 Mon Sep 17 00:00:00 2001 From: Jarryd Beck Date: Wed, 30 Nov 2016 18:03:28 +1100 Subject: [PATCH] fix Unicode build --- src/CMakeLists.txt | 2 ++ src/cxxopts.hpp | 15 ++++++++++++++- test/CMakeLists.txt | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfd768d..fd21e5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,8 @@ if(CXXOPTS_BUILD_EXAMPLES) add_executable(example example.cpp cxxopts.hpp) + target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES}) + if (MSVC) target_compile_options(example PUBLIC /W2) elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/src/cxxopts.hpp b/src/cxxopts.hpp index 8c92613..c33c06a 100644 --- a/src/cxxopts.hpp +++ b/src/cxxopts.hpp @@ -156,6 +156,13 @@ namespace cxxopts return result; } + + inline + bool + empty(const String& s) + { + return s.isEmpty(); + } } namespace std @@ -222,6 +229,12 @@ namespace cxxopts return std::forward(t); } + inline + bool + empty(const std::string& s) + { + return s.empty(); + } } //ifdef CXXOPTS_USE_UNICODE @@ -1364,7 +1377,7 @@ Options::help(const std::vector& groups) const for (std::size_t i = 0; i < groups.size(); ++i) { String const& group_help = help_one_group(groups[i]); - if (group_help.empty()) continue; + if (empty(group_help)) continue; result += group_help; if (i < groups.size() - 1) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 686e1f6..4378e2a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,8 @@ if (CXXOPTS_BUILD_TESTS) add_executable(options_test options.cpp) + target_link_libraries(options_test ${CXXOPTS_LINKER_LIBRARIES}) + if (MSVC) target_compile_options(options_test PUBLIC /W2) elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") -- libgit2 0.21.4