forked from flashlight/wav2letter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
164 lines (135 loc) · 3.79 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.5.1)
project(wav2letter++)
# ----------------------------- Setup -----------------------------
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ----------------------------- Configuration -----------------------------
# Build tests
option(W2L_BUILD_TESTS "Build tests for wav2letter++" ON)
if (W2L_BUILD_TESTS)
enable_testing()
add_subdirectory(${CMAKE_SOURCE_DIR}/src/tests)
endif ()
# Build examples
option(W2L_BUILD_EXAMPLES "Build examples for wav2letter++" ON)
# ------------------------ Global External Dependencies ------------------------
# ArrayFire
# The correct ArrayFire backend target is transitively included by flashlight
find_package(ArrayFire 3.6.1 REQUIRED)
if (ArrayFire_FOUND)
message(STATUS "ArrayFire found (include: ${ArrayFire_INCLUDE_DIRS}, library: ${ArrayFire_LIBRARIES})")
else()
message(FATAL_ERROR "ArrayFire not found")
endif()
# Find GLog
find_package(GLOG REQUIRED)
if (GLOG_FOUND)
message(STATUS "GLOG found")
else()
message(FATAL_ERROR "GLOG not found")
endif()
# Find GFlags
find_package(GFLAGS REQUIRED)
if (GFLAGS_FOUND)
message(STATUS "GFLAGS found")
else()
message(FATAL_ERROR "GFLAGS not found")
endif()
# Find and setup OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
message(STATUS "OpenMP found")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}"
)
else()
message(STATUS "OpenMP not found - building without OpenMP")
endif()
# ------------------------ flashlight ------------------------
find_package(flashlight REQUIRED)
if (flashlight_FOUND)
message(STATUS "flashlight found (include: ${FLASHLIGHT_INCLUDE_DIRS} lib: flashlight::flashlight )")
if (NOT TARGET flashlight::Distributed)
message(FATAL_ERROR "flashlight must be build in distributed mode for wav2letter++")
else ()
message(STATUS "flashlight built in distributed mode.")
endif ()
if (NOT TARGET flashlight::Contrib)
message(FATAL_ERROR "flashlight must be built with contrib features for wav2letter++")
else ()
message(STATUS "flashlight built with contrib features.")
endif ()
else()
message(FATAL_ERROR "flashlight not found.")
endif ()
# ------------------------ Components ------------------------
# Common
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/common)
# Feature
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/feature)
# Runtime
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime)
# Module
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/module)
# Decoder
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/decoder)
# Criterion
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/criterion)
# Data
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/data)
# ----------------------------- wav2letter++ lib -----------------------------
add_library(
wav2letter++
""
)
set_target_properties(
wav2letter++
PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 11
)
target_link_libraries(
wav2letter++
PUBLIC
common
criterion
decoder
module
runtime
)
target_include_directories(
wav2letter++
PUBLIC
${CMAKE_SOURCE_DIR}/src # all includes are based at src/
${FLASHLIGHT_INCLUDE_DIRS} # includes are <flashlight/...>
)
# ----------------------------- Train -----------------------------
add_executable(
Train
Train.cpp
)
target_link_libraries(
Train
wav2letter++
)
# ----------------------------- Test -----------------------------
add_executable(
Test
Test.cpp
)
target_link_libraries(
Test
wav2letter++
)
# ----------------------------- Decoder -----------------------------
add_executable(
Decoder
Decode.cpp
)
target_link_libraries(
Decoder
wav2letter++
)