-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
133 lines (120 loc) · 3.19 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
cmake_minimum_required(VERSION 3.1)
project(pytorch_android_cpp_demo)
set(CMAKE_CXX_STANDARD 14)
if(ANDROID_ABI)
list(APPEND CMAKE_FIND_ROOT_PATH ${PYTORCH_ANDROID_PATH})
message(STATUS "Using PyTorch Android library:" ${PYTORCH_ANDROID_PATH})
endif()
# Find torch library
find_package(Torch REQUIRED)
# Main executable
include_directories("./")
#add_executable(Predictor predictor.cpp)
add_executable(Predictor test.cc kaldi_io.cc fft.cc wave_reader.cc recognizer_impl.cc wrapper_recognizer.cc)
target_include_directories(Predictor PUBLIC ${TORCH_INCLUDE_DIRS})
# include_directories("./")
# add_executable(Test test.cc kaldi_io.cc)
# target_include_directories(Test PUBLIC ${TORCH_INCLUDE_DIRS})
find_package(Threads REQUIRED)
if(ANDROID_ABI)
find_library(Log log)
endif()
target_link_libraries(Predictor
-Wl,-s
-Wl,--gc-sections
-Wl,--whole-archive
${TORCH_LIBRARIES}
-Wl,--no-whole-archive
Threads::Threads
${Log}
-std=c++11
)
add_library(e2e SHARED kaldi_io.cc fft.cc wave_reader.cc recognizer_impl.cc wrapper_recognizer.cc)
target_include_directories(e2e PUBLIC ${TORCH_INCLUDE_DIRS})
target_link_libraries( e2e
-Wl,-s
-Wl,--gc-sections
-Wl,--whole-archive
${TORCH_LIBRARIES}
-Wl,--no-whole-archive
Threads::Threads
${Log}
-std=c++11
)
# this will generate a libe2d_jni.so
# copy this to jnilibs folder
add_library(e2e_jni SHARED e2e.cpp fft.cc recognizer_impl.cc wrapper_recognizer.cc)
target_include_directories(e2e_jni PUBLIC ${TORCH_INCLUDE_DIRS})
target_link_libraries( e2e_jni
-Wl,-s
-Wl,--gc-sections
-Wl,--whole-archive
${TORCH_LIBRARIES}
-Wl,--no-whole-archive
Threads::Threads
${Log}
-std=c++11
)
add_library(static_e2e STATIC kaldi_io.cc fft.cc wave_reader.cc recognizer_impl.cc wrapper_recognizer.cc)
target_include_directories(static_e2e PUBLIC ${TORCH_INCLUDE_DIRS})
target_link_libraries( static_e2e
-Wl,-s
-Wl,--gc-sections
-Wl,--whole-archive
${TORCH_LIBRARIES}
-Wl,--no-whole-archive
Threads::Threads
${Log}
-std=c++11
)
#link_directories("/home/lyguo/github/pytorch-android-cpp-demo/build/libe2e.so")
#link_libraries("/home/lyguo/github/pytorch-android-cpp-demo/${BUILD_ROOT}build_android/libe2e.so")
message("build_root: "${BUILD_ROOT})
link_libraries(${BUILD_ROOT}/libe2e.so)
add_executable(dynamic_Predictor test.cc wave_reader.cc)
#target_include_directories(dynamic_Predictor PUBLIC ${TORCH_INCLUDE_DIRS})
target_link_libraries(dynamic_Predictor
e2e
#-Wl,--whole-archive
${TORCH_LIBRARIES}
#-Wl,--no-whole-archive
#Threads::Threads
#pthread
${Log}
-std=c++11
)
# target_link_libraries(dynamic_Predictor
# e2e
# -Wl,-s
# -Wl,--gc-sections
# -Wl,--whole-archive
# ${TORCH_LIBRARIES}
# -Wl,--no-whole-archive
# Threads::Threads
# ${Log}
# -std=c++11
# )
# # The linker flags will be moved to TorchConfig.cmake
# if(APPLE)
# target_link_libraries(Predictor
# -Wl,-s
# -Wl,-dead_strip
# -Wl,-all_load
# ${TORCH_LIBRARIES}
# -Wl,-noall_load
# Threads::Threads
# ${Log}
# -std=c++11
# )
# else()
# target_link_libraries(Predictor
# -Wl,-s
# -Wl,--gc-sections
# -Wl,--whole-archive
# ${TORCH_LIBRARIES}
# -Wl,--no-whole-archive
# Threads::Threads
# ${Log}
# -std=c++11
# )
# endif()