Commit a04284fc2c650f52e0d09cbc6c6d688fbf64cca9

Authored by Jarryd Beck
1 parent d92988c6

fix Unicode build

src/CMakeLists.txt
... ... @@ -21,6 +21,8 @@
21 21 if(CXXOPTS_BUILD_EXAMPLES)
22 22 add_executable(example example.cpp cxxopts.hpp)
23 23  
  24 + target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES})
  25 +
24 26 if (MSVC)
25 27 target_compile_options(example PUBLIC /W2)
26 28 elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
... ...
src/cxxopts.hpp
... ... @@ -156,6 +156,13 @@ namespace cxxopts
156 156  
157 157 return result;
158 158 }
  159 +
  160 + inline
  161 + bool
  162 + empty(const String& s)
  163 + {
  164 + return s.isEmpty();
  165 + }
159 166 }
160 167  
161 168 namespace std
... ... @@ -222,6 +229,12 @@ namespace cxxopts
222 229 return std::forward<T>(t);
223 230 }
224 231  
  232 + inline
  233 + bool
  234 + empty(const std::string& s)
  235 + {
  236 + return s.empty();
  237 + }
225 238 }
226 239  
227 240 //ifdef CXXOPTS_USE_UNICODE
... ... @@ -1364,7 +1377,7 @@ Options::help(const std::vector&lt;std::string&gt;&amp; groups) const
1364 1377 for (std::size_t i = 0; i < groups.size(); ++i)
1365 1378 {
1366 1379 String const& group_help = help_one_group(groups[i]);
1367   - if (group_help.empty()) continue;
  1380 + if (empty(group_help)) continue;
1368 1381 result += group_help;
1369 1382 if (i < groups.size() - 1)
1370 1383 {
... ...
test/CMakeLists.txt
1 1 if (CXXOPTS_BUILD_TESTS)
2 2 add_executable(options_test options.cpp)
3 3  
  4 + target_link_libraries(options_test ${CXXOPTS_LINKER_LIBRARIES})
  5 +
4 6 if (MSVC)
5 7 target_compile_options(options_test PUBLIC /W2)
6 8 elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
... ...