CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # This file is part of Desktop App Toolkit,
  2. # a set of libraries for developing nice desktop applications.
  3. #
  4. # For license and copyright information please follow this link:
  5. # https://github.com/desktop-app/legal/blob/master/LEGAL
  6. add_library(lib_spellcheck STATIC)
  7. add_library(desktop-app::lib_spellcheck ALIAS lib_spellcheck)
  8. init_target(lib_spellcheck)
  9. get_filename_component(src_loc . REALPATH)
  10. set(use_enchant 0)
  11. if (LINUX AND DESKTOP_APP_USE_ENCHANT)
  12. set(use_enchant 1)
  13. endif()
  14. set(system_spellchecker 0)
  15. if ((APPLE OR WIN32 OR use_enchant) AND NOT DESKTOP_APP_USE_HUNSPELL_ONLY)
  16. set(system_spellchecker 1)
  17. endif()
  18. if (APPLE)
  19. target_link_frameworks_weak(lib_spellcheck
  20. PUBLIC
  21. NaturalLanguage # Since macOS 10.14 only.
  22. )
  23. endif()
  24. set(use_cld3 0)
  25. if (LINUX OR DESKTOP_APP_USE_CLD3)
  26. set(use_cld3 1)
  27. endif()
  28. target_precompile_headers(lib_spellcheck PRIVATE ${src_loc}/spellcheck/spellcheck_pch.h)
  29. nice_target_sources(lib_spellcheck ${src_loc}
  30. PRIVATE
  31. highlighting/highlighting.qrc
  32. spellcheck/platform/linux/language_linux.cpp
  33. spellcheck/platform/linux/language_linux.h
  34. spellcheck/platform/linux/linux_enchant.cpp
  35. spellcheck/platform/linux/linux_enchant.h
  36. spellcheck/platform/linux/spellcheck_linux.cpp
  37. spellcheck/platform/linux/spellcheck_linux.h
  38. spellcheck/platform/mac/language_mac.h
  39. spellcheck/platform/mac/language_mac.mm
  40. spellcheck/platform/mac/spellcheck_mac.h
  41. spellcheck/platform/mac/spellcheck_mac.mm
  42. spellcheck/platform/win/language_win.cpp
  43. spellcheck/platform/win/language_win.h
  44. spellcheck/platform/win/spellcheck_win.cpp
  45. spellcheck/platform/win/spellcheck_win.h
  46. spellcheck/platform/platform_language.h
  47. spellcheck/platform/platform_spellcheck.h
  48. spellcheck/third_party/language_cld3.cpp
  49. spellcheck/third_party/language_cld3.h
  50. spellcheck/third_party/hunspell_controller.cpp
  51. spellcheck/third_party/hunspell_controller.h
  52. spellcheck/third_party/spellcheck_hunspell.cpp
  53. spellcheck/third_party/spellcheck_hunspell.h
  54. spellcheck/spellcheck_types.h
  55. spellcheck/spellcheck_highlight_syntax.cpp
  56. spellcheck/spellcheck_highlight_syntax.h
  57. spellcheck/spellcheck_utils.cpp
  58. spellcheck/spellcheck_utils.h
  59. spellcheck/spellcheck_value.cpp
  60. spellcheck/spellcheck_value.h
  61. spellcheck/spelling_highlighter.cpp
  62. spellcheck/spelling_highlighter.h
  63. spellcheck/spelling_highlighter_helper.cpp
  64. spellcheck/spelling_highlighter_helper.h
  65. spellcheck/spellcheck_pch.h
  66. )
  67. target_prepare_qrc(lib_spellcheck)
  68. if (system_spellchecker)
  69. remove_target_sources(lib_spellcheck ${src_loc}
  70. spellcheck/third_party/spellcheck_hunspell.cpp
  71. spellcheck/third_party/spellcheck_hunspell.h
  72. )
  73. else()
  74. remove_target_sources(lib_spellcheck ${src_loc}
  75. spellcheck/platform/linux/linux_enchant.cpp
  76. spellcheck/platform/linux/linux_enchant.h
  77. spellcheck/platform/linux/spellcheck_linux.cpp
  78. spellcheck/platform/linux/spellcheck_linux.h
  79. spellcheck/platform/mac/spellcheck_mac.h
  80. spellcheck/platform/mac/spellcheck_mac.mm
  81. spellcheck/platform/win/spellcheck_win.cpp
  82. spellcheck/platform/win/spellcheck_win.h
  83. )
  84. endif()
  85. if (use_cld3)
  86. target_link_libraries(lib_spellcheck PRIVATE desktop-app::external_cld3)
  87. remove_target_sources(lib_spellcheck ${src_loc}
  88. spellcheck/platform/linux/language_linux.cpp
  89. spellcheck/platform/linux/language_linux.h
  90. spellcheck/platform/mac/language_mac.h
  91. spellcheck/platform/mac/language_mac.mm
  92. spellcheck/platform/win/language_win.cpp
  93. spellcheck/platform/win/language_win.h
  94. )
  95. else()
  96. remove_target_sources(lib_spellcheck ${src_loc}
  97. spellcheck/third_party/language_cld3.cpp
  98. spellcheck/third_party/language_cld3.h
  99. )
  100. endif()
  101. # We should support both types of spellchecker for Windows.
  102. if (WIN32 OR NOT system_spellchecker)
  103. target_link_libraries(lib_spellcheck PRIVATE desktop-app::external_hunspell)
  104. else()
  105. remove_target_sources(lib_spellcheck ${src_loc}
  106. spellcheck/third_party/hunspell_controller.cpp
  107. spellcheck/third_party/hunspell_controller.h
  108. )
  109. endif()
  110. target_include_directories(lib_spellcheck
  111. PUBLIC
  112. ${src_loc}
  113. )
  114. target_link_libraries(lib_spellcheck
  115. PRIVATE
  116. desktop-app::lib_ui
  117. desktop-app::lib_base
  118. desktop-app::lib_rpl
  119. desktop-app::lib_crl
  120. desktop-app::lib_prisma
  121. desktop-app::external_qt
  122. desktop-app::external_ranges
  123. desktop-app::external_gsl
  124. desktop-app::external_xxhash
  125. )
  126. if (LINUX AND use_enchant)
  127. find_package(PkgConfig REQUIRED)
  128. pkg_search_module(ENCHANT REQUIRED enchant-2 enchant)
  129. target_include_directories(lib_spellcheck SYSTEM PRIVATE ${ENCHANT_INCLUDE_DIRS})
  130. endif()