Skip to content

Commit

Permalink
chore: cmake fastdeploy_ppocr, windows only option
Browse files Browse the repository at this point in the history
  • Loading branch information
horror-proton committed May 24, 2024
1 parent 561b601 commit b5d1b88
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ option(INSTALL_DEVEL "install development files" OFF)
option(INSTALL_FLATTEN "do not use bin lib include directory" ON)
option(INSTALL_THIRD_LIBS "install third party libraries" ON)
option(USE_MAADEPS "use third-party libraries built by MaaDeps" ON)
option(WITH_EMULATOR_EXTRAS "build with emulator extras" ON)
option(WITH_EMULATOR_EXTRAS "build with emulator extras" ${WIN32})
option(WITH_THRIFT "build with thrift" OFF)

include(${PROJECT_SOURCE_DIR}/cmake/utils.cmake)
Expand Down Expand Up @@ -80,36 +80,37 @@ find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs videoio)
find_package(ZLIB REQUIRED)
find_package(cpr CONFIG REQUIRED)

if (USE_MAADEPS)
find_package(MaaDerpLearning REQUIRED)
elseif(DEFINED MaaDerpLearning_SOURCE_DIR) # TODO: FetchContent
if (NOT DEFINED MaaDerpLearning_BINARY_DIR)
set(MaaDerpLearning_BINARY_DIR ${CMAKE_BINARY_DIR}/MaaDerpLearning)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(${MaaDerpLearning_SOURCE_DIR} ${MaaDerpLearning_BINARY_DIR} EXCLUDE_FROM_ALL SYSTEM)
if (NOT DEFINED MaaDerpLearning_INCLUDE_DIRS)
set(MaaDerpLearning_INCLUDE_DIRS ${MaaDerpLearning_SOURCE_DIR})
endif()
get_target_property(MaaDerpLearning_type MaaDerpLearning TYPE)
if (MaaDerpLearning_type STREQUAL "SHARED_LIBRARY")
install(TARGETS MaaDerpLearning)
endif()
else()
find_package(MaaDerpLearning REQUIRED)
# TODO: INSTALL_THIRD_LIBS
endif()

list(APPEND maa_libs ${OpenCV_LIBS} MaaDerpLearning ZLIB::ZLIB cpr::cpr header_only_libraries)
list(APPEND maa_libs ${OpenCV_LIBS} ZLIB::ZLIB cpr::cpr header_only_libraries)

if (USE_MAADEPS)
if(USE_MAADEPS)
find_package(ONNXRuntime REQUIRED)
find_package(asio REQUIRED)
list(APPEND maa_libs ONNXRuntime::ONNXRuntime asio::asio)

find_package(MaaDerpLearning REQUIRED)
list(APPEND maa_libs MaaDerpLearning)
else()
find_package(onnxruntime REQUIRED) # provided by onnxruntime>=1.16
list(APPEND maa_libs onnxruntime::onnxruntime)
target_include_directories(MaaCore SYSTEM PRIVATE ${MaaDerpLearning_INCLUDE_DIRS})
if(DEFINED fastdeploy_SOURCE_DIR)
# TODO: FetchContent github.com/MaaAssistantArknights/FastDeploy
if(NOT DEFINED fastdeploy_BINARY_DIR)
set(fastdeploy_BINARY_DIR ${CMAKE_BINARY_DIR}/fastdeploy)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(${fastdeploy_SOURCE_DIR} ${fastdeploy_BINARY_DIR} EXCLUDE_FROM_ALL SYSTEM)
if(NOT DEFINED fastdeploy_INCLUDE_DIRS)
set(fastdeploy_INCLUDE_DIRS ${fastdeploy_SOURCE_DIR})
endif()
get_target_property(fastdeploy_type fastdeploy_ppocr TYPE)
if(fastdeploy_type STREQUAL "SHARED_LIBRARY")
install(TARGETS fastdeploy)
endif()
else()
find_package(fastdeploy_ppocr REQUIRED)
endif()
list(APPEND maa_libs fastdeploy_ppocr)
target_include_directories(MaaCore SYSTEM PRIVATE ${fastdeploy_INCLUDE_DIRS})
endif()

target_link_libraries(MaaCore ${maa_libs})
Expand Down

0 comments on commit b5d1b88

Please sign in to comment.