Skip to content

Commit

Permalink
fix(cmake, xcode.mk): find optional dependency icu, while building xc…
Browse files Browse the repository at this point in the history
…ode/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
  • Loading branch information
lotem committed Jun 18, 2019
1 parent 5a18ff5 commit 17a80f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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})
Expand Down
5 changes: 2 additions & 3 deletions README-mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(rime_dict_deps
${Marisa_LIBRARY})
set(rime_gears_deps
${ICONV_LIBRARIES}
${ICU_LIBRARIES}
${Opencc_LIBRARY})
set(rime_levers_deps "")

Expand Down
17 changes: 17 additions & 0 deletions xcode.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17a80f8

Please sign in to comment.