Warning, /libraries/ktextaddons/texttranslator/translator/plugins/bergamot/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-License-Identifier: BSD-3-Clause
0002 # SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 if (0)
0004 include(ExternalProject)
0005 include_directories(${CMAKE_CURRENT_BINARY_DIR}/)
0006 kde_enable_exceptions()
0007 SET(COMPILE_CUDA OFF CACHE BOOL "Compile GPU version")
0008 SET(USE_SENTENCEPIECE ON CACHE BOOL "Download and compile SentencePiece")
0009 SET(USE_STATIC_LIBS ON CACHE BOOL "Link statically against non-system libs")
0010 SET(USE_WASM_COMPATIBLE_SOURCE OFF CACHE BOOL "Don't build wasm compatible sources")
0011 
0012 add_definitions(-DPHF_NO_LIBCXX=0)
0013 #add_definitions(-DCUDA_FOUND=0)
0014 add_definitions(-D__STDC_VERSION__=0)
0015 if (0)
0016 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/3rd_party/marian-dev/src/)
0017 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/3rd_party/marian-dev/src/3rd_party/spdlog/include/)
0018 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/3rd_party/marian-dev/src/3rd_party)
0019 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/)
0020 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/3rd_party/ssplit-cpp/src/ssplit/)
0021 include_directories(${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator/src/)
0022 set(ext_source_dir ${CMAKE_CURRENT_BINARY_DIR}/bergamot-translator)
0023 ExternalProject_Add(3rdparty_bergamot
0024         #PREFIX ${ext_source_dir}/build
0025         GIT_REPOSITORY "https://github.com/browsermt/bergamot-translator.git"
0026         GIT_TAG "main"
0027         SOURCE_DIR ${ext_source_dir}
0028         BUILD_IN_SOURCE ON
0029         CMAKE_ARGS -DBLA_PREFER_PKGCONFIG:BOOL=ON
0030         -DBLA_PKGCONFIG_BLAS:STRING=openblas
0031         -Dcblas_cblas_LIBRARY:STRING=cblas
0032 )
0033 endif()
0034 
0035 add_subdirectory(bergamot-translator EXCLUDE_FROM_ALL)
0036 
0037 endif()
0038 add_library(libbergamot)
0039 
0040 
0041 target_sources(libbergamot PRIVATE
0042 
0043     begamotenginedialog.h
0044     begamotenginedialog.cpp
0045     bergamotenginewidget.h
0046     bergamotenginewidget.cpp
0047 
0048     managermodeltranslator.h
0049     managermodeltranslator.cpp
0050     translator.h
0051     translator.cpp
0052 
0053     bergamotengineutils.h
0054     bergamotengineutils.cpp
0055 
0056     translatormodel.h
0057     translatormodel.cpp
0058     bergamotenginelanguagewidget.h
0059     bergamotenginelanguagewidget.cpp
0060 
0061     bergamotenginesettingswidget.h
0062     bergamotenginesettingswidget.cpp
0063 
0064     libbergamot_private_export.h
0065 
0066     translatorproxymodel.h
0067     translatorproxymodel.cpp
0068 
0069     bergamotmarianinterface.h
0070     bergamotmarianinterface.cpp
0071 
0072     extractlanguagejob.h
0073     extractlanguagejob.cpp
0074 
0075     downloadlanguagejob.h
0076     downloadlanguagejob.cpp
0077 
0078     translation.cpp
0079     translation.h
0080 )
0081 
0082 generate_export_header(libbergamot BASE_NAME libbergamot)
0083 
0084 ecm_qt_declare_logging_category(libbergamot HEADER libbergamot_debug.h IDENTIFIER TRANSLATOR_LIBBERGAMOT_LOG
0085     CATEGORY_NAME org.kde.libbergamottranslator DESCRIPTION "lib bergamot translator" EXPORT KTEXTADDONS)
0086 
0087 target_link_libraries(libbergamot  Qt::Widgets
0088     KF${KF_MAJOR_VERSION}::I18n
0089     KF${KF_MAJOR_VERSION}::TextTranslator
0090     KF${KF_MAJOR_VERSION}::ConfigWidgets
0091     KF${KF_MAJOR_VERSION}::TextAddonsWidgets
0092     KF${KF_MAJOR_VERSION}::WidgetsAddons
0093     KF${KF_MAJOR_VERSION}::Archive
0094     slimt::slimt-shared
0095 )
0096 
0097 set_target_properties(libbergamot
0098     PROPERTIES OUTPUT_NAME libbergamot VERSION ${TEXTTRANSLATE_VERSION} SOVERSION ${TEXTTRANSLATE_SOVERSION}
0099 )
0100 
0101 install(TARGETS libbergamot ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
0102 
0103 
0104 add_library(translator_bergamot MODULE)
0105 ecm_qt_declare_logging_category(translator_debug_bergamot_SRCS
0106     HEADER bergamottranslator_debug.h
0107     IDENTIFIER TRANSLATOR_BERGAMOT_LOG
0108     CATEGORY_NAME org.kde.kf.texttranslator.bergamot
0109     DESCRIPTION "bergamot translator"
0110     EXPORT KTEXTADDONS
0111 )
0112 
0113 target_sources(translator_bergamot PRIVATE
0114     ${translator_debug_bergamot_SRCS}
0115     bergamotengineplugin.cpp
0116     bergamotengineplugin.h
0117     bergamotengineclient.cpp
0118     bergamotengineclient.h
0119 
0120 )
0121 
0122 target_link_libraries(translator_bergamot PRIVATE KF${KF_MAJOR_VERSION}::TextTranslator KF${KF_MAJOR_VERSION}::I18n libbergamot)
0123 
0124 install(TARGETS translator_bergamot  DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/translator/)
0125 
0126 if (BUILD_TESTING)
0127     add_subdirectory(autotests)
0128     add_subdirectory(tests)
0129 endif()