CMakeLists.txt 2.01 KB
Newer Older
moto's avatar
moto committed
1
2
3
4
5
# kenlm uses std::binary_function, which had BC breaking change in C++17.
# On Windows + GPU, torchaudio is compiled with C++ 17 globally.
# We use C++ 14 for KenLM
set(CMAKE_CXX_STANDARD 14)

moto's avatar
moto committed
6
7
set(
  KENLM_UTIL_SOURCES
moto's avatar
moto committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  kenlm/util/bit_packing.cc
  kenlm/util/double-conversion/bignum.cc
  kenlm/util/double-conversion/bignum-dtoa.cc
  kenlm/util/double-conversion/cached-powers.cc
  kenlm/util/double-conversion/diy-fp.cc
  kenlm/util/double-conversion/double-conversion.cc
  kenlm/util/double-conversion/fast-dtoa.cc
  kenlm/util/double-conversion/fixed-dtoa.cc
  kenlm/util/double-conversion/strtod.cc
  kenlm/util/ersatz_progress.cc
  kenlm/util/exception.cc
  kenlm/util/file.cc
  kenlm/util/file_piece.cc
  kenlm/util/float_to_string.cc
  kenlm/util/integer_to_string.cc
  kenlm/util/mmap.cc
  kenlm/util/murmur_hash.cc
  kenlm/util/pool.cc
  kenlm/util/read_compressed.cc
  kenlm/util/scoped.cc
  kenlm/util/spaces.cc
  kenlm/util/string_piece.cc
moto's avatar
moto committed
30
31
32
33
  )

set(
  KENLM_SOURCES
moto's avatar
moto committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  kenlm/lm/bhiksha.cc
  kenlm/lm/binary_format.cc
  kenlm/lm/config.cc
  kenlm/lm/lm_exception.cc
  kenlm/lm/model.cc
  kenlm/lm/quantize.cc
  kenlm/lm/read_arpa.cc
  kenlm/lm/search_hashed.cc
  kenlm/lm/search_trie.cc
  kenlm/lm/trie.cc
  kenlm/lm/trie_sort.cc
  kenlm/lm/value_build.cc
  kenlm/lm/virtual_interface.cc
  kenlm/lm/vocab.cc
moto's avatar
moto committed
48
49
50
51
52
53
54
55
56
57
58
  )

add_library(
  kenlm
  STATIC
  "${KENLM_UTIL_SOURCES};${KENLM_SOURCES}"
  )

target_include_directories(
  kenlm
  BEFORE
moto's avatar
moto committed
59
  PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
moto's avatar
moto committed
60
61
  )

moto's avatar
moto committed
62
63
64
65
66
67
68
69
70
set(
  kenlm_deps
  zlib
  bzip2
  )

set(
  kenlm_compiler_definitions
  KENLM_MAX_ORDER=6
moto's avatar
moto committed
71
72
  HAVE_ZLIB
  HAVE_BZLIB
moto's avatar
moto committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  )

if (MSVC)
  list(
    APPEND
    kenlm_compiler_definitions
    # To avoid warning C4003: not enough arguments for function-like macro invocation 'max'
    NOMINMAX
    )
endif()

if(TARGET lzma)
  list(APPEND kenlm_deps lzma)
  list(
    APPEND
    kenlm_compiler_definitions
    HAVE_XZLIB
    )
endif()

target_compile_definitions(
  kenlm
  PUBLIC
  ${kenlm_compiler_definitions}
moto's avatar
moto committed
97
98
99
100
  )

target_link_libraries(
  kenlm
moto's avatar
moto committed
101
  PRIVATE
moto's avatar
moto committed
102
  ${kenlm_deps}
moto's avatar
moto committed
103
)