-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
106 lines (94 loc) · 4.26 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.18)
project(_kalpy)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
if(KALDI_ROOT)
message(STATUS "Adding KALDI_ROOT directories: ${KALDI_ROOT}")
set(CMAKE_INCLUDE_PATH "${KALDI_ROOT}/include")
set(CMAKE_LIBRARY_PATH "${KALDI_ROOT}/lib")
link_directories("${KALDI_ROOT}/lib")
include_directories("${KALDI_ROOT}/include")
include_directories("${KALDI_ROOT}/include/kaldi")
if (NOT CUDA_TOOLKIT_ROOT_DIR)
set(CUDA_TOOLKIT_ROOT_DIR "${KALDI_ROOT}")
endif()
endif()
add_definitions(-DKALDI_NO_PORTAUDIO=1)
if (MSVC)
find_package(dlfcn-win32 REQUIRED)
set(CMAKE_DL_LIBS dlfcn-win32::dl)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_definitions(-D_USE_MATH_DEFINES)
add_compile_options(/permissive- /FS /wd4819 /EHsc /bigobj)
# some warnings related with fst
add_compile_options(/wd4018 /wd4244 /wd4267 /wd4291 /wd4305)
elseif(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib;$ORIGIN/../../tools/openfst/lib")
endif ()
find_package(CUDAToolkit)
find_package(pybind11 REQUIRED)
include_directories(extensions)
pybind11_add_module(_kalpy extensions/_kalpy.cpp
extensions/chain/chain.cpp
extensions/cudamatrix/cudamatrix.cpp
extensions/decoder/decoder.cpp
extensions/feat/feat.cpp
extensions/fstext/fstext.cpp
extensions/gmm/gmm.cpp
extensions/hmm/hmm.cpp
extensions/itf/itf.cpp
extensions/ivector/ivector.cpp
extensions/kws/kws.cpp
extensions/lat/lat.cpp
extensions/lm/lm.cpp
#extensions/rnnlm/rnnlm.cpp
extensions/online/online.cpp
extensions/online2/online2.cpp
extensions/matrix/matrix.cpp
extensions/nnet/nnet.cpp
extensions/nnet2/nnet2.cpp
extensions/nnet3/nnet3.cpp
extensions/transform/transform.cpp
extensions/tree/tree.cpp
extensions/util/util.cpp
)
target_link_libraries(_kalpy PUBLIC kaldi-base kaldi-chain
kaldi-matrix
kaldi-cudamatrix
kaldi-hmm
kaldi-online kaldi-online2 kaldi-rnnlm
kaldi-nnet3
kaldi-nnet2 kaldi-nnet
kaldi-kws
kaldi-decoder
kaldi-lat
kaldi-nnet3
kaldi-nnet2 kaldi-nnet
kaldi-ivector kaldi-lm
kaldi-fstext kaldi-feat
kaldi-transform kaldi-gmm
kaldi-tree
kaldi-util
fst
fstscript
)
if (CUDAToolkit_FOUND)
find_library(KALDI_CUDADECODER kaldi-cudadecoder)
if(KALDI_CUDADECODER)
target_link_libraries(_kalpy PUBLIC kaldi-cudadecoder kaldi-cudafeat
)
endif()
endif()
if(MSVC)
set_target_properties(_kalpy PROPERTIES
DEFINE_SYMBOL "KALDI_DLL_IMPORTS"
"KALDI_CUMATRIX_DLL_IMPORTS"
"KALDI_UTIL_DLL_IMPORTS")
endif(MSVC)