2023-01-09 17:14:24 +08:00
|
|
|
vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
|
|
|
|
string(REGEX MATCH "^[0-9]*" ICU_VERSION_MAJOR "${VERSION}")
|
|
|
|
string(REPLACE "." "_" VERSION2 "${VERSION}")
|
|
|
|
string(REPLACE "." "-" VERSION3 "${VERSION}")
|
2020-11-19 06:09:34 +08:00
|
|
|
|
|
|
|
vcpkg_download_distfile(
|
|
|
|
ARCHIVE
|
|
|
|
URLS "https://github.com/unicode-org/icu/releases/download/release-${VERSION3}/icu4c-${VERSION2}-src.tgz"
|
|
|
|
FILENAME "icu4c-${VERSION2}-src.tgz"
|
2023-01-09 17:14:24 +08:00
|
|
|
SHA512 848c341b37c0ff077e34a95d92c6200d5aaddd0ee5e06134101a74e04deb08256a5e817c8aefab020986abe810b7827dd7b2169a60dacd250c298870518dcae8
|
2020-11-19 06:09:34 +08:00
|
|
|
)
|
2022-04-12 00:06:15 +08:00
|
|
|
|
2023-01-09 17:14:24 +08:00
|
|
|
vcpkg_extract_source_archive(SOURCE_PATH
|
|
|
|
ARCHIVE "${ARCHIVE}"
|
2020-11-19 06:09:34 +08:00
|
|
|
PATCHES
|
2021-09-24 08:45:11 +08:00
|
|
|
disable-escapestr-tool.patch
|
|
|
|
remove-MD-from-configure.patch
|
|
|
|
fix_parallel_build_on_windows.patch
|
|
|
|
fix-extra.patch
|
|
|
|
mingw-dll-install.patch
|
|
|
|
disable-static-prefix.patch # https://gitlab.kitware.com/cmake/cmake/-/issues/16617; also mingw.
|
2022-01-14 05:23:44 +08:00
|
|
|
fix-win-build.patch
|
2020-11-19 06:09:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
vcpkg_find_acquire_program(PYTHON3)
|
|
|
|
set(ENV{PYTHON} "${PYTHON3}")
|
|
|
|
|
2022-01-14 05:23:44 +08:00
|
|
|
if(VCPKG_TARGET_IS_WINDOWS)
|
|
|
|
list(APPEND CONFIGURE_OPTIONS --enable-icu-build-win)
|
|
|
|
endif()
|
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
list(APPEND CONFIGURE_OPTIONS --disable-samples --disable-tests --disable-layoutex)
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
list(APPEND CONFIGURE_OPTIONS_RELEASE --disable-debug --enable-release)
|
|
|
|
list(APPEND CONFIGURE_OPTIONS_DEBUG --enable-debug --disable-release)
|
2020-11-19 06:09:34 +08:00
|
|
|
|
|
|
|
set(RELEASE_TRIPLET ${TARGET_TRIPLET}-rel)
|
|
|
|
set(DEBUG_TRIPLET ${TARGET_TRIPLET}-dbg)
|
|
|
|
|
2023-01-27 13:40:42 +08:00
|
|
|
if("tools" IN_LIST FEATURES)
|
|
|
|
list(APPEND CONFIGURE_OPTIONS --enable-tools)
|
|
|
|
else()
|
|
|
|
list(APPEND CONFIGURE_OPTIONS --disable-tools)
|
|
|
|
endif()
|
2021-09-24 08:45:11 +08:00
|
|
|
if(CMAKE_HOST_WIN32 AND VCPKG_TARGET_IS_MINGW AND NOT HOST_TRIPLET MATCHES "mingw")
|
|
|
|
# Assuming no cross compiling because the host (windows) pkgdata tool doesn't
|
|
|
|
# use the '/' path separator when creating compiler commands for mingw bash.
|
|
|
|
elseif(VCPKG_CROSSCOMPILING)
|
2021-09-08 06:19:28 +08:00
|
|
|
set(TOOL_PATH "${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
|
|
|
|
# convert to unix path
|
|
|
|
string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" _VCPKG_TOOL_PATH "${TOOL_PATH}")
|
|
|
|
list(APPEND CONFIGURE_OPTIONS "--with-cross-build=${_VCPKG_TOOL_PATH}")
|
2021-05-02 02:16:52 +08:00
|
|
|
endif()
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
vcpkg_configure_make(
|
2021-11-11 02:49:18 +08:00
|
|
|
SOURCE_PATH "${SOURCE_PATH}"
|
2022-01-14 05:23:44 +08:00
|
|
|
AUTOCONFIG
|
2021-05-02 02:16:52 +08:00
|
|
|
PROJECT_SUBPATH source
|
2022-04-12 00:06:15 +08:00
|
|
|
ADDITIONAL_MSYS_PACKAGES autoconf-archive
|
2021-05-02 02:16:52 +08:00
|
|
|
OPTIONS ${CONFIGURE_OPTIONS}
|
|
|
|
OPTIONS_RELEASE ${CONFIGURE_OPTIONS_RELEASE}
|
|
|
|
OPTIONS_DEBUG ${CONFIGURE_OPTIONS_DEBUG}
|
2021-07-23 13:00:40 +08:00
|
|
|
DETERMINE_BUILD_TRIPLET
|
2021-05-02 02:16:52 +08:00
|
|
|
)
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2023-01-09 17:14:24 +08:00
|
|
|
if(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
vcpkg_build_make()
|
2021-01-27 06:58:42 +08:00
|
|
|
# remove this block if https://unicode-org.atlassian.net/browse/ICU-21458
|
|
|
|
# is resolved and use the configure script instead
|
2021-05-02 02:16:52 +08:00
|
|
|
if(DEFINED CMAKE_INSTALL_NAME_DIR)
|
|
|
|
set(ID_PREFIX "${CMAKE_INSTALL_NAME_DIR}")
|
|
|
|
else()
|
|
|
|
set(ID_PREFIX "@rpath")
|
|
|
|
endif()
|
2021-01-27 06:58:42 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
# install_name_tool may be missing if cross-compiling
|
|
|
|
find_program(
|
|
|
|
INSTALL_NAME_TOOL
|
|
|
|
install_name_tool
|
|
|
|
HINTS /usr/bin /Library/Developer/CommandLineTools/usr/bin/
|
|
|
|
DOC "Absolute path of install_name_tool"
|
|
|
|
REQUIRED
|
|
|
|
)
|
2021-01-27 06:58:42 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
message(STATUS "setting rpath prefix for macOS dynamic libraries")
|
2021-07-23 13:00:40 +08:00
|
|
|
|
2023-04-13 02:29:01 +08:00
|
|
|
if("tools" IN_LIST FEATURES)
|
|
|
|
set(LIBICUTU_RPATH "libicutu")
|
|
|
|
endif()
|
2021-05-02 02:16:52 +08:00
|
|
|
# add ID_PREFIX to libicudata libicui18n libicuio libicutu libicuuc
|
2023-04-13 02:29:01 +08:00
|
|
|
foreach(LIB_NAME IN ITEMS libicudata libicui18n libicuio ${LIBICUTU_RPATH} libicuuc)
|
2021-01-27 06:58:42 +08:00
|
|
|
vcpkg_execute_build_process(
|
2023-01-09 17:14:24 +08:00
|
|
|
COMMAND "${INSTALL_NAME_TOOL}" -id "${ID_PREFIX}/${LIB_NAME}.${ICU_VERSION_MAJOR}.dylib"
|
2021-05-02 02:16:52 +08:00
|
|
|
"${LIB_NAME}.${VERSION}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/lib"
|
|
|
|
LOGNAME "make-build-fix-rpath-${RELEASE_TRIPLET}"
|
|
|
|
)
|
2021-05-02 02:16:52 +08:00
|
|
|
endforeach()
|
2021-07-23 13:00:40 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
# add ID_PREFIX to libicui18n libicuio libicutu dependencies
|
2023-01-09 17:14:24 +08:00
|
|
|
foreach(LIB_NAME IN ITEMS libicui18n libicuio)
|
2021-01-27 06:58:42 +08:00
|
|
|
vcpkg_execute_build_process(
|
2023-01-09 17:14:24 +08:00
|
|
|
COMMAND "${INSTALL_NAME_TOOL}" -change "libicuuc.${ICU_VERSION_MAJOR}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
"${ID_PREFIX}/libicuuc.${ICU_VERSION_MAJOR}.dylib"
|
2021-05-02 02:16:52 +08:00
|
|
|
"${LIB_NAME}.${VERSION}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/lib"
|
|
|
|
LOGNAME "make-build-fix-rpath-${RELEASE_TRIPLET}"
|
|
|
|
)
|
|
|
|
vcpkg_execute_build_process(
|
2023-01-09 17:14:24 +08:00
|
|
|
COMMAND "${INSTALL_NAME_TOOL}" -change "libicudata.${ICU_VERSION_MAJOR}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
"${ID_PREFIX}/libicudata.${ICU_VERSION_MAJOR}.dylib"
|
2021-05-02 02:16:52 +08:00
|
|
|
"${LIB_NAME}.${VERSION}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/lib"
|
|
|
|
LOGNAME "make-build-fix-rpath-${RELEASE_TRIPLET}"
|
|
|
|
)
|
2021-05-02 02:16:52 +08:00
|
|
|
endforeach()
|
2021-01-27 06:58:42 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
# add ID_PREFIX to remaining libicuio libicutu dependencies
|
|
|
|
foreach(LIB_NAME libicuio libicutu)
|
2021-01-27 06:58:42 +08:00
|
|
|
vcpkg_execute_build_process(
|
2023-01-09 17:14:24 +08:00
|
|
|
COMMAND "${INSTALL_NAME_TOOL}" -change "libicui18n.${ICU_VERSION_MAJOR}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
"${ID_PREFIX}/libicui18n.${ICU_VERSION_MAJOR}.dylib"
|
2021-05-02 02:16:52 +08:00
|
|
|
"${LIB_NAME}.${VERSION}.dylib"
|
2021-01-27 06:58:42 +08:00
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/lib"
|
|
|
|
LOGNAME "make-build-fix-rpath-${RELEASE_TRIPLET}"
|
|
|
|
)
|
2021-05-02 02:16:52 +08:00
|
|
|
endforeach()
|
2021-01-27 06:58:42 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
# add ID_PREFIX to libicuuc dependencies
|
2020-11-19 06:09:34 +08:00
|
|
|
vcpkg_execute_build_process(
|
2023-01-09 17:14:24 +08:00
|
|
|
COMMAND "${INSTALL_NAME_TOOL}" -change "libicudata.${ICU_VERSION_MAJOR}.dylib"
|
2021-05-02 02:16:52 +08:00
|
|
|
"${ID_PREFIX}/libicudata.${ICU_VERSION_MAJOR}.dylib"
|
|
|
|
"libicuuc.${VERSION}.dylib"
|
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/lib"
|
|
|
|
LOGNAME "make-build-fix-rpath-${RELEASE_TRIPLET}"
|
|
|
|
)
|
2020-11-19 06:09:34 +08:00
|
|
|
endif()
|
|
|
|
|
2021-09-04 07:42:38 +08:00
|
|
|
vcpkg_install_make()
|
|
|
|
|
2020-11-19 06:09:34 +08:00
|
|
|
file(REMOVE_RECURSE
|
2021-11-11 02:49:18 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/share"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/share"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/lib/icu"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/lib/icu"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/lib/icud")
|
2020-11-19 06:09:34 +08:00
|
|
|
|
|
|
|
file(GLOB TEST_LIBS
|
2021-11-11 02:49:18 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/lib/*test*"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/lib/*test*")
|
2021-09-04 07:42:38 +08:00
|
|
|
if(TEST_LIBS)
|
|
|
|
file(REMOVE ${TEST_LIBS})
|
|
|
|
endif()
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
2020-11-19 06:09:34 +08:00
|
|
|
# force U_STATIC_IMPLEMENTATION macro
|
|
|
|
foreach(HEADER utypes.h utf_old.h platform.h)
|
2021-11-11 02:49:18 +08:00
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/unicode/${HEADER}" "defined(U_STATIC_IMPLEMENTATION)" "1")
|
2020-11-19 06:09:34 +08:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2021-05-02 02:16:52 +08:00
|
|
|
# Install executables from /tools/icu/sbin to /tools/icu/bin on unix (/bin because icu require this for cross compiling)
|
2023-02-08 07:01:58 +08:00
|
|
|
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX AND "tools" IN_LIST FEATURES)
|
2021-05-02 02:16:52 +08:00
|
|
|
vcpkg_copy_tools(
|
|
|
|
TOOL_NAMES icupkg gennorm2 gencmn genccode gensprep
|
2021-11-11 02:49:18 +08:00
|
|
|
SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools/icu/sbin"
|
|
|
|
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin"
|
2021-05-02 02:16:52 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(REMOVE_RECURSE
|
2021-11-11 02:49:18 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/tools/icu/sbin"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/tools/icu/debug")
|
2021-05-02 02:16:52 +08:00
|
|
|
|
|
|
|
# To cross compile, we need some files at specific positions. So lets copy them
|
2021-11-11 02:49:18 +08:00
|
|
|
file(GLOB CROSS_COMPILE_DEFS "${CURRENT_BUILDTREES_DIR}/${RELEASE_TRIPLET}/config/icucross.*")
|
|
|
|
file(INSTALL ${CROSS_COMPILE_DEFS} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/config")
|
2021-05-02 02:16:52 +08:00
|
|
|
|
2023-01-09 17:14:24 +08:00
|
|
|
file(GLOB RELEASE_DLLS "${CURRENT_PACKAGES_DIR}/lib/*icu*${ICU_VERSION_MAJOR}.dll")
|
|
|
|
file(COPY ${RELEASE_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")
|
2021-05-02 02:16:52 +08:00
|
|
|
|
|
|
|
# copy dlls
|
2023-01-09 17:14:24 +08:00
|
|
|
file(GLOB RELEASE_DLLS "${CURRENT_PACKAGES_DIR}/lib/*icu*${ICU_VERSION_MAJOR}.dll")
|
|
|
|
file(COPY ${RELEASE_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
|
|
|
|
if(NOT VCPKG_BUILD_TYPE)
|
2021-11-11 02:49:18 +08:00
|
|
|
file(GLOB DEBUG_DLLS "${CURRENT_PACKAGES_DIR}/debug/lib/*icu*${ICU_VERSION_MAJOR}.dll")
|
|
|
|
file(COPY ${DEBUG_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
|
2021-05-02 02:16:52 +08:00
|
|
|
endif()
|
2020-11-19 06:09:34 +08:00
|
|
|
|
|
|
|
# remove any remaining dlls in /lib
|
2021-11-11 02:49:18 +08:00
|
|
|
file(GLOB DUMMY_DLLS "${CURRENT_PACKAGES_DIR}/lib/*.dll" "${CURRENT_PACKAGES_DIR}/debug/lib/*.dll")
|
2020-11-19 06:09:34 +08:00
|
|
|
if(DUMMY_DLLS)
|
|
|
|
file(REMOVE ${DUMMY_DLLS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
vcpkg_copy_pdbs()
|
2023-01-09 17:14:24 +08:00
|
|
|
vcpkg_fixup_pkgconfig()
|
2020-11-19 06:09:34 +08:00
|
|
|
|
2021-11-11 02:49:18 +08:00
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/icu/bin/icu-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../../")
|
|
|
|
|
2023-01-09 17:14:24 +08:00
|
|
|
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
2022-01-14 05:23:44 +08:00
|
|
|
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|