diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ce74d8..7ee1a14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,42 +1,24 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR) -project(wenet VERSION 0.2) -# set color -string(ASCII 27 Esc) -set(ColourReset "${Esc}[m") -set(BoldGreen "${Esc}[1;32m") -set(BoldRed "${Esc}[31m") -# 运行参数 +project(wenet VERSION 0.1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -fPIC -w") set(LIB_BASE_DIR /root/CXX_ENVS/wenet_runtime) -set(third_party_libraries) -option(GRPC "whether to build with gRPC" ON) -option(ONNX "whether to build with ONNX" ON) - list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-linux) -# Model Option -if(ONNX) - include(onnx) -endif() - +include(onnx) include(openfst) -#wenet个人项目内容 include_directories( ${OPENFST_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/kaldi ) -# Build all libraries + add_subdirectory(utils) add_subdirectory(frontend) add_subdirectory(post_processor) add_subdirectory(kaldi) # kaldi: add_subdirectory(decoder) -# Connection Option -if(GRPC) - add_subdirectory(grpc) -endif() +add_subdirectory(grpc) + -# Build all bins -add_subdirectory(bin) \ No newline at end of file diff --git a/CMakeLists.txt.bak b/CMakeLists.txt.bak new file mode 100644 index 0000000..8ce74d8 --- /dev/null +++ b/CMakeLists.txt.bak @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) + +project(wenet VERSION 0.2) +# set color +string(ASCII 27 Esc) +set(ColourReset "${Esc}[m") +set(BoldGreen "${Esc}[1;32m") +set(BoldRed "${Esc}[31m") +# 运行参数 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -fPIC -w") +set(LIB_BASE_DIR /root/CXX_ENVS/wenet_runtime) +set(third_party_libraries) +option(GRPC "whether to build with gRPC" ON) +option(ONNX "whether to build with ONNX" ON) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-linux) + +# Model Option +if(ONNX) + include(onnx) +endif() + +include(openfst) +#wenet个人项目内容 +include_directories( + ${OPENFST_INCLUDE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/kaldi +) +# Build all libraries +add_subdirectory(utils) +add_subdirectory(frontend) +add_subdirectory(post_processor) +add_subdirectory(kaldi) # kaldi: +add_subdirectory(decoder) +# Connection Option +if(GRPC) + add_subdirectory(grpc) +endif() + +# Build all bins +add_subdirectory(bin) \ No newline at end of file diff --git a/CMakeLists.txt1 b/CMakeLists.txt1 deleted file mode 100644 index 27041dd..0000000 --- a/CMakeLists.txt1 +++ /dev/null @@ -1,73 +0,0 @@ -cmake_minimum_required(VERSION 3.14 FATAL_ERROR) - -project(wenet VERSION 0.1) - -option(CXX11_ABI "whether to use CXX11_ABI libtorch" OFF) -option(GRAPH_TOOLS "whether to build TLG graph tools" OFF) -option(BUILD_TESTING "whether to build unit test" OFF) -option(GRPC "whether to build with gRPC" ON) -# TODO(Binbin Zhang): Change websocket to OFF since it depends on boost which is a very big library -# -option(WEBSOCKET "whether to build with websocket" OFF) -option(HTTP "whether to build with http" OFF) -option(TORCH "whether to build with Torch" OFF) -option(ONNX "whether to build with ONNX" ON) -option(GPU "whether to build with GPU" OFF) -option(ITN "whether to use WeTextProcessing" OFF) - -set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -g") -set(CMAKE_VERBOSE_MAKEFILE OFF) - -include(FetchContent) -set(FETCHCONTENT_QUIET OFF) -get_filename_component(fc_base "fc_base" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(FETCHCONTENT_BASE_DIR ${fc_base}) - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -if(NOT MSVC) - # Keep the same with openfst, -fPIC or -fpic - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -fPIC") -else() - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - add_compile_options("$<$:/utf-8>") -endif() - - -if(ONNX) - include(onnx) -endif() -# -include(openfst) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/kaldi -) - -if(ITN) - include(wetextprocessing) -endif() - -# Build all libraries -add_subdirectory(utils) -add_subdirectory(frontend) -add_subdirectory(post_processor) -add_subdirectory(kaldi) # kaldi: -add_subdirectory(decoder) - -# Optionally, you can build with websocket -if(WEBSOCKET) - include(boost) - add_subdirectory(websocket) -endif() - -# Optionally, you can build with gRPC -if(GRPC) - include(grpc) - add_subdirectory(grpc) -endif() - - - -# Build all bins -add_subdirectory(bin) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 2ca2dbe..3d6c0c4 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -1,11 +1,11 @@ -add_executable(decoder_main decoder_main.cc) -target_link_libraries(decoder_main PUBLIC decoder) -if(IPEX) - target_link_libraries(decoder_main PUBLIC "${TORCH_IPEX_LIBRARIES}") -endif() +#add_executable(decoder_main decoder_main.cc) +#target_link_libraries(decoder_main PUBLIC decoder ${GFLAGS_LIBRARY}) +#if(IPEX) +# target_link_libraries(decoder_main PUBLIC "${TORCH_IPEX_LIBRARIES}") +#endif() -add_executable(label_checker_main label_checker_main.cc) -target_link_libraries(label_checker_main PUBLIC decoder) +#add_executable(label_checker_main label_checker_main.cc) +#target_link_libraries(label_checker_main PUBLIC decoder ${GFLAGS_LIBRARY}) if(TORCH) add_executable(api_main api_main.cc) diff --git a/cmake-linux/onnx.cmake b/cmake-linux/onnx.cmake index 13abf0a..c55525d 100644 --- a/cmake-linux/onnx.cmake +++ b/cmake-linux/onnx.cmake @@ -2,8 +2,5 @@ set(onnxruntime_SOURCE_DIR ${LIB_BASE_DIR}/onnxruntime-src) include_directories(${onnxruntime_SOURCE_DIR}/include) -link_directories(${onnxruntime_SOURCE_DIR}/lib) -list(APPEND third_party_libraries onnxruntime) - -add_definitions(-DUSE_ONNX) \ No newline at end of file +find_library(ONNX_LIBRARY NAMES onnxruntime PATHS ${onnxruntime_SOURCE_DIR}/lib NO_DEFAULT_PATH) \ No newline at end of file diff --git a/grpc/CMakeLists.txt b/grpc/CMakeLists.txt index 0dc2fa8..c9af38f 100644 --- a/grpc/CMakeLists.txt +++ b/grpc/CMakeLists.txt @@ -2,26 +2,24 @@ set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}") include(../cmake-linux/grpc.cmake) - +get_target_property(PROTOC_LOCATION ${PROTOBUF_PROTOC} LOCATION) add_custom_command( OUTPUT ${PROTO_DIR}/wenet.pb.cc ${PROTO_DIR}/wenet.pb.h ${PROTO_DIR}/wenet.grpc.pb.cc ${PROTO_DIR}/wenet.grpc.pb.h - COMMAND ${CMAKE_COMMAND} -E echo "PROTOBUF_PROTOC is set to: ${PROTOBUF_PROTOC}" - COMMAND ${PROTOBUF_PROTOC} + COMMAND ${PROTOC_LOCATION} ARGS --grpc_out "${PROTO_DIR}" - --cpp_out "${PROTO_DIR}" - -I "${PROTO_DIR}" - --plugin=protoc-gen-grpc=${GRPC_BINARY_DIR}/grpc_cpp_plugin - wenet.proto) + --cpp_out "${PROTO_DIR}" + -I "${PROTO_DIR}" + --plugin=protoc-gen-grpc=${GRPC_BINARY_DIR}/grpc_cpp_plugin + ${PROTO_DIR}/wenet.proto) add_library(wenet_grpc STATIC grpc_client.cc grpc_server.cc wenet.pb.cc wenet.grpc.pb.cc) -message(STATUS "REFLECTION: ${REFLECTION}") target_link_libraries(wenet_grpc PUBLIC ${REFLECTION} ${GRPC_GRPCPP} - ${PROTOBUF_LIBPROTOBUF} decoder ${GFLAGS_LIBRARY_NOTHREADS}) + ${PROTOBUF_LIBPROTOBUF} ${GFLAGS_LIBRARY} decoder) diff --git a/kaldi/CMakeLists.txt b/kaldi/CMakeLists.txt index 50121f6..a6df721 100644 --- a/kaldi/CMakeLists.txt +++ b/kaldi/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(kaldi-util util/simple-io-funcs.cc util/text-utils.cc ) -target_link_libraries(kaldi-util PUBLIC utils) +target_link_libraries(kaldi-util PUBLIC fst dl) add_library(kaldi-decoder lat/determinize-lattice-pruned.cc