You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
5.0 KiB
149 lines
5.0 KiB
3 years ago
|
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||
|
|
||
3 years ago
|
set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/EnableCMP0048.cmake")
|
||
|
|
||
2 years ago
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||
|
|
||
|
include(system)
|
||
|
|
||
|
# Ninja Generator will set CMAKE_BUILD_TYPE to Debug
|
||
|
if(NOT CMAKE_BUILD_TYPE)
|
||
|
set(CMAKE_BUILD_TYPE
|
||
|
"Release"
|
||
|
CACHE
|
||
|
STRING
|
||
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
|
||
|
FORCE)
|
||
|
endif()
|
||
|
|
||
|
project(paddlespeech VERSION 0.1)
|
||
|
|
||
3 years ago
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||
3 years ago
|
|
||
3 years ago
|
# set std-14
|
||
|
set(CMAKE_CXX_STANDARD 14)
|
||
|
|
||
|
include(FetchContent)
|
||
|
include(ExternalProject)
|
||
3 years ago
|
|
||
3 years ago
|
# fc_patch dir
|
||
|
set(FETCHCONTENT_QUIET off)
|
||
|
get_filename_component(fc_patch "fc_patch" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||
|
set(FETCHCONTENT_BASE_DIR ${fc_patch})
|
||
|
|
||
3 years ago
|
# compiler option
|
||
3 years ago
|
# Keep the same with openfst, -fPIC or -fpic
|
||
2 years ago
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g -ldl")
|
||
3 years ago
|
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g -ggdb")
|
||
|
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O3 -Wall")
|
||
|
|
||
3 years ago
|
###############################################################################
|
||
|
# Option Configurations
|
||
|
###############################################################################
|
||
|
option(TEST_DEBUG "option for debug" OFF)
|
||
2 years ago
|
option(USE_PROFILING "enable c++ profling" OFF)
|
||
2 years ago
|
option(WITH_TESTING "unit test" ON)
|
||
3 years ago
|
|
||
2 years ago
|
option(USING_GPU "u2 compute on GPU." OFF)
|
||
3 years ago
|
|
||
|
###############################################################################
|
||
|
# Include third party
|
||
|
###############################################################################
|
||
3 years ago
|
include(gflags)
|
||
|
|
||
|
include(glog)
|
||
|
|
||
3 years ago
|
# openfst
|
||
3 years ago
|
include(openfst)
|
||
3 years ago
|
add_dependencies(openfst gflags glog)
|
||
3 years ago
|
|
||
3 years ago
|
# paddle lib
|
||
2 years ago
|
include(paddleinference)
|
||
3 years ago
|
|
||
2 years ago
|
# gtest
|
||
|
if(WITH_TESTING)
|
||
|
include(gtest) # download, build, install gtest
|
||
|
endif()
|
||
|
|
||
2 years ago
|
# python/pybind11/threads
|
||
2 years ago
|
find_package(Threads REQUIRED)
|
||
2 years ago
|
# https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||
|
find_package(Python3 COMPONENTS Interpreter Development)
|
||
2 years ago
|
find_package(pybind11 CONFIG)
|
||
|
|
||
2 years ago
|
if(Python3_FOUND)
|
||
|
message(STATUS "Python3_FOUND = ${Python3_FOUND}")
|
||
|
message(STATUS "Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
|
||
|
message(STATUS "Python3_LIBRARIES = ${Python3_LIBRARIES}")
|
||
|
message(STATUS "Python3_INCLUDE_DIRS = ${Python3_INCLUDE_DIRS}")
|
||
|
message(STATUS "Python3_LINK_OPTIONS = ${Python3_LINK_OPTIONS}")
|
||
|
set(PYTHON_LIBRARIES ${Python3_LIBRARIES} CACHE STRING "python lib" FORCE)
|
||
|
set(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS} CACHE STRING "python inc" FORCE)
|
||
|
endif()
|
||
|
|
||
2 years ago
|
message(STATUS "PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
|
||
2 years ago
|
message(STATUS "PYTHON_INCLUDE_DIR = ${PYTHON_INCLUDE_DIR}")
|
||
|
|
||
|
if(pybind11_FOUND)
|
||
|
message(STATUS "pybind11_INCLUDES = ${pybind11_INCLUDE_DIRS}")
|
||
|
message(STATUS "pybind11_LIBRARIES=${pybind11_LIBRARIES}")
|
||
|
message(STATUS "pybind11_DEFINITIONS=${pybind11_DEFINITIONS}")
|
||
|
endif()
|
||
|
|
||
2 years ago
|
|
||
2 years ago
|
# paddle libpaddle.so
|
||
2 years ago
|
# paddle include and link option
|
||
2 years ago
|
# -L/workspace/DeepSpeech-2.x/engine/venv/lib/python3.7/site-packages/paddle/libs -L/workspace/DeepSpeech-2.x/speechx/venv/lib/python3.7/site-packages/paddle/fluid -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so
|
||
2 years ago
|
execute_process(
|
||
2 years ago
|
COMMAND python -c "\
|
||
|
import os;\
|
||
|
import paddle;\
|
||
|
include_dir=paddle.sysconfig.get_include();\
|
||
|
paddle_dir=os.path.split(include_dir)[0];\
|
||
|
libs_dir=os.path.join(paddle_dir, 'libs');\
|
||
|
fluid_dir=os.path.join(paddle_dir, 'fluid');\
|
||
|
out=' '.join([\"-L\" + libs_dir, \"-L\" + fluid_dir]);\
|
||
|
out += \" -l:libpaddle.so -l:libdnnl.so.2 -l:libiomp5.so\"; print(out);\
|
||
|
"
|
||
2 years ago
|
OUTPUT_VARIABLE PADDLE_LINK_FLAGS
|
||
|
RESULT_VARIABLE SUCESS)
|
||
|
|
||
|
message(STATUS PADDLE_LINK_FLAGS= ${PADDLE_LINK_FLAGS})
|
||
|
string(STRIP ${PADDLE_LINK_FLAGS} PADDLE_LINK_FLAGS)
|
||
|
|
||
|
# paddle compile option
|
||
2 years ago
|
# -I/workspace/DeepSpeech-2.x/engine/venv/lib/python3.7/site-packages/paddle/include
|
||
2 years ago
|
execute_process(
|
||
2 years ago
|
COMMAND python -c "\
|
||
|
import paddle; \
|
||
|
include_dir = paddle.sysconfig.get_include(); \
|
||
|
print(f\"-I{include_dir}\"); \
|
||
|
"
|
||
2 years ago
|
OUTPUT_VARIABLE PADDLE_COMPILE_FLAGS)
|
||
|
message(STATUS PADDLE_COMPILE_FLAGS= ${PADDLE_COMPILE_FLAGS})
|
||
|
string(STRIP ${PADDLE_COMPILE_FLAGS} PADDLE_COMPILE_FLAGS)
|
||
|
|
||
|
|
||
|
# for LD_LIBRARY_PATH
|
||
|
# set(PADDLE_LIB_DIRS /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/fluid:/workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/paddle/libs/)
|
||
|
execute_process(
|
||
2 years ago
|
COMMAND python -c "\
|
||
2 years ago
|
import os; \
|
||
|
import paddle; \
|
||
|
include_dir=paddle.sysconfig.get_include(); \
|
||
|
paddle_dir=os.path.split(include_dir)[0]; \
|
||
|
libs_dir=os.path.join(paddle_dir, 'libs'); \
|
||
|
fluid_dir=os.path.join(paddle_dir, 'fluid'); \
|
||
|
out=':'.join([libs_dir, fluid_dir]); print(out); \
|
||
|
"
|
||
2 years ago
|
OUTPUT_VARIABLE PADDLE_LIB_DIRS)
|
||
|
message(STATUS PADDLE_LIB_DIRS= ${PADDLE_LIB_DIRS})
|
||
|
|
||
|
|
||
3 years ago
|
###############################################################################
|
||
|
# Add local library
|
||
|
###############################################################################
|
||
2 years ago
|
set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/engine)
|
||
3 years ago
|
|
||
2 years ago
|
add_subdirectory(engine)
|