forked from RapidAI/RapidOCR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·107 lines (72 loc) · 2.71 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
cmake_minimum_required(VERSION 3.12)
project(RapidOCR)
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/cpp/RapidOCRCPP/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/ /rapidocr/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/onnxruntime/)
if(WIN32)
add_definitions(-D_BPOCR_EXPORT_API)
IF(CMAKE_CL_64)
set(platform x64)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/win/x64/)
link_directories(c:/rapidocr/onnxruntime-win-x64-1.7.0/lib)
set(OpenCV_DIR c:/rapidocr/windows-x64)
ELSE(CMAKE_CL_64)
set(platform x86)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/win/x86/)
link_directories(c:/rapidocr/onnxruntime-win-x86-1.7.0/lib)
set(OpenCV_DIR c:/rapidocr/windows-x86)
ENDIF(CMAKE_CL_64)
set(OpenCV_STATIC 1)
#if(MSVC)
#add_compile_options(
#$<$<CONFIG:>:/MT> #---------|
#$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
#$<$<CONFIG:Release>:/MT> #--|
#)
#endif()
# 指向下载的opencv解开后的目录,下面会有bin/lib/include等目录
elseif(UNIX)
# set(OpenCV_DIR /path/to/opencv/build)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/linux /rapidocr/lib/)
endif()
#IF(CMAKE_BUILD_TYPE STREQUAL Debug) #debug
#
#else()
# link_libraries(opencv_world3413.lib onnxruntime.lib)
#endif()
# for onnxruntime
link_libraries(onnxruntime)
FIND_PACKAGE(OpenCV REQUIRED)
if(OPENCV_FOUND)
message("OpenCV FOUND")
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBRARY_DIRS})
link_libraries(${OpenCV_LIBS})
endif()
# openmp
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
message(${CMAKE_EXE_LINKER_FLAGS})
endif()
#end of openmp
add_definitions(-D__OPENMP__)
aux_source_directory(cpp/RapidOCRCPP/src/ SRC_MAIN)
list(REMOVE_ITEM SRC_MAIN "main.cpp")
set(OCR_SRC api4cpp/rapidocr_api.cpp ${SRC_MAIN} )
add_library(rapidocrapi SHARED ${OCR_SRC})
target_compile_definitions(rapidocrapi PUBLIC -D_BPOCR_LIB)
# test program
set(BPOCRTESTSRC api4cpp/rapidocrtest.cpp)
add_executable(rapidocrtest ${BPOCRTESTSRC})
target_link_libraries(rapidocrtest onnxruntime ${OPENCV_LIB} rapidocrapi)