-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
141 lines (119 loc) · 3.37 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# For licensing see accompanying LICENSE file.
# Copyright © 2024 Argmax, Inc. All rights reserved.
cmake_minimum_required(VERSION 3.22.1)
# project name and language
project(whisperax LANGUAGES CXX)
if (NOT DEFINED TENSORFLOW_SOURCE_DIR)
message(FATAL_ERROR "TensorFlow path is not defined. Please use cmake -DTENSORFLOW_SOURCE_DIR=/path/to/tensorflow")
endif()
set(CMAKE_CXX_STANDARD 23)
set(COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_BUILD_TYPE Release)
set(AXIE_SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(AXIE_INC_DIR ${CMAKE_SOURCE_DIR}/inc)
set(AXIE_CLI_DIR ${CMAKE_SOURCE_DIR}/cli)
if(${ANDROID})
message(NOTICE "Config build for Android ARM64..")
set(CMAKE_TOOLCHAIN_FILE ${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake)
set(ANDROID_ABI arm64-v8a)
set(AXIE_LIB_DIR ${CMAKE_SOURCE_DIR}/libs/android)
find_library(android_log log)
else()
message(NOTICE "Config build for x86_64..")
set(AXIE_LIB_DIR ${CMAKE_SOURCE_DIR}/libs/x86)
endif()
add_subdirectory(
"${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite"
EXCLUDE_FROM_ALL
)
link_directories(
${AXIE_LIB_DIR}
)
# build top library: whisperax
if(${ANDROID})
if(${QNN_DELEGATE}) # QCOM QNN delegate
message(NOTICE " Delegate via QCOM QNN..")
add_library(whisperax SHARED
${AXIE_SRC_DIR}/tflite_model.cpp
${AXIE_SRC_DIR}/tflite_qnn_model.cpp
${AXIE_SRC_DIR}/post_proc.cpp
${AXIE_SRC_DIR}/audio_input.cpp
${AXIE_SRC_DIR}/whisperax.cpp
)
else() # generic TFLite GPU delegate
message(NOTICE " Delegate via Generic TFLite GPU..")
add_library(whisperax SHARED
${AXIE_SRC_DIR}/tflite_model.cpp
${AXIE_SRC_DIR}/tflite_gpu_model.cpp
${AXIE_SRC_DIR}/post_proc.cpp
${AXIE_SRC_DIR}/audio_input.cpp
${AXIE_SRC_DIR}/whisperax.cpp
)
endif()
else() # other generic arch, CPU only
message(NOTICE " Generic CPU only..")
add_library(whisperax SHARED
${AXIE_SRC_DIR}/tflite_model.cpp
${AXIE_SRC_DIR}/post_proc.cpp
${AXIE_SRC_DIR}/audio_input.cpp
${AXIE_SRC_DIR}/whisperax.cpp
)
endif()
target_include_directories(whisperax PRIVATE
${AXIE_INC_DIR}
)
if(${ANDROID})
if(${QNN_DELEGATE})
ADD_DEFINITIONS(-DQNN_DELEGATE)
add_library(qnn_delegate SHARED IMPORTED)
set_property(TARGET qnn_delegate PROPERTY IMPORTED_LOCATION
${AXIE_LIB_DIR}/libQnnTFLiteDelegate.so
)
target_link_libraries(whisperax PRIVATE
qnn_delegate
tensorflow-lite
tensorflowlite_gpu_delegate
${android_log}
SDL3
)
else()
ADD_DEFINITIONS(-DGPU_DELEGATE)
target_link_libraries(whisperax PRIVATE
tensorflow-lite
tensorflowlite_gpu_delegate
${android_log}
SDL3
)
endif()
else()
target_link_libraries(whisperax PRIVATE
tensorflow-lite
SDL3
)
endif()
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# build CLI: whisperax_cli
add_executable(whisperax_cli
${AXIE_CLI_DIR}/whisperax_cli.cpp
${AXIE_CLI_DIR}/audio_codec.cpp
)
target_include_directories(whisperax_cli PRIVATE
${AXIE_INC_DIR}
${AXIE_CLI_DIR}
)
target_link_libraries(whisperax_cli PRIVATE
whisperax
avformat
avcodec
avutil
swresample
)
target_compile_definitions(whisperax_cli PRIVATE
"-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\""
)