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.

47 lines
2.2 KiB

  1. if(NOT ANDROID)
  2. include(gflags)
  3. # We can't build glog with gflags, unless gflags is pre-installed.
  4. # If build glog with pre-installed gflags, there will be conflict.
  5. set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE)
  6. include(glog)
  7. if(NOT GRAPH_TOOLS)
  8. set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE)
  9. set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE)
  10. endif()
  11. set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE)
  12. set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE)
  13. set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE)
  14. set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE)
  15. set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE)
  16. set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE)
  17. set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE)
  18. set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE)
  19. set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE)
  20. set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE)
  21. if(MSVC)
  22. add_compile_options(/W0 /wd4244 /wd4267)
  23. endif()
  24. # "OpenFST port for Windows" builds openfst with cmake for multiple platforms.
  25. # Openfst is compiled with glog/gflags to avoid log and flag conflicts with log and flags in wenet/libtorch.
  26. # To build openfst with gflags and glog, we comment out some vars of {flags, log}.h and flags.cc.
  27. set(openfst_SOURCE_DIR ${fc_base}/openfst-src CACHE PATH "OpenFST source directory")
  28. FetchContent_Declare(openfst
  29. URL https://github.com/kkm000/openfst/archive/refs/tags/win/1.7.2.1.tar.gz
  30. URL_HASH SHA256=e04e1dabcecf3a687ace699ccb43a8a27da385777a56e69da6e103344cc66bca
  31. #URL https://github.com/kkm000/openfst/archive/refs/tags/win/1.6.5.1.tar.gz
  32. #URL_HASH SHA256=02c49b559c3976a536876063369efc0e41ab374be1035918036474343877046e
  33. PATCH_COMMAND
  34. )
  35. FetchContent_MakeAvailable(openfst)
  36. add_dependencies(fst gflags glog)
  37. target_link_libraries(fst PUBLIC gflags_nothreads_static glog)
  38. include_directories(${openfst_SOURCE_DIR}/src/include)
  39. else()
  40. set(openfst_BINARY_DIR ${build_DIR}/wenet-openfst-android-1.0.2.aar/jni)
  41. include_directories(${openfst_BINARY_DIR}/include)
  42. link_directories(${openfst_BINARY_DIR}/${ANDROID_ABI})
  43. link_libraries(log gflags_nothreads glog fst)
  44. endif()