|
1 | 1 | include(gflags) |
| 2 | +# We can't build glog with gflags, unless gflags is pre-installed. |
| 3 | +# If build glog with pre-installed gflags, there will be conflict. |
2 | 4 | set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE) |
3 | 5 | include(glog) |
4 | 6 |
|
5 | | -set(CONFIG_FLAGS "") |
6 | | -if(NOT FST_HAVE_BIN) |
7 | | - set(CONFIG_FLAGS "--disable-bin") |
| 7 | +set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) |
| 8 | +set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) |
| 9 | +set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE) |
| 10 | +set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE) |
| 11 | +set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE) |
| 12 | +set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE) |
| 13 | +set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE) |
| 14 | +set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE) |
| 15 | +set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE) |
| 16 | +set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE) |
| 17 | +set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE) |
| 18 | +set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) |
| 19 | + |
| 20 | +if(MSVC) |
| 21 | + add_compile_options(/W0 /wd4244 /wd4267) |
8 | 22 | endif() |
9 | 23 |
|
| 24 | +# "OpenFST port for Windows" builds openfst with cmake for multiple platforms. |
10 | 25 | # Openfst is compiled with glog/gflags to avoid log and flag conflicts with log and flags in wenet/libtorch. |
11 | 26 | # To build openfst with gflags and glog, we comment out some vars of {flags, log}.h and flags.cc. |
12 | 27 | set(openfst_SOURCE_DIR ${fc_base}/openfst-src CACHE PATH "OpenFST source directory") |
13 | | -set(openfst_PREFIX_DIR ${fc_base}/openfst-subbuild/openfst-populate-prefix CACHE PATH "OpenFST prefix directory") |
14 | | -ExternalProject_Add(openfst |
15 | | - URL https://github.com/mjansche/openfst/archive/1.7.2.zip |
16 | | - URL_HASH MD5=96656fee440ee2d71006a4900ef9ac00 |
17 | | - PREFIX ${openfst_PREFIX_DIR} |
18 | | - SOURCE_DIR ${openfst_SOURCE_DIR} |
19 | | - CONFIGURE_COMMAND ${openfst_SOURCE_DIR}/configure ${CONFIG_FLAGS} --enable-far --prefix=${openfst_PREFIX_DIR} |
20 | | - "CPPFLAGS=-I${gflags_BINARY_DIR}/include -I${glog_SOURCE_DIR}/src -I${glog_BINARY_DIR}" |
21 | | - "LDFLAGS=-L${gflags_BINARY_DIR} -L${glog_BINARY_DIR}" |
22 | | - "LIBS=-lgflags_nothreads -lglog -lpthread" |
23 | | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${openfst_SOURCE_DIR} |
24 | | - BUILD_COMMAND make -j$(nproc) |
| 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 | + PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/openfst ${openfst_SOURCE_DIR} |
25 | 32 | ) |
26 | | -add_dependencies(openfst gflags glog) |
27 | | -link_directories(${openfst_PREFIX_DIR}/lib) |
| 33 | +FetchContent_MakeAvailable(openfst) |
| 34 | +add_dependencies(fst gflags glog) |
| 35 | +target_link_libraries(fst PUBLIC gflags_nothreads_static glog) |
28 | 36 | include_directories(${openfst_SOURCE_DIR}/src/include) |
0 commit comments