Skip to content

Commit

Permalink
Move language model to usr/lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Aug 29, 2020
1 parent 3c67a3d commit 6c00982
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cma

find_package(Boost 1.61 REQUIRED COMPONENTS iostreams)
set(LIBIME_INSTALL_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/libime")
set(LIBIME_INSTALL_LIBDATADIR "${CMAKE_INSTALL_FULL_LIBDIR}/libime")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#define _LIBIME_CONFIG_H_IN_

#define LIBIME_INSTALL_PKGDATADIR "@LIBIME_INSTALL_PKGDATADIR@"
#define LIBIME_INSTALL_LIBDATADIR "@LIBIME_INSTALL_LIBDATADIR@"

#endif // _LIBIME_CONFIG_H_IN_
8 changes: 4 additions & 4 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ add_custom_command(
COMMAND LibIME::prediction "${OPENGRAM_LM_OUTPUT}" "${OPENGRAM_LM_SRC}" "${OPENGRAM_LM_PREDICT_OUTPUT}")
add_custom_target(opengram-lm-predict ALL DEPENDS "${OPENGRAM_LM_PREDICT_OUTPUT}")

install(FILES "${OPENGRAM_LM_OUTPUT}" RENAME zh_CN.lm DESTINATION "${CMAKE_INSTALL_DATADIR}/libime")
install(FILES "${OPENGRAM_LM_PREDICT_OUTPUT}" RENAME zh_CN.lm.predict DESTINATION "${CMAKE_INSTALL_DATADIR}/libime")
install(FILES "${OPENGRAM_LM_OUTPUT}" RENAME zh_CN.lm DESTINATION "${LIBIME_INSTALL_LIBDATADIR}")
install(FILES "${OPENGRAM_LM_PREDICT_OUTPUT}" RENAME zh_CN.lm.predict DESTINATION "${LIBIME_INSTALL_PKGDATADIR}")

set(OPENGRAM_DICT_TAR "dict.utf8-20200715.tar.xz")
set(OPENGRAM_DICT_URL "https://download.fcitx-im.org/data/${OPENGRAM_DICT_TAR}")
Expand All @@ -48,7 +48,7 @@ add_custom_command(
DEPENDS "${OPENGRAM_DICT_SRC}" LibIME::pinyindict
COMMAND LibIME::pinyindict "${OPENGRAM_DICT_SRC}" "${OPENGRAM_DICT_OUTPUT}")
add_custom_target(opengram-dict ALL DEPENDS "${OPENGRAM_DICT_OUTPUT}")
install(FILES "${OPENGRAM_DICT_OUTPUT}" DESTINATION "${CMAKE_INSTALL_DATADIR}/libime")
install(FILES "${OPENGRAM_DICT_OUTPUT}" DESTINATION "${LIBIME_INSTALL_PKGDATADIR}")

set(TABLE_DICT_URL "https://download.fcitx-im.org/data/table.tar.gz")
set(TABLE_DICT_TAR "table.tar.gz")
Expand All @@ -69,4 +69,4 @@ foreach(TABLE_TXT_FILE ${TABLE_TXT_FILES})
endforeach()

add_custom_target(table-dict ALL DEPENDS ${TABLE_DICT_FILES})
install(FILES ${TABLE_DICT_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/libime")
install(FILES ${TABLE_DICT_FILES} DESTINATION "${LIBIME_INSTALL_PKGDATADIR}")
2 changes: 1 addition & 1 deletion src/libime/core/languagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ std::string DefaultLanguageModelResolver::languageModelFileNameForLanguage(
if (language.empty() || language.find('/') != std::string::npos) {
return {};
}
auto file = fcitx::stringutils::joinPath(LIBIME_INSTALL_PKGDATADIR,
auto file = fcitx::stringutils::joinPath(LIBIME_INSTALL_LIBDATADIR,
language + ".lm");
if (fcitx::fs::isreg(file)) {
return file;
Expand Down

0 comments on commit 6c00982

Please sign in to comment.