fix Unicode build

This commit is contained in:
Jarryd Beck 2016-11-30 18:03:28 +11:00
parent d92988c6a2
commit a04284fc2c
3 changed files with 18 additions and 1 deletions

View File

@ -21,6 +21,8 @@
if(CXXOPTS_BUILD_EXAMPLES) if(CXXOPTS_BUILD_EXAMPLES)
add_executable(example example.cpp cxxopts.hpp) add_executable(example example.cpp cxxopts.hpp)
target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES})
if (MSVC) if (MSVC)
target_compile_options(example PUBLIC /W2) target_compile_options(example PUBLIC /W2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")

View File

@ -156,6 +156,13 @@ namespace cxxopts
return result; return result;
} }
inline
bool
empty(const String& s)
{
return s.isEmpty();
}
} }
namespace std namespace std
@ -222,6 +229,12 @@ namespace cxxopts
return std::forward<T>(t); return std::forward<T>(t);
} }
inline
bool
empty(const std::string& s)
{
return s.empty();
}
} }
//ifdef CXXOPTS_USE_UNICODE //ifdef CXXOPTS_USE_UNICODE
@ -1364,7 +1377,7 @@ Options::help(const std::vector<std::string>& groups) const
for (std::size_t i = 0; i < groups.size(); ++i) for (std::size_t i = 0; i < groups.size(); ++i)
{ {
String const& group_help = help_one_group(groups[i]); String const& group_help = help_one_group(groups[i]);
if (group_help.empty()) continue; if (empty(group_help)) continue;
result += group_help; result += group_help;
if (i < groups.size() - 1) if (i < groups.size() - 1)
{ {

View File

@ -1,6 +1,8 @@
if (CXXOPTS_BUILD_TESTS) if (CXXOPTS_BUILD_TESTS)
add_executable(options_test options.cpp) add_executable(options_test options.cpp)
target_link_libraries(options_test ${CXXOPTS_LINKER_LIBRARIES})
if (MSVC) if (MSVC)
target_compile_options(options_test PUBLIC /W2) target_compile_options(options_test PUBLIC /W2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")