-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
64 lines (46 loc) · 2.37 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
##########################################################################
# Configuration #
##########################################################################
cmake_minimum_required(VERSION 3.0.0)
project(ocr-receipt VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(EXTRA_COMPILE_FLAGS "-Wall -Werror")
set(BINARY ${CMAKE_PROJECT_NAME})
set(TEST ${CMAKE_PROJECT_NAME}-test)
find_package(Boost 1.74.0 REQUIRED COMPONENTS filesystem locale program_options system)
include_directories(${Boost_INCLUDE_DIR})
find_package(Leptonica 1.82.0 REQUIRED)
include_directories(${Leptonica_INCLUDE_DIRS})
find_package(Tesseract 5.1.0 REQUIRED)
include_directories(${Tesseract_INCLUDE_DIRS})
find_package(OpenCV 4.5.4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
find_package(PythonLibs 3.10.4 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
##########################################################################
# Binary #
##########################################################################
include_directories(include)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.cpp)
add_executable(${BINARY} ${SOURCES} ${INCLUDES} main.cpp)
target_link_libraries(${BINARY} ${Boost_LIBRARIES} ${Tesseract_LIBRARIES} ${Leptonica_LIBRARIES} ${OpenCV_LIBS} ${PYTHON_LIBRARIES})
##########################################################################
# Unit Tests #
##########################################################################
enable_testing()
include(GoogleTest)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
)
FetchContent_MakeAvailable(googletest)
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
file(GLOB_RECURSE SOURCES_TEST ${TEST_DIR}/*.cpp)
add_executable(${TEST} ${SOURCES} ${SOURCES_TEST} ${INCLUDES})
target_link_libraries(${TEST} gtest_main ${Boost_LIBRARIES} ${Tesseract_LIBRARIES} ${Leptonica_LIBRARIES} ${OpenCV_LIBS} ${PYTHON_LIBRARIES})
gtest_discover_tests(${TEST})