|
@ -1,8 +1,7 @@ |
|
|
# We can't build glog with gflags, unless gflags is pre-installed. |
|
|
# We can't build glog with gflags, unless gflags is pre-installed. |
|
|
# If build glog with pre-installed gflags, there will be conflict. |
|
|
# If build glog with pre-installed gflags, there will be conflict. |
|
|
|
|
|
|
|
|
set(openfst_ROOT ${LIB_BASE_DIR}/openfst-src) |
|
|
|
|
|
set(openfst_BUILD ${LIB_BASE_DIR}/openfst-build) |
|
|
|
|
|
|
|
|
set(OPENFST_ROOT ${LIB_BASE_DIR}/openfst-build) |
|
|
# We can't build glog with gflags, unless gflags is pre-installed. |
|
|
# We can't build glog with gflags, unless gflags is pre-installed. |
|
|
# If build glog with pre-installed gflags, there will be conflict. |
|
|
# If build glog with pre-installed gflags, there will be conflict. |
|
|
include(gflags) |
|
|
include(gflags) |
|
@ -13,11 +12,14 @@ endif() |
|
|
set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE) |
|
|
set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE) |
|
|
include(glog) |
|
|
include(glog) |
|
|
# 推荐手动构建这个openfst依赖,因为通过cmake构建这个库会失败。 |
|
|
# 推荐手动构建这个openfst依赖,因为通过cmake构建这个库会失败。 |
|
|
if(NOT EXISTS ${openfst_BUILD}) |
|
|
|
|
|
|
|
|
function(GRPC_INSTALL) |
|
|
# 推荐手动去构建项目,不然这些代码因为环境不兼容等原因会执行不成功 |
|
|
# 推荐手动去构建项目,不然这些代码因为环境不兼容等原因会执行不成功 |
|
|
message(STATUS "${BoldGreen}Install openfst: ${GLOG_BUILD_DIR}${ColourReset}") |
|
|
message(STATUS "${BoldGreen}Install openfst: ${GLOG_BUILD_DIR}${ColourReset}") |
|
|
|
|
|
|
|
|
execute_process(COMMAND mkdir ${openfst_BUILD}) |
|
|
|
|
|
|
|
|
if(NOT EXISTS ${OPENFST_ROOT}) |
|
|
|
|
|
execute_process(COMMAND mkdir -p "${OPENFST_ROOT}") |
|
|
|
|
|
else () |
|
|
|
|
|
execute_process(COMMAND rm -rf "${OPENFST_ROOT}/*") |
|
|
|
|
|
endif () |
|
|
# patch补丁必须打,不然会报glog无法动态识别这个库的方法,导致链接不成功。 |
|
|
# patch补丁必须打,不然会报glog无法动态识别这个库的方法,导致链接不成功。 |
|
|
execute_process( |
|
|
execute_process( |
|
|
COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${LIB_BASE_DIR}/openfst-src |
|
|
COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${LIB_BASE_DIR}/openfst-src |
|
@ -26,49 +28,56 @@ if(NOT EXISTS ${openfst_BUILD}) |
|
|
message(STATUS "${BoldGreen}configure openfst${ColourReset}") |
|
|
message(STATUS "${BoldGreen}configure openfst${ColourReset}") |
|
|
#./configure --prefix=${openfst_SOURCE_DIR}/build --enable-static --disable-shared --with-pic |
|
|
#./configure --prefix=${openfst_SOURCE_DIR}/build --enable-static --disable-shared --with-pic |
|
|
execute_process( |
|
|
execute_process( |
|
|
COMMAND ./configure --prefix=${openfst_BUILD} --with-pic |
|
|
|
|
|
WORKING_DIRECTORY ${openfst_ROOT} ) |
|
|
|
|
|
|
|
|
COMMAND ./configure --prefix=${OPENFST_ROOT} --with-pic |
|
|
|
|
|
WORKING_DIRECTORY ${LIB_BASE_DIR}/openfst-src ) |
|
|
|
|
|
|
|
|
message(STATUS "${BoldGreen}copy openfst patch done!${ColourReset}") |
|
|
message(STATUS "${BoldGreen}copy openfst patch done!${ColourReset}") |
|
|
execute_process( |
|
|
execute_process( |
|
|
COMMAND make -j4 |
|
|
COMMAND make -j4 |
|
|
WORKING_DIRECTORY ${openfst_ROOT} |
|
|
|
|
|
|
|
|
WORKING_DIRECTORY ${LIB_BASE_DIR}/openfst-src |
|
|
RESULT_VARIABLE configure_result |
|
|
RESULT_VARIABLE configure_result |
|
|
) |
|
|
) |
|
|
execute_process( |
|
|
|
|
|
COMMAND make --install |
|
|
|
|
|
WORKING_DIRECTORY ${openfst_ROOT}) |
|
|
|
|
|
if(configure_result) |
|
|
if(configure_result) |
|
|
message(FATAL_ERROR "${BoldRed}openfst项目构建不成功! ${ColourReset}") |
|
|
message(FATAL_ERROR "${BoldRed}openfst项目构建不成功! ${ColourReset}") |
|
|
endif () |
|
|
endif () |
|
|
endif() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 下面这堆关键字是防止cmake出一堆无关的提示 |
|
|
|
|
|
if(NOT GRAPH_TOOLS) |
|
|
|
|
|
set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) |
|
|
|
|
|
set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) |
|
|
|
|
|
endif() |
|
|
|
|
|
set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE) |
|
|
|
|
|
set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE) |
|
|
|
|
|
set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE) |
|
|
|
|
|
set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE) |
|
|
|
|
|
set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE) |
|
|
|
|
|
set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE) |
|
|
|
|
|
set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE) |
|
|
|
|
|
set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE) |
|
|
|
|
|
set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE) |
|
|
|
|
|
set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) |
|
|
|
|
|
|
|
|
|
|
|
include_directories(${openfst_ROOT}/src/include) |
|
|
|
|
|
|
|
|
|
|
|
if (EXISTS ${openfst_BUILD}/src/lib/libfst.so) |
|
|
|
|
|
add_library(fst SHARED IMPORTED) |
|
|
|
|
|
set_property(TARGET fst PROPERTY IMPORTED_LOCATION ${openfst_BUILD}/src/lib/libfst.so) |
|
|
|
|
|
message(STATUS "${BoldGreen}Find Library libfst.so: ${openfst_BUILD}/src/lib/${ColourReset}") |
|
|
|
|
|
|
|
|
execute_process( |
|
|
|
|
|
COMMAND make --install |
|
|
|
|
|
WORKING_DIRECTORY ${LIB_BASE_DIR}/openfst-src) |
|
|
|
|
|
endfunction() |
|
|
|
|
|
if(LIB_BASE_DIR) |
|
|
|
|
|
# 下面这堆关键字是防止cmake出一堆无关的提示 |
|
|
|
|
|
if(NOT GRAPH_TOOLS) |
|
|
|
|
|
set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) |
|
|
|
|
|
set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) |
|
|
|
|
|
endif() |
|
|
|
|
|
set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE) |
|
|
|
|
|
set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE) |
|
|
|
|
|
set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE) |
|
|
|
|
|
set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE) |
|
|
|
|
|
set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE) |
|
|
|
|
|
set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE) |
|
|
|
|
|
set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE) |
|
|
|
|
|
set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE) |
|
|
|
|
|
set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE) |
|
|
|
|
|
set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) |
|
|
else () |
|
|
else () |
|
|
message(FATAL_ERROR "${BoldRed}Can't find openfst library from: ${openfst_BUILD}/src/lib ${ColourReset}") |
|
|
|
|
|
|
|
|
message(FATAL_ERROR "${BoldRed}LIB_BASE_DIR for openfst is not set! ${ColourReset}") |
|
|
endif () |
|
|
endif () |
|
|
|
|
|
|
|
|
list(APPEND third_party_libraries fst gflags_nothreads_static glog dl) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
find_path(OPENFST_INCLUDE_DIR fst/fst.h PATHS ${OPENFST_ROOT}/include) |
|
|
|
|
|
include_directories(${OPENFST_INCLUDE_DIR}) |
|
|
|
|
|
find_path(OPENFST_BINARY_DIR fstsymbols PATHS ${OPENFST_ROOT}/bin) |
|
|
|
|
|
find_path(OPENFST_LIBRARY_DIR libfst.so PATHS ${OPENFST_ROOT}/lib) |
|
|
|
|
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${OPENFST_LIBRARY_DIR}) |
|
|
|
|
|
set(OPENFST_LIBRARYS fst gflags_nothreads_static glog dl) |
|
|
|
|
|
#验证库和文件是否被找到 |
|
|
|
|
|
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) |
|
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Openfst DEFAULT_MSG |
|
|
|
|
|
OPENFST_INCLUDE_DIR OPENFST_BINARY_DIR OPENFST_LIBRARY_DIR |
|
|
|
|
|
fst gflags_nothreads_static glog dl) |
|
|
|
|
|
message("${BoldGreen}Openfst FOUND\n |
|
|
|
|
|
OPENFST_INCLUDE_DIR: ${OPENFST_INCLUDE_DIR}\n |
|
|
|
|
|
OPENFST_BINARY_DIR: ${OPENFST_BINARY_DIR}\n |
|
|
|
|
|
OPENFST_LIBRARY_DIR: ${OPENFST_LIBRARY_DIR}\n |
|
|
|
|
|
IMPORTED OPENFST_LIBRARYS: ${OPENFST_LIBRARYS}${ColourReset}") |