From d2642b4c0763e16ed5bc2338c0e53b7a82212678 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 17 Oct 2021 13:39:32 +0200 Subject: [PATCH] CMake: Enable wxUSE_SPELLCHECK Find gspell-1 when using GTK3. Also need to find enchant.h. --- build/cmake/init.cmake | 11 ++++++++ build/cmake/modules/FindGSPELL.cmake | 42 ++++++++++++++++++++++++++++ build/cmake/options.cmake | 1 + 3 files changed, 54 insertions(+) create mode 100644 build/cmake/modules/FindGSPELL.cmake diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index bd8152eded..b57c34f36d 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -563,6 +563,17 @@ if(wxUSE_GUI) else() set(wxUSE_LIBGNOMEVFS OFF) endif() + + if(WXGTK3 AND wxUSE_SPELLCHECK) + find_package(GSPELL) + if(GSPELL_FOUND) + list(APPEND wxTOOLKIT_INCLUDE_DIRS ${GSPELL_INCLUDE_DIRS}) + list(APPEND wxTOOLKIT_LIBRARIES ${GSPELL_LIBRARIES}) + else() + message(STATUS "gspell-1 not found, spell checking in wxTextCtrl won't be available") + wx_option_force_value(wxUSE_SPELLCHECK OFF) + endif() + endif() endif() # test if precompiled headers are supported using the cotire test project diff --git a/build/cmake/modules/FindGSPELL.cmake b/build/cmake/modules/FindGSPELL.cmake new file mode 100644 index 0000000000..5de7cd99d8 --- /dev/null +++ b/build/cmake/modules/FindGSPELL.cmake @@ -0,0 +1,42 @@ +# - Try to find gspell +# Once done this will define +# +# GSPELL_FOUND - system has gspell +# GSPELL_INCLUDE_DIRS - The include directory to use for the gspell headers +# GSPELL_LIBRARIES - Link these to use gspell + +find_package(PkgConfig) +pkg_check_modules(PC_GSPELL QUIET gspell-1) + +find_path(GSPELL_INCLUDE_DIRS + NAMES gspell/gspell.h + HINTS ${PC_GSPELL_INCLUDEDIR} + ${PC_GSPELL_INCLUDE_DIRS} +) + +find_library(GSPELL_LIBRARIES + NAMES gspell-1 + HINTS ${PC_GSPELL_LIBDIR} + ${PC_GSPELL_LIBRARY_DIRS} +) + +pkg_check_modules(PC_ENCHANT QUIET enchant-2 enchant) +find_path(ENCHANT_INCLUDE_DIRS + NAMES enchant.h + HINTS ${PC_ENCHANT_INCLUDEDIR} + ${PC_ENCHANT_INCLUDE_DIRS} + PATH_SUFFIXES enchant-2 enchant +) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSPELL DEFAULT_MSG GSPELL_INCLUDE_DIRS ENCHANT_INCLUDE_DIRS GSPELL_LIBRARIES) + +if(GSPELL_FOUND) + set(GSPELL_INCLUDE_DIRS ${GSPELL_INCLUDE_DIRS} ${ENCHANT_INCLUDE_DIRS}) +endif() + +mark_as_advanced( + GSPELL_INCLUDE_DIRS + GSPELL_LIBRARIES + ENCHANT_INCLUDE_DIRS +) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 610f293e5f..2e654436a8 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -190,6 +190,7 @@ wx_option(wxUSE_PRINTF_POS_PARAMS "use wxVsnprintf() which supports positional p wx_option(wxUSE_SECRETSTORE "use wxSecretStore class") wx_option(wxUSE_SNGLINST_CHECKER "use wxSingleInstanceChecker class") wx_option(wxUSE_SOUND "use wxSound class") +wx_option(wxUSE_SPELLCHECK "enable spellchecking in wxTextCtrl class (MSW and GTK3 only)") wx_option(wxUSE_STDPATHS "use wxStandardPaths class") wx_option(wxUSE_STOPWATCH "use wxStopWatch class") wx_option(wxUSE_STREAMS "use wxStream etc classes")