From 17a80f8c5e9b59a74e50e7e6768f929c31cde388 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sun, 20 Jan 2019 15:17:11 +0800 Subject: [PATCH] fix(cmake, xcode.mk): find optional dependency icu, while building xcode/release-with-icu target [skip appveyor] The homebrew version of boost(>=1.68) link to icu libraries by default Note: this will link against locally installed dylib and render the build non-portable --- CMakeLists.txt | 5 +++++ README-mac.md | 5 ++--- src/CMakeLists.txt | 1 + xcode.mk | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 519dc0030a..d9f683dec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ option(ENABLE_LOGGING "Enable logging with google-glog library" ON) option(BOOST_USE_CXX11 "Boost has been built with C++11 support" OFF) option(BOOST_USE_SIGNALS2 "Boost use signals2 instead of signals" ON) option(ENABLE_ASAN "Enable Address Sanitizer (Unix Only)" OFF) +option(BUILD_WITH_ICU "Build by explicitly linking to ICU libraries" OFF) set(rime_data_dir "/share/rime-data" CACHE STRING "Target directory for Rime data") @@ -91,6 +92,10 @@ endif() find_package(Threads) +if (BUILD_WITH_ICU) + find_package(ICU COMPONENTS uc) +endif() + find_package(Iconv) if (ICONV_FOUND) include_directories(${ICONV_INCLUDE_DIRS}) diff --git a/README-mac.md b/README-mac.md index 51885fe0de..6c25aa2637 100644 --- a/README-mac.md +++ b/README-mac.md @@ -22,9 +22,8 @@ brew link --force boost@1.60 > Starting from version 1.68, homebrewed `boost` libraries depends on `icu4c`, > which is not provided by macOS. > -> The [`with-icu` branch](https://github.com/rime/librime/tree/with-icu) adds -> support for linking to ICU libraries but the built app cannot run on machines -> without ICU libraries installed. +> The make target `xcode/release-with-icu` tells cmake to link to ICU libraries +> but the built app cannot run on machines without ICU libraries installed. > > To make the build portable, either install an earlier version of `boost` via > homebrew, or build from source with bootstrap option `--without-icu`. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02eae0604f..47f2fd62b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,7 @@ set(rime_dict_deps ${Marisa_LIBRARY}) set(rime_gears_deps ${ICONV_LIBRARIES} + ${ICU_LIBRARIES} ${Opencc_LIBRARY}) set(rime_levers_deps "") diff --git a/xcode.mk b/xcode.mk index 5beeae52ac..9e4bf3bacc 100644 --- a/xcode.mk +++ b/xcode.mk @@ -16,12 +16,29 @@ release: -DCMAKE_INSTALL_PREFIX="$(RIME_DIST_DIR)" cmake --build build --config Release +release-with-icu: + cmake . -Bbuild -GXcode \ + -DBUILD_STATIC=ON \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ + -DCMAKE_INSTALL_PREFIX="$(RIME_DIST_DIR)" \ + -DBUILD_WITH_ICU=ON \ + -DCMAKE_PREFIX_PATH=/usr/local/opt/icu4c + cmake --build build --config Release + debug: cmake . -Bdebug -GXcode \ -DBUILD_STATIC=ON \ -DBUILD_SEPARATE_LIBS=ON cmake --build debug --config Debug +debug-with-icu: + cmake . -Bdebug -GXcode \ + -DBUILD_STATIC=ON \ + -DBUILD_SEPARATE_LIBS=ON \ + -DBUILD_WITH_ICU=ON \ + -DCMAKE_PREFIX_PATH=/usr/local/opt/icu4c + cmake --build debug --config Debug + clean: rm -rf build > /dev/null 2>&1 || true rm -rf debug > /dev/null 2>&1 || true