From be2eff7360e74ba4062e4c6a1f3328b5be1594c2 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Wed, 15 Jun 2022 23:29:58 +0800 Subject: [PATCH] use system opencv, cleaner way to use ncnn --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72a271b..4993b78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(deepin-ocr) #3rdparty -execute_process(COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/build3rdparty.sh WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +#execute_process(COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/build3rdparty.sh WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) option(DOTEST "option for test" OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f0198c..b0beede 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,14 +32,22 @@ add_definitions(${QT_DEFINITIONS}) include(CMakePackageConfigHelpers) #for OpenCV-mobile -include_directories(../3rdparty/opencv-4.5.4/build/install/include/opencv4) -add_library(opencv_world STATIC IMPORTED) -set_property(TARGET opencv_world PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/opencv-4.5.4/build/install/lib/libopencv_world.a) +#include_directories(../3rdparty/opencv-4.5.4/build/install/include/opencv4) +#add_library(opencv_world STATIC IMPORTED) +#set_property(TARGET opencv_world PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/opencv-4.5.4/build/install/lib/libopencv_world.a) +# vtk hdf5 +find_package(OpenCV REQUIRED COMPONENTS opencv_hdf opencv_imgproc opencv_imgcodecs) +include_directories(${OpenCV_INCLUDE_DIRS}) +set(opencv_world ${OpenCV_LIBS}) #for ncnn -include_directories(../3rdparty/ncnn/build/install/include/ncnn) +#set (ncnn_DIR "../3rdparty/ncnn/src" CACHE PATH "Directory that contains ncnnConfig.cmake") +find_package(ncnn PATHS ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/ncnn/build/install/lib/cmake/ncnn) +if (NOT ncnn_FOUND) +include_directories(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/ncnn/build/install/include/ncnn) add_library(ncnn STATIC IMPORTED) set_property(TARGET ncnn PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/ncnn/build/install/lib/libncnn.a) +endif() #for clipper include_directories(../3rdparty/clipper) @@ -146,10 +154,10 @@ if(DOTEST) qt5_use_modules(${PROJECT_NAME_TEST} ${QtModule}) endif() -target_link_libraries(${PROJECT_NAME} opencv_world ncnn Qt5::Core Qt5::Gui Qt5::Widgets ${dtk_lib_LIBRARIES} pthread dl -fopenmp) +target_link_libraries(${PROJECT_NAME} ${opencv_world} ncnn Qt5::Core Qt5::Gui Qt5::Widgets ${dtk_lib_LIBRARIES} pthread dl -fopenmp) if(DOTEST) - target_link_libraries(${PROJECT_NAME_TEST} opencv_world ncnn Qt5::Core Qt5::Gui Qt5::Widgets ${dtk_lib_LIBRARIES} pthread dl -fopenmp) + target_link_libraries(${PROJECT_NAME_TEST} ${opencv_world} ncnn Qt5::Core Qt5::Gui Qt5::Widgets ${dtk_lib_LIBRARIES} pthread dl -fopenmp) endif() # install