Add SRAL_DISABLE_UIA CMake option to optionally exclude UIA support#23
Add SRAL_DISABLE_UIA CMake option to optionally exclude UIA support#23m1maker merged 1 commit intom1maker:mainfrom
Conversation
Add SRAL_DISABLE_UIA option (default OFF) to conditionally compile UIA
There was a problem hiding this comment.
Pull request overview
This PR adds a CMake option SRAL_DISABLE_UIA to conditionally exclude UI Automation (UIA) support from the SRAL library, addressing static linking conflicts that can occur with UIA in some projects.
Key Changes:
- Adds
SRAL_DISABLE_UIACMake option (default OFF) to control UIA compilation - Conditionally compiles UIA-related source files and links uiautomationcore.lib
- Changes default MSVC runtime library from static to dynamic linking
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| CMakeLists.txt | Adds SRAL_DISABLE_UIA option, conditionally includes UIA sources and libraries, and changes default runtime library to dynamic linking |
| SRC/SRAL.cpp | Guards UIA header include, engine initialization, and Narrator process detection with SRAL_NO_UIA preprocessor checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -317,7 +321,7 @@ static BOOL FindProcess(const wchar_t* name) { | |||
| #endif | |||
| static void speech_engine_update() { | |||
| if (!g_currentEngine || !g_currentEngine->GetActive() || g_currentEngine->GetNumber() == SRAL_ENGINE_SAPI || g_currentEngine->GetNumber() == SRAL_ENGINE_UIA || g_currentEngine->GetNumber() == SRAL_ENGINE_AV_SPEECH) { | |||
There was a problem hiding this comment.
When SRAL_NO_UIA is defined, the condition still checks for SRAL_ENGINE_UIA even though the UIA engine is never initialized. This comparison against SRAL_ENGINE_UIA will never be true when UIA is disabled, but the check itself can still execute. Consider wrapping the SRAL_ENGINE_UIA check in the condition with a preprocessor directive to avoid the unnecessary comparison when UIA is disabled.
| # Allow runtime library to be set externally; default to dynamic if not set | ||
| if(NOT CMAKE_MSVC_RUNTIME_LIBRARY) |
There was a problem hiding this comment.
This change modifies the default runtime library from static (MultiThreaded) to dynamic (MultiThreadedDLL), which is unrelated to the UIA feature toggle. This is a breaking change that could affect existing users who depend on static linking and should be documented or split into a separate PR. If this change is intentional and related to UIA compatibility issues, it should be explained in the PR description.
| # Allow runtime library to be set externally; default to dynamic if not set | |
| if(NOT CMAKE_MSVC_RUNTIME_LIBRARY) | |
| # Allow runtime library to be set externally; optionally enable dynamic CRT | |
| option(SRAL_USE_DYNAMIC_MSVC_RUNTIME "Use dynamic MSVC runtime library (/MD, /MDd)" OFF) | |
| if(SRAL_USE_DYNAMIC_MSVC_RUNTIME AND NOT CMAKE_MSVC_RUNTIME_LIBRARY) |
Add SRAL_DISABLE_UIA option (default OFF) to conditionally compile UIA
Sometimes uia conflicts with static linking sral in some projects.