1
0
Fork 0

Add external_sonnet library

This commit is contained in:
Ilya Fedin 2022-11-23 07:16:00 +04:00 committed by John Preston
parent 2c341a0d3e
commit 81705fb609
10 changed files with 169 additions and 5 deletions

View file

@ -13,6 +13,9 @@ endmacro()
add_checked_subdirectory(angle) add_checked_subdirectory(angle)
add_checked_subdirectory(auto_updates) add_checked_subdirectory(auto_updates)
if (add_cld3_library)
add_checked_subdirectory(cld3)
endif()
add_checked_subdirectory(crash_reports) add_checked_subdirectory(crash_reports)
if (LINUX) if (LINUX)
add_checked_subdirectory(dispatch) add_checked_subdirectory(dispatch)
@ -36,9 +39,6 @@ endif()
if (add_hunspell_library) if (add_hunspell_library)
add_checked_subdirectory(hunspell) add_checked_subdirectory(hunspell)
endif() endif()
if (add_cld3_library)
add_checked_subdirectory(cld3)
endif()
add_checked_subdirectory(iconv) add_checked_subdirectory(iconv)
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC) if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
add_checked_subdirectory(jemalloc) add_checked_subdirectory(jemalloc)
@ -59,6 +59,9 @@ add_checked_subdirectory(qr_code_generator)
add_checked_subdirectory(ranges) add_checked_subdirectory(ranges)
add_checked_subdirectory(rlottie) add_checked_subdirectory(rlottie)
add_checked_subdirectory(rnnoise) add_checked_subdirectory(rnnoise)
if (add_sonnet_library)
add_checked_subdirectory(sonnet)
endif()
add_checked_subdirectory(ton) add_checked_subdirectory(ton)
add_checked_subdirectory(variant) add_checked_subdirectory(variant)
add_checked_subdirectory(vpx) add_checked_subdirectory(vpx)

View file

@ -56,6 +56,7 @@ PRIVATE
target_include_directories(external_hunspell_bundled target_include_directories(external_hunspell_bundled
PUBLIC PUBLIC
${hunspell_src} ${hunspell_src}
${hunspell_src}/hunspell
) )
target_compile_definitions(external_hunspell_bundled target_compile_definitions(external_hunspell_bundled

110
external/sonnet/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,110 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND QT_VERSION_MAJOR EQUAL 5)
add_library(external_sonnet INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_sonnet ALIAS external_sonnet)
find_package(KF5Sonnet)
if (KF5Sonnet_FOUND)
target_link_libraries(external_sonnet INTERFACE KF5::SonnetCore)
return()
endif()
endif()
add_library(external_sonnet STATIC)
add_library(desktop-app::external_sonnet ALIAS external_sonnet)
init_target(external_sonnet "(external)")
set(sonnet_loc ${third_party_loc}/sonnet)
set(sonnet_data_loc ${sonnet_loc}/data)
set(sonnet_core_src ${sonnet_loc}/src/core)
set(sonnet_plugins_src ${sonnet_loc}/src/plugins)
set_target_properties(external_sonnet PROPERTIES AUTOMOC ON)
configure_file(${sonnet_data_loc}/trigrams.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/trigrams.qrc @ONLY)
target_sources(external_sonnet PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/trigrams.qrc)
nice_target_sources(external_sonnet ${sonnet_core_src}
PRIVATE
client.cpp
client_p.h
guesslanguage.cpp
guesslanguage.h
loader.cpp
loader_p.h
settings.cpp
settings.h
settingsimpl.cpp
settingsimpl_p.h
speller.cpp
speller.h
spellerplugin.cpp
spellerplugin_p.h
textbreaks.cpp
textbreaks_p.h
tokenizer.cpp
tokenizer_p.h
)
nice_target_sources(external_sonnet ${sonnet_plugins_src}/hunspell
PRIVATE
hunspellclient.cpp
hunspellclient.h
hunspelldict.cpp
hunspelldict.h
)
if (APPLE)
nice_target_sources(external_sonnet ${sonnet_plugins_src}/nsspellchecker
PRIVATE
nsspellcheckerclient.cpp
nsspellcheckerclient.h
nsspellcheckerdict.cpp
nsspellcheckerdict.h
)
endif()
target_compile_definitions(external_sonnet
PUBLIC
SONNETCORE_EXPORT=
SONNET_STATIC
PRIVATE
QT_USE_QSTRINGBUILDER
)
target_include_directories(external_sonnet SYSTEM
PUBLIC
${sonnet_core_src}
${CMAKE_CURRENT_SOURCE_DIR}/headers/public
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/headers/private
)
target_link_libraries(external_sonnet
PRIVATE
desktop-app::external_qt
desktop-app::external_hunspell
)
target_prepare_qrc(external_sonnet)
add_executable(external_sonnet_parsetrigrams)
init_target(external_sonnet_parsetrigrams "(external)")
nice_target_sources(external_sonnet_parsetrigrams ${sonnet_data_loc}
PRIVATE
parsetrigrams.cpp
)
target_link_libraries(external_sonnet_parsetrigrams
PRIVATE
desktop-app::external_qt
)
include(generate_trigrams.cmake)
generate_trigrams(external_sonnet ${sonnet_data_loc}/trigrams)

23
external/sonnet/generate_trigrams.cmake vendored Normal file
View file

@ -0,0 +1,23 @@
function(generate_trigrams target_name trigrams_file)
set(gen_dst ${CMAKE_BINARY_DIR}/data)
file(MAKE_DIRECTORY ${gen_dst})
set(gen_timestamp ${gen_dst}/${target_name}_trigrams.timestamp)
set(gen_files ${gen_dst}/trigrams.map)
add_custom_command(
OUTPUT
${gen_timestamp}
BYPRODUCTS
${gen_files}
COMMAND
external_sonnet_parsetrigrams "${trigrams_file}" > "${gen_files}"
COMMAND
echo 1> ${gen_timestamp}
COMMENT "Generating trigrams (${target_name})"
DEPENDS
external_sonnet_parsetrigrams
${trigrams_file}
)
generate_target(${target_name} trigrams ${gen_timestamp} "${gen_files}" ${gen_dst})
endfunction()

View file

View file

@ -0,0 +1,3 @@
#pragma once
#include <QLoggingCategory>
static const QLoggingCategory SONNET_LOG_CORE("kf.sonnet.core", QtInfoMsg);

View file

@ -0,0 +1,3 @@
#pragma once
#include <QLoggingCategory>
static const QLoggingCategory SONNET_HUNSPELL("kf.sonnet.clients.hunspell", QtInfoMsg);

View file

@ -0,0 +1,3 @@
#pragma once
#include <QLoggingCategory>
static const QLoggingCategory SONNET_NSSPELLCHECKER("kf.sonnet.clients.nsspellchecker", QtInfoMsg);

View file

View file

@ -31,10 +31,22 @@ option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no
option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate}) option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate})
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF) cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF)
cmake_dependent_option(DESKTOP_APP_USE_CLD3 "Disable system text language recognition and use bundled cld3 only." OFF APPLE ON)
cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF) cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF)
cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF LINUX OFF) cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF LINUX OFF)
if (APPLE)
set(language_recognition_default SYSTEM)
elseif (WIN32)
set(language_recognition_default CLD3)
else()
set(language_recognition_default SONNET)
endif()
set(DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND "${language_recognition_default}" CACHE STRING "Text language recognition backend.")
set_property(CACHE DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND PROPERTY STRINGS SYSTEM CLD3 SONNET)
if (LINUX AND DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND STREQUAL SYSTEM)
set(DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND "${language_recognition_default}")
endif()
if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH) if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH)
if (DEFINED CMAKE_OSX_ARCHITECTURES) if (DEFINED CMAKE_OSX_ARCHITECTURES)
set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch.") set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch.")
@ -52,10 +64,16 @@ if ((WIN32
endif() endif()
set(add_cld3_library 0) set(add_cld3_library 0)
if (LINUX OR DESKTOP_APP_USE_CLD3) if (DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND STREQUAL CLD3)
set(add_cld3_library 1) set(add_cld3_library 1)
endif() endif()
set(add_sonnet_library 0)
if (DESKTOP_APP_LANGUAGE_RECOGNITION_BACKEND STREQUAL SONNET)
set(add_sonnet_library 1)
set(add_hunspell_library 1)
endif()
set(build_macstore 0) set(build_macstore 0)
set(build_winstore 0) # 32 or 64 bit set(build_winstore 0) # 32 or 64 bit
set(build_win64 0) # normal or uwp set(build_win64 0) # normal or uwp