You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.9 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. # We can't build glog with gflags, unless gflags is pre-installed.
  2. # If build glog with pre-installed gflags, there will be conflict.
  3. set(openfst_ROOT ${LIB_BASE_DIR}/openfst-src)
  4. set(openfst_BUILD "${LIB_BASE_DIR}/openfst-build")
  5. if(REBUILD)
  6. message(STATUS "${BoldGreen}Install openfst: ${GLOG_BUILD_DIR}${ColourReset}")
  7. #./configure --prefix=${openfst_SOURCE_DIR}/build --enable-static --disable-shared --with-pic
  8. execute_process(COMMAND rm -rf ${openfst_BUILD} && mkdir -p ${openfst_BUILD})
  9. # patch补丁必须打,不然会报glog无法动态识别这个库的方法,导致链接不成功。
  10. execute_process(
  11. COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${LIB_BASE_DIR}/openfst-src
  12. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  13. )
  14. execute_process(
  15. COMMAND ./configure --prefix=${openfst_BUILD} --with-pic
  16. WORKING_DIRECTORY ${LIB_BASE_DIR}/openfst-src)
  17. execute_process(
  18. COMMAND cmake --build . --target install
  19. WORKING_DIRECTORY ${openfst_BUILD})
  20. execute_process(
  21. COMMAND cmake --install .
  22. WORKING_DIRECTORY ${openfst_BUILD})
  23. endif()
  24. # We can't build glog with gflags, unless gflags is pre-installed.
  25. # If build glog with pre-installed gflags, there will be conflict.
  26. # gflags和glog现在被我安装到了系统盘下/usr/lib/x86_64-linux-gnu
  27. include(gflags)
  28. if(TARGET gflags)
  29. message(STATUS "${BoldGreen}Find Package gflags: ${gflags_FOUND}${ColourReset}")
  30. set_target_properties(gflags PROPERTIES INTERFACE_COMPILE_OPTIONS "-fPIC")
  31. endif()
  32. set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE)
  33. include(glog)
  34. # 下面这堆关键字是防止cmake出一堆无关的提示
  35. if(NOT GRAPH_TOOLS)
  36. set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE)
  37. set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE)
  38. endif()
  39. set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE)
  40. set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE)
  41. set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE)
  42. set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE)
  43. set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE)
  44. set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE)
  45. set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE)
  46. set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE)
  47. set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE)
  48. set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE)
  49. include_directories(${openfst_ROOT}/src/include)
  50. if (EXISTS ${openfst_BUILD}/src/lib/libfst.so)
  51. add_library(fst SHARED IMPORTED)
  52. set_property(TARGET fst PROPERTY IMPORTED_LOCATION ${openfst_BUILD}/src/lib/libfst.so)
  53. message(STATUS "${BoldGreen}Find Library libfst.so: ${openfst_BUILD}/src/lib/${ColourReset}")
  54. else ()
  55. message(FATAL_ERROR "${BoldRed}Can't find openfst library from: ${openfst_BUILD}/src/lib ${ColourReset}")
  56. endif ()
  57. list(APPEND third_party_libraries fst gflags_nothreads_static glog dl)