From 11a49a51229b9c51b16f101dfa1a0609bc63638b Mon Sep 17 00:00:00 2001 From: Jesse Jurman Date: Wed, 18 Mar 2026 00:41:17 -0400 Subject: [PATCH] New Flag SRAL_DISABLE_NSSPEECH for iOS support --- CMakeLists.txt | 10 +++++++++- SRC/SRAL.cpp | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52c5d6c..42e0356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ endif() project ("SRAL") option (BUILD_SRAL_TEST "Build SRAL examples/tests" ON) option (SRAL_DISABLE_UIA "Disable UIA (UI Automation) support" OFF) +option (SRAL_DISABLE_NSSPEECH "Disable NSSpeech (macOS-only NSSpeechSynthesizer) support" OFF) add_library(${PROJECT_NAME}_obj OBJECT) target_sources(${PROJECT_NAME}_obj PRIVATE "SRC/Encoding.h" "SRC/Encoding.cpp" @@ -41,7 +42,11 @@ if(WIN32) endif() elseif(APPLE) target_sources(${PROJECT_NAME}_obj PRIVATE - "SRC/AVSpeech.h" "SRC/AVSpeech.mm" "SRC/NSSpeech.h" "SRC/NSSpeech.mm" "SRC/VoiceOver.h" "SRC/VoiceOver.mm") + "SRC/AVSpeech.h" "SRC/AVSpeech.mm" "SRC/VoiceOver.h" "SRC/VoiceOver.mm") + if(NOT SRAL_DISABLE_NSSPEECH) + target_sources(${PROJECT_NAME}_obj PRIVATE + "SRC/NSSpeech.h" "SRC/NSSpeech.mm") + endif() else() target_sources(${PROJECT_NAME}_obj PRIVATE "Dep/utf-8.h" "Dep/utf-8.c" "SRC/SpeechDispatcher.h" "SRC/SpeechDispatcher.cpp") @@ -54,6 +59,9 @@ target_compile_definitions(${PROJECT_NAME}_obj PRIVATE _CRT_SECURE_NO_WARNINGS) if(SRAL_DISABLE_UIA) target_compile_definitions(${PROJECT_NAME}_obj PRIVATE SRAL_NO_UIA) endif() +if(SRAL_DISABLE_NSSPEECH) + target_compile_definitions(${PROJECT_NAME}_obj PRIVATE SRAL_NO_NSSPEECH) +endif() if(BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} SHARED diff --git a/SRC/SRAL.cpp b/SRC/SRAL.cpp index 9d62376..9e843ce 100644 --- a/SRC/SRAL.cpp +++ b/SRC/SRAL.cpp @@ -14,7 +14,9 @@ #include #elif defined(__APPLE__) #include "AVSpeech.h" +#ifndef SRAL_NO_NSSPEECH #include "NSSpeech.h" +#endif #include "VoiceOver.h" #else #include "SpeechDispatcher.h" @@ -229,7 +231,9 @@ extern "C" SRAL_API bool SRAL_Initialize(int engines_exclude) { #elif defined(__APPLE__) g_engines[SRAL_ENGINE_VOICE_OVER] = std::make_unique(); g_engines[SRAL_ENGINE_AV_SPEECH] = std::make_unique(); +#ifndef SRAL_NO_NSSPEECH g_engines[SRAL_ENGINE_NS_SPEECH] = std::make_unique(); +#endif #else g_engines[SRAL_ENGINE_SPEECH_DISPATCHER] = std::make_unique(); #endif