diff --git a/CMakeLists.txt b/CMakeLists.txt index e785ba4..34e6bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2b2ff9..625abe9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/example.cpp b/src/example.cpp index 526045c..c6500c6 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -24,8 +24,6 @@ THE SOFTWARE. #include -#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()) ("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")