Installation¶
polycpp-iconv-lite targets C++20 and uses generated table data from
upstream iconv-lite for legacy character sets.
Requirements¶
CMake 3.20 or newer
A C++20 compiler
A polycpp checkout, or network access so CMake can fetch polycpp
CMake FetchContent¶
Add the library to your CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
polycpp_iconv_lite
GIT_REPOSITORY https://github.com/polycpp/iconv-lite.git
GIT_TAG master
)
FetchContent_MakeAvailable(polycpp_iconv_lite)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE polycpp::iconv_lite)
The companion links polycpp and does not require a direct ICU or iconv
dependency. Standalone builds default embedded polycpp to
POLYCPP_UNICODE=builtin because iconv-lite compatibility is provided by the
generated upstream tables. Consumers can pass -DPOLYCPP_UNICODE=auto or
-DPOLYCPP_UNICODE=icu if their wider application needs those polycpp
features. Pin GIT_TAG to a release commit for reproducible builds.
Using a local polycpp checkout¶
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DPOLYCPP_SOURCE_DIR=/path/to/polycpp
When POLYCPP_SOURCE_DIR is not set, CMake fetches polycpp from GitHub.
Build options¶
POLYCPP_ICONV_LITE_BUILD_TESTSBuild the GoogleTest suite. Defaults to
ONfor standalone builds andOFFwhen consumed through FetchContent.POLYCPP_ICONV_LITE_BUILD_EXAMPLESBuild examples under
examples/. Defaults toOFF.POLYCPP_SOURCE_DIRPath to a local polycpp checkout.
Verifying the install¶
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DPOLYCPP_ICONV_LITE_BUILD_EXAMPLES=ON
cmake --build build -j$(nproc)
ctest --test-dir build --output-on-failure
./build/examples/convert
The example prints Windows-1251 bytes for Привет and then decodes them
back to UTF-8 text.
Individual example targets use namespaced CMake target names, such as
polycpp_iconv_lite_example_convert, and write runnable binaries under
build/examples/.