@@ -77,6 +77,7 @@ if(ICU_SETTINGS_RESET)
7777 unset (NO_ICU_SH CACHE )
7878 unset (LOCAL_ICU_SH CACHE )
7979 unset (SYSTEM_ICU_SH CACHE )
80+ unset (EMBED_ICU_SH CACHE )
8081endif ()
8182
8283if (CC_TARGET_OS_ANDROID_SH)
@@ -135,7 +136,47 @@ else()
135136 set (INTL_ICU 0)
136137endif ()
137138
138- if (ICU_INCLUDE_PATH)
139+ if (EMBED_ICU_SH)
140+ set (EMBED_ICU 1)
141+ unset (EMBED_ICU_SH CACHE )
142+ endif ()
143+
144+ if (EMBED_ICU AND ICU_INCLUDE_PATH)
145+ message (FATAL_ERROR "Embedded ICU and ICU include path cannot be set at the same time" )
146+ endif ()
147+
148+ if (EMBED_ICU)
149+ # Keep consistent with what ICU download script used to print
150+ message ("Note: ICU installation and use is subject to it's publisher's licensing terms" )
151+
152+ set (ICU_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} /deps/thirdparty/icu)
153+ set (ICU_DOWNLOAD_DIR ${ICU_PREFIX} /download)
154+ set (ICU_SOURCE_DIR ${ICU_PREFIX} /stage)
155+ set (EMBEDDED_ICU_TARGET icu4c)
156+ set (ICU_INCLUDE_PATH ${ICU_PREFIX} /include )
157+ set (ICU_LIBRARY_PATH ${ICU_PREFIX} /lib)
158+ add_definitions (-DHAS_REAL_ICU=1)
159+ add_definitions (-DHAS_ICU)
160+ add_definitions (-DINTL_ICU=1)
161+ set (ICU_LIBRARIES
162+ ${ICU_LIBRARY_PATH} /libicuuc.a
163+ ${ICU_LIBRARY_PATH} /libicui18n.a
164+ ${ICU_LIBRARY_PATH} /libicudata.a
165+ )
166+
167+ include (ExternalProject)
168+ ExternalProject_Add(${EMBEDDED_ICU_TARGET}
169+ PREFIX ${ICU_PREFIX}
170+ DOWNLOAD_DIR ${ICU_DOWNLOAD_DIR}
171+ SOURCE_DIR ${ICU_SOURCE_DIR}
172+ URL https://github.com/unicode-org/icu/releases/download/release-63-2/icu4c-63_2-src.tgz
173+ URL_HASH SHA512=5fa9092efd8d6da6dfc8d498e4026167fda43423eaafc754d1789cf8fd4f6e76377878ebcaa32e14f314836136b764873511a93bfbcc5419b758841cc6df8f32
174+ CONFIGURE_COMMAND ${ICU_SOURCE_DIR} /source /configure --prefix =${ICU_PREFIX} --with-data-packaging=static --enable-static --disable-shared --with-library-bits=64 --disable-icuio --disable-layout --disable-tests --disable-samples
175+ BUILD_COMMAND make STATICCFLAGS="-fPIC" STATICCXXFLAGS="-fPIC" STATICCPPFLAGS="-DPIC"
176+ INSTALL_COMMAND make install
177+ BYPRODUCTS ${ICU_LIBRARIES}
178+ )
179+ elseif (ICU_INCLUDE_PATH)
139180 add_definitions (-DHAS_REAL_ICU=1)
140181 add_definitions (-DHAS_ICU)
141182 set (ICU_LIBRARY_PATH "${ICU_INCLUDE_PATH} /../lib/" )
0 commit comments