divide ways of input in CMakeLists
This commit is contained in:
parent
5209b7bf22
commit
cb8041c928
143
CMakeLists.txt
143
CMakeLists.txt
|
@ -3,6 +3,28 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
project(checks-parser VERSION 0.1 LANGUAGES CXX)
|
project(checks-parser VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
option(BUILD_TRANSLATIONS "Build translations?" ON)
|
option(BUILD_TRANSLATIONS "Build translations?" ON)
|
||||||
|
option(BUILD_EMAIL_TO_TEXT_MODE "Build email-to-text mode?" ON)
|
||||||
|
option(BUILD_OCR_MODE "Build OCR mode?" ON)
|
||||||
|
option(BUILD_OFD_LOCAL_QR_SCAN "Build OFDs' local qr scanner?" ON)
|
||||||
|
option(BUILD_OFD_BINARYEYE_SCAN "Build OFDs' binaryeye scanner?" ON)
|
||||||
|
|
||||||
|
if (NOT (BUILD_EMAIL_TO_TEXT_MODE OR BUILD_OCR_MODE OR BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN))
|
||||||
|
message(FATAL_ERROR "You must specify at least one of the modes of data input!")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_EMAIL_TO_TEXT_MODE)
|
||||||
|
add_compile_definitions(BUILD_EMAIL_TO_TEXT_MODE)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OCR_MODE)
|
||||||
|
add_compile_definitions(BUILD_OCR_MODE)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
add_compile_definitions(BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OFD_BINARYEYE_SCAN)
|
||||||
|
add_compile_definitions(BUILD_OFD_BINARYEYE_SCAN)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
|
@ -18,15 +40,38 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core REQUIRED)
|
||||||
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)
|
if (BUILD_TRANSLATIONS)
|
||||||
|
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)
|
||||||
|
endif()
|
||||||
find_package(Qt5Gui REQUIRED)
|
find_package(Qt5Gui REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
find_package(Qt5UiTools REQUIRED)
|
find_package(Qt5UiTools REQUIRED)
|
||||||
|
|
||||||
set(PROJECT_SOURCES
|
set(TRANSLATION_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.h mainwindow.cpp scenes/mainwindow.ui
|
mainwindow.cpp mainwindow.h scenes/mainwindow.ui
|
||||||
|
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
|
||||||
|
)
|
||||||
|
|
||||||
|
if (BUILD_EMAIL_TO_TEXT_MODE)
|
||||||
|
list(APPEND TRANSLATION_SOURCES emailtextscene.cpp emailtextscene.h scenes/emailtextscene.ui)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OCR_MODE)
|
||||||
|
list(APPEND TRANSLATION_SOURCES ocrscene.cpp ocrscene.h scenes/ocrscene.ui)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
list(APPEND TRANSLATION_SOURCES adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
|
||||||
|
list(APPEND TRANSLATION_SOURCES solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui)
|
||||||
|
list(APPEND TRANSLATION_SOURCES ofdscene.cpp ofdscene.h scenes/ofdscene.ui)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS ${TRANSLATION_SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
set(PROJECT_SOURCES
|
||||||
goods/goods.h goods/goods.cpp
|
goods/goods.h goods/goods.cpp
|
||||||
check/check.h check/check.cpp
|
check/check.h check/check.cpp
|
||||||
parser/parser.h parser/parser.cpp
|
parser/parser.h parser/parser.cpp
|
||||||
|
@ -35,37 +80,29 @@ set(PROJECT_SOURCES
|
||||||
output/output_options.h output/output_options.cpp
|
output/output_options.h output/output_options.cpp
|
||||||
|
|
||||||
utils/utils.h utils/utils.cpp
|
utils/utils.h utils/utils.cpp
|
||||||
image/checkimage.h image/checkimage.cpp
|
|
||||||
net/net.h net/net.cpp
|
net/net.h net/net.cpp
|
||||||
settings/settings.h settings/settings.cpp
|
settings/settings.h settings/settings.cpp
|
||||||
exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp
|
|
||||||
|
|
||||||
emailtextscene.h emailtextscene.cpp scenes/emailtextscene.ui
|
${TRANSLATION_SOURCES}
|
||||||
ocrscene.h ocrscene.cpp scenes/ocrscene.ui
|
|
||||||
ofdscene.h ofdscene.cpp scenes/ofdscene.ui
|
|
||||||
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
|
|
||||||
adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui
|
|
||||||
image_redactor/imageredactor.h image_redactor/imageredactor.cpp
|
|
||||||
solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TRANSLATION_SOURCES
|
if (BUILD_OCR_MODE)
|
||||||
main.cpp
|
list(APPEND PROJECT_SOURCES image/checkimage.h image/checkimage.cpp)
|
||||||
mainwindow.cpp mainwindow.h scenes/mainwindow.ui
|
list(APPEND PROJECT_SOURCES image_redactor/imageredactor.h image_redactor/imageredactor.cpp)
|
||||||
emailtextscene.cpp emailtextscene.h scenes/emailtextscene.ui
|
endif()
|
||||||
ocrscene.cpp ocrscene.h scenes/ocrscene.ui
|
|
||||||
ofdscene.cpp ofdscene.h scenes/ofdscene.ui
|
|
||||||
outputdialog.h outputdialog.cpp scenes/outputdialog.ui
|
|
||||||
adjustpicturedialog.h adjustpicturedialog.cpp scenes/adjustpicturedialog.ui
|
|
||||||
solvecaptchadialog.h solvecaptchadialog.cpp scenes/solvecaptchadialog.ui
|
|
||||||
)
|
|
||||||
|
|
||||||
set(TS_FILES
|
if (BUILD_OFD_BINARYEYE_SCAN OR BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
translations/en_US.ts
|
list(APPEND PROJECT_SOURCES exceptions/ofdrequestexception.h exceptions/ofdrequestexception.cpp)
|
||||||
translations/ru_RU.ts
|
endif()
|
||||||
)
|
|
||||||
|
|
||||||
if (BUILD_TRANSLATIONS)
|
if (BUILD_TRANSLATIONS)
|
||||||
|
|
||||||
|
set(TS_FILES
|
||||||
|
translations/en_US.ts
|
||||||
|
translations/ru_RU.ts
|
||||||
|
)
|
||||||
|
|
||||||
qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" ${TS_FILES})
|
qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" ${TS_FILES})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc COPYONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc COPYONLY)
|
||||||
qt5_add_resources(TRANSLATIONQRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
qt5_add_resources(TRANSLATIONQRC ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||||
|
@ -109,7 +146,9 @@ endif()
|
||||||
|
|
||||||
target_link_libraries(checks-parser PRIVATE Qt5::Widgets Qt5::UiTools)
|
target_link_libraries(checks-parser PRIVATE Qt5::Widgets Qt5::UiTools)
|
||||||
|
|
||||||
target_include_directories(checks-parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/image_redactor)
|
# if (BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
target_include_directories(checks-parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/image_redactor)
|
||||||
|
# endif()
|
||||||
|
|
||||||
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER org.foxarmy.checks-parser)
|
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER org.foxarmy.checks-parser)
|
||||||
|
|
||||||
|
@ -133,29 +172,39 @@ if(WIN32)
|
||||||
set(OpenCV_DIR /usr/local/lib/cmake/opencv4)
|
set(OpenCV_DIR /usr/local/lib/cmake/opencv4)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
FetchContent_Declare(httplib SYSTEM
|
if (BUILD_OFD_BINARYEYE_SCAN)
|
||||||
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib
|
find_package(PkgConfig)
|
||||||
GIT_TAG 787a34ad7f01f20922a237d5142aae469828be72
|
pkg_check_modules(QRENCODE REQUIRED libqrencode)
|
||||||
GIT_SHALLOW TRUE)
|
include_directories(${QRENCODE_INCLUDE_DIRS})
|
||||||
FetchContent_MakeAvailable(httplib)
|
link_directories(${QRENCODE_LIBRARY_DIRS})
|
||||||
|
target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if (BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
target_link_libraries(checks-parser PRIVATE -lzbar)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
|
if (BUILD_OCR_MODE)
|
||||||
|
target_link_libraries(checks-parser PRIVATE -ltesseract)
|
||||||
|
endif()
|
||||||
|
if (BUILD_OFD_BINARYEYE_SCAN OR BUILD_OFD_LOCAL_QR_SCAN)
|
||||||
|
target_link_libraries(checks-parser PRIVATE -lcurl)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig)
|
if (BUILD_OCR_MODE OR BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
|
||||||
pkg_check_modules(QRENCODE REQUIRED libqrencode)
|
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
|
||||||
include_directories(${QRENCODE_INCLUDE_DIRS})
|
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
|
||||||
link_directories(${QRENCODE_LIBRARY_DIRS})
|
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
|
||||||
target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES})
|
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
||||||
|
endif()
|
||||||
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
|
||||||
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
target_link_libraries(checks-parser PRIVATE -lzbar)
|
|
||||||
target_link_libraries(checks-parser PRIVATE -ltesseract)
|
|
||||||
target_link_libraries(checks-parser PRIVATE -lcurl)
|
|
||||||
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
|
|
||||||
target_link_libraries(checks-parser PRIVATE httplib)
|
|
||||||
|
|
||||||
|
if(BUILD_OFD_BINARYEYE_SCAN)
|
||||||
|
FetchContent_Declare(httplib SYSTEM
|
||||||
|
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib
|
||||||
|
GIT_TAG 787a34ad7f01f20922a237d5142aae469828be72
|
||||||
|
GIT_SHALLOW TRUE)
|
||||||
|
FetchContent_MakeAvailable(httplib)
|
||||||
|
target_link_libraries(checks-parser PRIVATE httplib)
|
||||||
|
endif()
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
|
||||||
target_link_libraries(checks-parser PRIVATE -lstdc++fs)
|
target_link_libraries(checks-parser PRIVATE -lstdc++fs)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue