@@ -37,22 +37,24 @@ if(NOT MSVC)
3737endif (NOT MSVC )
3838
3939#############################CMAKE FOR FASTDEPLOY################################
40- option (ENABLE_PADDLE_FRONTEND "if to enable PaddlePaddle frontend to support load paddle model in fastdeploy." ON )
41- option (WITH_GPU "if WITH_GPU=ON, will enable onnxruntime-gpu/paddle-infernce-gpu" OFF )
42- option (ENABLE_ORT_BACKEND "if to enable onnxruntime backend." OFF )
43- option (ENABLE_TRT_BACKEND "if to enable tensorrt backend." OFF )
44- option (ENABLE_PADDLE_BACKEND "if to enable paddle backend." OFF )
45- option (CUDA_DIRECTORY "if build tensorrt backend, need to define path of cuda library." )
46- option (TRT_DIRECTORY "if build tensorrt backend, need to define path of tensorrt library." )
47- option (ENABLE_VISION "if to enable vision models usage." OFF )
48- option (ENABLE_VISION_VISUALIZE "if to enable visualize vision model result toolbox." ON )
40+ option (ENABLE_PADDLE_FRONTEND "Whether to enable PaddlePaddle frontend to support load paddle model in fastdeploy." ON )
41+ option (WITH_GPU "Whether WITH_GPU=ON, will enable onnxruntime-gpu/paddle-infernce-gpu" OFF )
42+ option (ENABLE_ORT_BACKEND "Whether to enable onnxruntime backend." OFF )
43+ option (ENABLE_TRT_BACKEND "Whether to enable tensorrt backend." OFF )
44+ option (ENABLE_PADDLE_BACKEND "Whether to enable paddle backend." OFF )
45+ option (CUDA_DIRECTORY "If build tensorrt backend, need to define path of cuda library." )
46+ option (TRT_DIRECTORY "If build tensorrt backend, need to define path of tensorrt library." )
47+ option (ENABLE_VISION "Whether to enable vision models usage." OFF )
48+ option (ENABLE_VISION_VISUALIZE "Whether to enable visualize vision model result toolbox." ON )
49+ option (ENABLE_TEXT "Whether to enable text models usage." OFF )
4950
5051# Please don't open this flag now, some bugs exists.
51- option (ENABLE_OPENCV_CUDA "if to enable opencv with cuda, this will allow process image with GPU." OFF )
52- option (ENABLE_DEBUG "if to enable print debug information, this may reduce performance." OFF )
52+ option (ENABLE_OPENCV_CUDA "Whether to enable opencv with cuda, this will allow process image with GPU." OFF )
53+ option (ENABLE_DEBUG "Whether to enable print debug information, this may reduce performance." OFF )
5354
5455# Whether to build fastdeply with vision/text/... examples, only for testings.
5556option (WITH_VISION_EXAMPLES "Whether to build fastdeply with vision examples" OFF )
57+ option (WITH_TEXT_EXAMPLES "Whether to build fastdeply with text examples" OFF )
5658
5759# Check for 32bit system
5860if (WIN32 )
@@ -98,21 +100,29 @@ if (WITH_VISION_EXAMPLES AND EXISTS ${PROJECT_SOURCE_DIR}/examples)
98100 set (ENABLE_VISION_VISUALIZE ON CACHE BOOL "force to enable visualize vision model result toolbox" FORCE)
99101endif ()
100102
103+ if (WITH_TEXT_EXAMPLES AND EXISTS ${PROJECT_SOURCE_DIR} /examples)
104+ # ENABLE_TEXT must be ON if enable text examples.
105+ message (STATUS "Found WITH_TEXT_EXAMPLES ON, so, force ENABLE_TEXT ON" )
106+ set (ENABLE_TEXT ON CACHE BOOL "force to enable text models usage" FORCE)
107+ endif ()
108+
101109add_definitions (-DFASTDEPLOY_LIB)
102110file (GLOB_RECURSE ALL_DEPLOY_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/*.cc)
103111file (GLOB_RECURSE DEPLOY_ORT_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/backends/ort/*.cc)
104112file (GLOB_RECURSE DEPLOY_PADDLE_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/backends/paddle/*.cc)
105113file (GLOB_RECURSE DEPLOY_TRT_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/backends/tensorrt/*.cc ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/backends/tensorrt/*.cpp)
106114file (GLOB_RECURSE DEPLOY_VISION_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/vision/*.cc)
115+ file (GLOB_RECURSE DEPLOY_TEXT_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/text/*.cc)
107116file (GLOB_RECURSE DEPLOY_PYBIND_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/pybind/*.cc ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/*_pybind.cc)
108- list (REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS} ${DEPLOY_PADDLE_SRCS} ${DEPLOY_TRT_SRCS} ${DEPLOY_VISION_SRCS} )
117+ list (REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS} ${DEPLOY_PADDLE_SRCS} ${DEPLOY_TRT_SRCS} ${DEPLOY_VISION_SRCS} ${DEPLOY_TEXT_SRCS} )
109118
110119set (DEPEND_LIBS "" )
111120
112121file (READ "${PROJECT_SOURCE_DIR} /VERSION_NUMBER" FASTDEPLOY_VERSION)
113122string (STRIP "${FASTDEPLOY_VERSION} " FASTDEPLOY_VERSION)
114123
115124set (THIRD_PARTY_PATH ${CMAKE_CURRENT_BINARY_DIR} /third_libs)
125+ include (external/eigen.cmake)
116126if (ENABLE_PADDLE_FRONTEND)
117127 add_definitions (-DENABLE_PADDLE_FRONTEND)
118128 include (${PROJECT_SOURCE_DIR} /external/paddle2onnx.cmake)
@@ -207,6 +217,12 @@ else()
207217 endif ()
208218endif ()
209219
220+ if (ENABLE_TEXT)
221+ add_definitions (-DENABLE_TEXT)
222+ list (APPEND ALL_DEPLOY_SRCS ${DEPLOY_TEXT_SRCS} )
223+ include (external/faster_tokenizer.cmake)
224+ endif ()
225+
210226configure_file (${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/core/config.h)
211227configure_file (${PROJECT_SOURCE_DIR} /FastDeploy.cmake.in ${PROJECT_SOURCE_DIR} /FastDeploy.cmake @ONLY)
212228
@@ -249,6 +265,15 @@ if (WITH_VISION_EXAMPLES AND EXISTS ${PROJECT_SOURCE_DIR}/examples)
249265 add_subdirectory (examples)
250266endif ()
251267
268+ if (WITH_TEXT_EXAMPLES AND EXISTS ${PROJECT_SOURCE_DIR} /examples)
269+ add_definitions (-DWITH_TEXT_EXAMPLES)
270+ set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR} /examples/bin)
271+ # Avoid to add_subdirectory repeatedly
272+ if (NOT WITH_VISION_EXAMPLES)
273+ add_subdirectory (examples)
274+ endif ()
275+ endif ()
276+
252277include (external/summary.cmake)
253278fastdeploy_summary()
254279if (WIN32 )
@@ -307,6 +332,12 @@ if(BUILD_FASTDEPLOY_PYTHON)
307332 file (GLOB_RECURSE VISION_PYBIND_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/vision/*_pybind.cc)
308333 list (REMOVE_ITEM DEPLOY_PYBIND_SRCS ${VISION_PYBIND_SRCS} )
309334 endif ()
335+
336+ if (NOT ENABLE_TEXT)
337+ file (GLOB_RECURSE TEXT_PYBIND_SRCS ${PROJECT_SOURCE_DIR} /${CSRCS_DIR_NAME} /fastdeploy/text/*_pybind.cc)
338+ list (REMOVE_ITEM DEPLOY_PYBIND_SRCS ${TEXT_PYBIND_SRCS} )
339+ endif ()
340+
310341 add_library (${PY_LIBRARY_NAME} MODULE ${DEPLOY_PYBIND_SRCS} )
311342 redefine_file_macro(${PY_LIBRARY_NAME} )
312343 set_target_properties (${PY_LIBRARY_NAME} PROPERTIES PREFIX "" )
0 commit comments