Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions indra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ else ()
option(USE_SDL_WINDOW "Build with SDL based window management and input (experimental on Windows)" OFF)
endif ()

# Spell checking backend
cmake_dependent_option(USE_NSSPELLCHECKER "Use the native macOS NSSpellChecker instead of Hunspell" ON "APPLE" OFF)
cmake_dependent_option(USE_WINSPELLCHECK "Use the native Windows Spell Checking API instead of Hunspell" ON "WIN32" OFF)

# Configure crash reporting
option(RELEASE_CRASH_REPORTING "Enable use of crash reporting in release builds" OFF)
option(NON_RELEASE_CRASH_REPORTING "Enable use of crash reporting in developer builds" OFF)
Expand Down Expand Up @@ -181,6 +185,10 @@ if(BUILD_DULLAHAN_EXAMPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "dullahan-example")
endif()

if (NOT USE_NSSPELLCHECKER AND NOT USE_WINSPELLCHECK)
list(APPEND VCPKG_MANIFEST_FEATURES "hunspell")
endif()

# Export compile_commands.json for ninja and makefile generators
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -275,6 +283,7 @@ include(Mesa)
include(Meshoptimizer)
include(Mikktspace)
include(NDOF)
include(NSSpellChecker)
include(NVAPI)
include(OpenAL)
include(OpenGL)
Expand All @@ -297,6 +306,7 @@ include(Vorbis)
include(WebP)
include(WebRTC)
include(websocketpp)
include(WinSpellCheck)
include(xxHash)
include(ZLIBNG)

Expand Down
10 changes: 7 additions & 3 deletions indra/cmake/Copy3rdPartyLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ if(WINDOWS)
endif()
elseif(DARWIN)
set(vcpkg_lib_dir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib")
set(release_libs
"libhunspell-1.7.0.dylib"
)
if (USE_NSSPELLCHECKER)
set(release_libs "")
else()
set(release_libs
"libhunspell-1.7.0.dylib"
)
endif()
elseif(LINUX)
set(vcpkg_lib_dir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib")
set(release_libs "")
Expand Down
8 changes: 5 additions & 3 deletions indra/cmake/Hunspell.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ include_guard()

add_library(ll::hunspell INTERFACE IMPORTED)

find_package(PkgConfig REQUIRED)
if (NOT USE_NSSPELLCHECKER AND NOT USE_WINSPELLCHECK)
find_package(PkgConfig REQUIRED)

pkg_check_modules(hunspell REQUIRED IMPORTED_TARGET GLOBAL hunspell)
target_link_libraries(ll::hunspell INTERFACE PkgConfig::hunspell)
pkg_check_modules(hunspell REQUIRED IMPORTED_TARGET GLOBAL hunspell)
target_link_libraries(ll::hunspell INTERFACE PkgConfig::hunspell)
endif()
11 changes: 11 additions & 0 deletions indra/cmake/NSSpellChecker.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- cmake -*-

include_guard()

if (USE_NSSPELLCHECKER)
# Link target for the macOS NSSpellChecker engine (llspellcheckengine_mac.mm). No compile
# definitions are needed: the engine is selected by which source CMake compiles, and the shared
# llspellcheck.h is platform-clean (it only forward-declares the abstract LLSpellCheckEngine).
add_library(ll::nsspellchecker INTERFACE IMPORTED)
target_link_libraries(ll::nsspellchecker INTERFACE "-framework AppKit" "-framework Foundation")
endif ()
13 changes: 13 additions & 0 deletions indra/cmake/WinSpellCheck.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- cmake -*-

include_guard()

if (USE_WINSPELLCHECK)
# Link target for the Windows Spell Checking engine (llspellcheckengine_win32.cpp). ole32 provides
# CoInitializeEx/CoCreateInstance/CoTaskMemFree/CoUninitialize; <spellcheck.h> ships with the
# Windows SDK and the API uses LPCWSTR (not BSTR), so no oleaut32/uuid.lib is required. No compile
# definitions are needed: the engine is selected by which source CMake compiles, and the shared
# llspellcheck.h is platform-clean (it only forward-declares the abstract LLSpellCheckEngine).
add_library(ll::winspellcheck INTERFACE IMPORTED)
target_link_libraries(ll::winspellcheck INTERFACE ole32)
endif ()
36 changes: 32 additions & 4 deletions indra/llui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target_sources(llui
llsearcheditor.cpp
llslider.cpp
llsliderctrl.cpp
llspellcheck.cpp
llspinctrl.cpp
llstatbar.cpp
llstatgraph.cpp
Expand Down Expand Up @@ -190,6 +189,7 @@ target_sources(llui
llsliderctrl.h
llslider.h
llspellcheck.h
llspellcheckengine.h
llspellcheckmenuhandler.h
llspinctrl.h
llstatbar.h
Expand Down Expand Up @@ -234,6 +234,20 @@ target_sources(llui
llxyvector.h
)

# Spell checking: the backend-agnostic LLSpellChecker core (llspellcheck.cpp) is always compiled;
# exactly one platform engine is selected by build option — native macOS NSSpellChecker
# (Objective-C++), native Windows Spell Checking API, or Hunspell (default).
target_sources(llui PRIVATE llspellcheck.cpp)
if (USE_NSSPELLCHECKER)
target_sources(llui PRIVATE llspellcheckengine_mac.mm)
set_source_files_properties(llspellcheckengine_mac.mm PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
elseif (USE_WINSPELLCHECK)
target_sources(llui PRIVATE llspellcheckengine_win32.cpp)
set_source_files_properties(llspellcheckengine_win32.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
else ()
target_sources(llui PRIVATE llspellcheckengine_hunspell.cpp)
endif ()

SET(llurlentry_TEST_DEPENDENCIES
llurlmatch.cpp
llurlregistry.cpp
Expand All @@ -259,14 +273,28 @@ target_link_libraries(llui
llxml
llmath
llcommon
ll::hunspell
)

if (USE_NSSPELLCHECKER)
target_link_libraries(llui PUBLIC ll::nsspellchecker)
elseif (USE_WINSPELLCHECK)
target_link_libraries(llui PUBLIC ll::winspellcheck)
else ()
target_link_libraries(llui PUBLIC ll::hunspell)
endif ()

target_precompile_headers(llui REUSE_FROM llprecompiled)

# Add tests
if(BUILD_TESTING)
set(test_libs llmessage llcorehttp llxml llrender llcommon ll::hunspell)
if (USE_NSSPELLCHECKER)
set(spellcheck_lib ll::nsspellchecker)
elseif (USE_WINSPELLCHECK)
set(spellcheck_lib ll::winspellcheck)
else ()
set(spellcheck_lib ll::hunspell)
endif ()
set(test_libs llmessage llcorehttp llxml llrender llcommon ${spellcheck_lib})

SET(llui_TEST_SOURCE_FILES
llurlmatch.cpp
Expand All @@ -275,7 +303,7 @@ if(BUILD_TESTING)
LL_ADD_PROJECT_UNIT_TESTS(llui "${llui_TEST_SOURCE_FILES}")

# INTEGRATION TESTS
set(test_libs llui llmessage llcorehttp llxml llrender llcommon ll::hunspell)
set(test_libs llui llmessage llcorehttp llxml llrender llcommon ${spellcheck_lib})
set(test_project llui)
LL_ADD_INTEGRATION_TEST(llurlentry llurlentry.cpp "${test_libs}" "${test_project}")
LL_ADD_INTEGRATION_TEST(llemojidictionary llemojidictionary.cpp "${test_libs}" "${test_project}")
Expand Down
Loading
Loading