From 5ca16a4f76f95e66fd9fa0bf02558a28c201eb11 Mon Sep 17 00:00:00 2001 From: leca Date: Mon, 3 Mar 2025 22:52:09 +0300 Subject: [PATCH] translations --- CMakeLists.txt | 81 ++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c083d9..01a9abf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,10 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS Designer) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) -find_package(Qt5 COMPONENTS LinguistTools) +find_package(Qt5Core REQUIRED) +find_package(Qt5 REQUIRED COMPONENTS LinguistTools) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Widgets REQUIRED) set(PROJECT_SOURCES main.cpp @@ -50,48 +51,40 @@ set(TRANSLATION_SOURCES adjustpicturedialog.cpp adjustpicturedialog.h adjustpicturedialog.ui ) -set(TRANSLATION_FILES translations/en_US.ts translations/ru_RU.ts) +# qt_add_resources(RESOURCES +# ${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc +# ) -# set(QM_FILES "") - - -# qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" translations/en_US.ts translations/ru_RU.ts) - - -# foreach(TS_FILE IN LISTS "${TRANSLATION_FILES}") -# qt5_create_translation(QM_FILE "${TRANSLATION_SOURCES}" TS_FILE) -# set(QM_FILE "${CMAKE_CURRENT_BINARY_DIR}/${QM_FILE}") -# set(QM_FILES "${QM_FILES};${QM_FILE}") -# endforeach() - -qt5_create_translation(QM_FILES "${TRANSLATION_SOURCES}" translations/en_US.ts translations/ru_RU.ts) -# message(STATUS ${CMAKE_CURRENT_BINARY_DIR}) -qt5_add_resources(TRANSLATIONQRC translations.qrc OPTIONS --root ${CMAKE_CURRENT_BINARY_DIR}) +qt5_add_translation(QM_FILES translations/en_US.ts translations/ru_RU.ts) +# qt5_add_resources(TRANSLATIONQRC translations.qrc OPTIONS --root ${CMAKE_CURRENT_BINARY_DIR}) +# qt5_add_resources(TRANSLATIONQRC translations.qrc) add_custom_target(translations DEPENDS ${QM_FILES} - DEPENDS ${TRANSLATIONQRC} + # DEPENDS ${RESOURCES} VERBATIM ) +file(GLOB QM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.qm) -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(checks-parser - MANUAL_FINALIZATION +qt_add_resources(translation_resources + ${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc +) + +foreach(QM_FILE ${QM_FILES}) + file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc + " ${QM_FILE}\n" + ) +endforeach() + +if(ANDROID) + add_library(checks-parser SHARED ${PROJECT_SOURCES} ) else() - if(ANDROID) - add_library(checks-parser SHARED - ${PROJECT_SOURCES} - ) - - else() - add_executable(checks-parser - ${PROJECT_SOURCES} - # ${QM_FILES} - ${TRANSLATIONQRC} - ) - endif() + add_executable(checks-parser + ${PROJECT_SOURCES} + ${RESOURCES} + ) endif() target_link_libraries(checks-parser PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) @@ -101,9 +94,7 @@ target_include_directories(checks-parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imag # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. -if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.checks-parser) -endif() +set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.checks-parser) set_target_properties(checks-parser PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} @@ -119,22 +110,16 @@ install(TARGETS checks-parser RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(checks-parser) -endif() - if(WIN32) -# set(OPENCV_MAP_IMPORTED_CONFIG "") set(OpenCV_DIR /usr/local/lib/cmake/opencv4) -# set (OpenCV_DIR /usr/lib/x86_64-linux-gnu/cmake/opencv4) endif() -find_package(OpenCV REQUIRED) +find_package(OpenCV 4 REQUIRED COMPONENTS core imgproc imgcodecs) -include_directories( ${OpenCV_INCLUDE_DIRS} ) +include_directories(${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 ${OpenCV_LIBS}) 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()