unicode configuration

This commit is contained in:
Jarryd Beck 2014-10-27 22:06:24 +11:00
parent 8234766bca
commit 8d7c4ea43e
3 changed files with 17 additions and 6 deletions

View File

@ -23,9 +23,20 @@ project(cxxopts)
set(VERSION "0.0.1")
find_package(PkgConfig)
set(CXXOPTS_LINKER_LIBRARIES "")
pkg_check_modules(ICU REQUIRED icu-uc)
set(CXXOPTS_USE_UNICODE_HELP FALSE CACHE BOOL "Use ICU Unicode library")
if(CXXOPTS_USE_UNICODE_HELP)
find_package(PkgConfig)
pkg_check_modules(ICU REQUIRED icu-uc)
set(CXXOPTS_LINKER_LIBRARIES "${ICU_LIBRARIES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCXXOPTS_USE_UNICODE")
endif()
add_subdirectory(src)

View File

@ -21,6 +21,6 @@
add_executable(example example.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
target_link_libraries(example ${ICU_LIBRARIES})
target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES})
install(FILES cxxopts.hpp DESTINATION include)

View File

@ -24,8 +24,6 @@ THE SOFTWARE.
#include <iostream>
#define CXXOPTS_USE_UNICODE
#include "cxxopts.hpp"
int main(int argc, char* argv[])
@ -48,8 +46,10 @@ int main(int argc, char* argv[])
("help", "Print help")
("int", "An integer", cxxopts::value<int>())
("option_that_is_too_long_for_the_help", "A very long option")
("unicode", u8"A help option with non-ascii: à. Here the length of the"
#ifdef CXXOPTS_USE_UNICODE
("unicode", u8"A help option with non-ascii: à. Here the size of the"
" string should be correct")
#endif
;
options.add_options("Group")