@@ -60,6 +60,7 @@ option(MZ_OPENSSL "Enables OpenSSL for encryption" ${UNIX})
6060cmake_dependent_option (MZ_LIBBSD "Builds with libbsd crypto random" ON "UNIX" OFF )
6161# Character conversion options
6262option (MZ_ICONV "Enables iconv for string encoding conversion" ON )
63+ option (MZ_ICU "Enables ICU for string encoding conversion" OFF )
6364# Code generation options
6465option (MZ_COMPRESS_ONLY "Only support compression" OFF )
6566option (MZ_DECOMPRESS_ONLY "Only support decompression" OFF )
@@ -586,6 +587,12 @@ else()
586587 list (APPEND MINIZIP_DEF -DMZ_ZIP_NO_CRYPTO)
587588 endif ()
588589
590+ # Iconv and ICU are mutually exclusive; ICU takes precedence
591+ if (MZ_ICU AND MZ_ICONV)
592+ message (STATUS "ICU enabled, disabling Iconv" )
593+ set (MZ_ICONV OFF )
594+ endif ()
595+
589596 # Iconv is only necessary when it is not already built-in
590597 # FindIconv requires cmake 3.11 or higher
591598 if (MZ_ICONV)
@@ -606,6 +613,24 @@ else()
606613
607614 set (MZ_ICONV OFF )
608615 endif ()
616+
617+ if (MZ_ICU)
618+ find_package (ICU COMPONENTS uc QUIET )
619+ endif ()
620+
621+ if (ICU_FOUND)
622+ message (STATUS "Using ICU ${ICU_VERSION} " )
623+
624+ list (APPEND MINIZIP_DEF -DHAVE_ICU)
625+ list (APPEND MINIZIP_DEP_PKG ICU)
626+ list (APPEND MINIZIP_LIB ICU::uc)
627+ set (PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -licuuc" )
628+ else ()
629+ if (MZ_ICU)
630+ message (STATUS "ICU library not found" )
631+ set (MZ_ICU OFF )
632+ endif ()
633+ endif ()
609634endif ()
610635
611636# Setup predefined macros
@@ -1056,6 +1081,7 @@ add_feature_info(MZ_OPENSSL MZ_OPENSSL "Enables OpenSSL for encryption")
10561081add_feature_info (MZ_LIBBSD MZ_LIBBSD "Builds with libbsd crypto random" )
10571082# Character conversion options
10581083add_feature_info (MZ_ICONV MZ_ICONV "Enables iconv string encoding conversion library" )
1084+ add_feature_info (MZ_ICU MZ_ICU "Enables ICU string encoding conversion library" )
10591085# Code generation options
10601086add_feature_info (MZ_COMPRESS_ONLY MZ_COMPRESS_ONLY "Only support compression" )
10611087add_feature_info (MZ_DECOMPRESS_ONLY MZ_DECOMPRESS_ONLY "Only support decompression" )
0 commit comments