-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
106 lines (86 loc) · 2.46 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
106
cmake_minimum_required(VERSION 3.20..3.50)
project(gazou VERSION 0.3.2 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if (WIN32)
set(Gazou_MODEL_FOLDER models)
else()
set(Gazou_MODEL_FOLDER ${CMAKE_INSTALL_PREFIX}/share/gazou/models)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(LIBS Qt5::Widgets Qt5::DBus tesseract)
if (UNIX)
list(APPEND LIBS leptonica)
else()
list(APPEND LIBS lept)
endif()
set(SRC
src/main.cpp
src/selectorwidget.cpp
src/keydialog.cpp
src/utils.cpp
src/ocr.cpp
src/state.cpp
src/request.cpp
resources/resources.qrc
)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
configure_file(src/config.h.in config.h)
include_directories(${PROJECT_BINARY_DIR})
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
option(GUI "Build GUI support" ON)
configure_file(src/config.h.in config.h)
include_directories(${PROJECT_BINARY_DIR})
find_package(PkgConfig)
pkg_check_modules(tess REQUIRED tesseract>=4.0.0)
pkg_check_modules(lept REQUIRED lept>=1.70)
find_package(Qt5 CONFIG REQUIRED Core DBus)
find_package(Qt5Widgets REQUIRED VERSION 5.10)
if (GUI)
if (UNIX AND NOT APPLE)
find_package(Qt5X11Extras)
endif()
find_package(QHotkey CONFIG QUIET)
if (NOT QHotkey_FOUND)
add_subdirectory(third-party/QHotkey EXCLUDE_FROM_ALL)
endif()
list(APPEND LIBS qhotkey)
list(APPEND SRC src/gui.cpp
src/configwindow.cpp
)
add_compile_definitions(GUI)
endif()
# Windows target
if (WIN32)
add_executable(${PROJECT_NAME} WIN32 ${SRC})
else()
add_executable(${PROJECT_NAME} ${SRC})
endif()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
target_link_libraries(${PROJECT_NAME} ${LIBS})
# Install targets
if (UNIX AND NOT APPLE)
install(TARGETS gazou RUNTIME DESTINATION bin)
install(DIRECTORY models DESTINATION share/gazou)
install(FILES resources/gazou.desktop DESTINATION share/applications)
install(FILES resources/gazou.png DESTINATION share/pixmaps)
endif()
# format entire project
file(GLOB_RECURSE
ALL_CXX_SOURCE_FILES
*.[chi]pp *.[chi]xx *.cc *.hh *.ii *.[CHI]
)
add_custom_target(
format
COMMAND /usr/lib/llvm/11/bin/clang-format
-i
-style=file
${ALL_CXX_SOURCE_FILES}
)