liugz18
2024-07-18 d80ac2fd2df4e7fb8a28acfa512bb11472b5cc99
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
 
include_directories(${PROJECT_SOURCE_DIR})
set(sources
  feature-fbank.cc
  feature-functions.cc
  feature-window.cc
  fftsg.c
  mel-computations.cc
  online-feature.cc
  rfft.cc
)
 
if(KALDI_NATIVE_FBANK_ENABLE_CHECK)
  list(APPEND sources log.cc)
endif()
 
add_library(kaldi-native-fbank-core ${sources})
if(KALDI_NATIVE_FBANK_ENABLE_CHECK)
  target_compile_definitions(kaldi-native-fbank-core PUBLIC KNF_ENABLE_CHECK=1)
 
  if(KNF_HAVE_EXECINFO_H)
    target_compile_definitions(kaldi-native-fbank-core PRIVATE KNF_HAVE_EXECINFO_H=1)
  endif()
 
  if(KNF_HAVE_CXXABI_H)
    target_compile_definitions(kaldi-native-fbank-core PRIVATE KNF_HAVE_CXXABI_H=1)
  endif()
endif()
 
# We are using std::call_once() in log.h,which requires us to link with -pthread
if(NOT WIN32 AND KALDI_NATIVE_FBANK_ENABLE_CHECK)
  target_link_libraries(kaldi-native-fbank-core -pthread)
endif()
 
if(KALDI_NATIVE_FBANK_BUILD_TESTS)
  add_executable(test-online-fbank test-online-fbank.cc)
  target_link_libraries(test-online-fbank kaldi-native-fbank-core)
endif()
 
function(kaldi_native_fbank_add_test source)
  get_filename_component(name ${source} NAME_WE)
  add_executable(${name} "${source}")
  target_link_libraries(${name}
    PRIVATE
      kaldi-native-fbank-core
      gtest
      gtest_main
  )
 
  add_test(NAME "Test.${name}"
    COMMAND
    $<TARGET_FILE:${name}>
  )
endfunction()
 
# please sort the source files alphabetically
set(test_srcs
  # test-online-feature.cc
  test-log.cc
  test-rfft.cc
)
 
if(KALDI_NATIVE_FBANK_BUILD_TESTS)
  foreach(source IN LISTS test_srcs)
    kaldi_native_fbank_add_test(${source})
  endforeach()
endif()
 
install(TARGETS kaldi-native-fbank-core
  DESTINATION lib
)
 
if(KALDI_NATIVE_FBANK_BUILD_TESTS)
  install(TARGETS test-online-fbank
    DESTINATION bin
  )
endif()
 
file(MAKE_DIRECTORY
  DESTINATION
    ${PROJECT_BINARY_DIR}/include/kaldi-native-fbank/csrc
)
file(GLOB_RECURSE all_headers *.h)
 
file(COPY
  ${all_headers}
  DESTINATION
    ${PROJECT_BINARY_DIR}/include/kaldi-native-fbank/csrc
)
 
install(FILES ${all_headers}
  DESTINATION include/kaldi-native-fbank/csrc
)