Skip to content

The set of scripts allowing to plug vanilla IDL files from Microsoft Windows / Speech SDKs to be used with FOSS C/C++ compilers

Notifications You must be signed in to change notification settings

KOLANICH-libs/MinGWSAPI5SDK.cmake

Repository files navigation

Set of scripts to use vanilla SAPI 5 SDK with FOSS toolchains

Set of CMake scripts to use vanilla SAPI 5 SDK with FOSS toolchains Such as MinGW-w64 with GCC and Clang as compilers.

Headers provided with the compilers mentioned often lack some classes and interfaces. The solution is to use vanilla SDK provided by Microsoft. The problem is that that the headers in the SDK were generated with MIDL, that generates the code that is meant to be compiled using Visual Studio - Microsoft proprietary compiler and IDE, and mainly cannot be compiled with GCC.

Fortunately, Component Object Model was designed for interoperability, and Microsoft also ship IDL files as a part of this SDK, so the needed headers can be regenerated using widl - an IDL compiler, that generates code to be used with FOSS toolchains.

So, this project is a CMake module, allowing you to automatically recompile needed IDL files into headers, that can be used with FOSS toolchains.

Prerequirements

You will need:

  • Sources of Wine and idl files from MinGW-w64. Some core IDL files have to be taken from there.
  • A bleeding edge version of widl. MinGW-w64 has widl, but not all the critical bugs are fixed there. Currently can be built only by compiling Wine (it is OK to stop right after it has built widl), but I have moved it into a separate repo. You will need its dependencies too.
  • Windows 10 SDK. It doesn't matter uf you gonna compile to Windows XP - Component Object Model was designed for compatibility, XP will just ignore the stuff for 7. Earlier versions of the SDK are also available.
  • GCC or Clang compiler. Our widl crash workaround app uses inline assembly with AT&T syntax. Also, cross-compilation is not yet supported. We should fix the bugs causing crashes in widl to get rid of the workaround.

Using the module

  1. Add a git submodule pointing to this repo.
  2. Use the code below after you have created a target for your module. Because some of CMake commands would require you to already have a target.
  3. Add the code like that:
if(MINGW)
	include(MinGWSAPI5SDK)  # Include our module. Should be in CMAKE_MODULE_PATH
	createMinGWSAPI5SDK(yourNameForTargetsForSAPI5Headers)  # Transpiles the needed IDLs into the headers
	add_dependencies(your_sapi5_module_target SAPI_SDK_FOR_MinGW)
	target_include_directories(your_sapi5_module_target PRIVATE "${yourNameForTargetsForSAPI5Headers_include}")
	target_link_libraries(your_sapi5_module_target PRIVATE "yourNameForTargetsForSAPI5Headers_uuids")  # some required symbols in the original SDK are neither in the headers, nor in the shared lib. Instead they are in MSVC-specific static lib. Fortunately, the IDL files contain some info, that is enough to recreate them. So we extract the info with a regex and create a C file with it, and compile it. You have to link it, if you have to use the symbols.
elseif(MSVC)
	# do something else
endif()

CMake configuration

About

The set of scripts allowing to plug vanilla IDL files from Microsoft Windows / Speech SDKs to be used with FOSS C/C++ compilers

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages