Skip to content

Conversation

@Sqhh99
Copy link

@Sqhh99 Sqhh99 commented Dec 29, 2025

This pull request introduces significant improvements to the build system for cross-platform support, dependency management, and artifact handling. The changes migrate the build workflow to use CMake presets and vcpkg for dependencies, streamline Rust FFI integration, and enhance Windows support. The build outputs and artifact uploads are now more consistent across platforms.

Build System and Dependency Management

  • Migrated build workflow to use CMake presets and vcpkg, enabling consistent dependency management and configuration across Linux, macOS, and Windows. Added build.bat, vcpkg.json, and CMakePresets.json to tracked files. (.github/workflows/builds.yml, [1] [2]
  • Added vcpkg setup and cache environment variables to GitHub Actions workflow for improved dependency caching and installation. (.github/workflows/builds.yml, .github/workflows/builds.ymlL50-L85)
  • Updated system dependencies installation steps for Linux and macOS, removing direct protobuf installation in favor of vcpkg-managed dependencies. (.github/workflows/builds.yml, .github/workflows/builds.ymlL50-L85)

Cross-Platform Build and Artifact Handling

  • Enabled Windows builds in the workflow matrix, added platform-specific CMake presets, and standardized build, test, and artifact upload steps for all platforms. (.github/workflows/builds.yml, [1] [2]
  • Improved post-build steps to copy public headers, Rust FFI libraries, and third-party DLLs (on Windows) to output directories for easier packaging and consumption. (CMakeLists.txt, CMakeLists.txtL217-L243)

CMake and Project Structure Enhancements

  • Refactored CMakeLists.txt to set project version, root/binary directories, and output paths based on platform. Added options for building examples and using vcpkg. (CMakeLists.txt, CMakeLists.txtL1-R55)
  • Improved Rust FFI integration: added custom commands for building Rust libraries, handling DLLs/import libraries on Windows, and removing problematic symbols on Linux. (CMakeLists.txt, CMakeLists.txtL122-R226)
  • Updated target include and link directories to use modern CMake idioms and ensure correct header/library placement for consumers. (CMakeLists.txt, CMakeLists.txtL217-L243)

Abseil and Protobuf Handling

  • Improved Abseil linking logic for projects using Protobuf >= 6, switching to private linking and handling both modern and legacy package names. (CMakeLists.txt, CMakeLists.txtL286-R421)

Related Issue: Fixes #23

Note to maintainers: I've implemented the build.cmd with automatic LIBCLANG_PATH detection to make the environment setup as smooth as possible for Windows users.

  livekit.vcxproj -> D:\workspace\lib-workspace\client-sdk-cpp\build\Release\livekit.lib
  SimpleDataStream.vcxproj -> D:\workspace\lib-workspace\client-sdk-cpp\build\examples\Release\SimpleDataStream.exe
  SimpleRoom.vcxproj -> D:\workspace\lib-workspace\client-sdk-cpp\build\examples\Release\SimpleRoom.exe
  SimpleRpc.vcxproj -> D:\workspace\lib-workspace\client-sdk-cpp\build\examples\Release\SimpleRpc.exe
Build Succeeded.
- Fix "file path too long" errors by switching from CMAKE_SOURCE_DIR
  to CMAKE_CURRENT_SOURCE_DIR for relative path resolution.
- Refactor CMakeLists.txt to support nested project usage via
  LIVEKIT_IS_TOPLEVEL check.
- Align MSVC runtime library with Rust static CRT (MultiThreaded)
  to prevent link-time conflicts.
- Implement unified binary output directory (bin/lib/include) with
  config-specific subfolders.
- Add robust cargo build integration using run_cargo.cmake script.
- Introduce install logic and full clean targets (clean_all).
- Added CMakePresets.json for unified cross-platform build configurations.
- Optimized Rust FFI build logic to prevent unnecessary recompilation when C++ code changes.
- Fixed MSVC runtime library (MT/MD) mismatch on Windows.
- Added automatic header aggregation to build/include directory.
- Refactored CMakeLists.txt to support both top-level and subdirectory integration.
…cies

- Add GitHub Actions workflow for Windows, Linux, and macOS
- Integrate vcpkg manifest mode with CMake Presets
- Fix missing Linux dependencies (libva, alsa, libclang, etc.)
- Add CXXFLAGS to ignore deprecated warnings from WebRTC on newer GCC
- Synchronize git submodules and fix protocol file paths
- Configure build.h template for build metadata injection
- Remove livekit_ffi.h inclusion from public participant.h
- Add livekit_ffi.h to room.cpp for internal access to INVALID_HANDLE
- Improve header encapsulation by hiding internal FFI definitions from SDK users
…T conflicts

Motivation:
The prebuilt libwebrtc library is strictly compiled with the /MT runtime,
causing severe symbol redefinition and runtime mismatch errors (LNK2038)
when linked against /MD-based Qt applications.

Changes:
1. Architecture Redesign: Refactored livekit-ffi to build as a shared library
   (cdylib/DLL) instead of a static library on Windows.
2. Binary Isolation: Leveraged the DLL boundary to encapsulate /MT dependencies,
   allowing the consumer layer (livekit.lib) to safely use /MD.
3. CMake Infrastructure Enhancements:
   - Explicitly set CMAKE_MSVC_RUNTIME_LIBRARY to MultiThreadedDLL for
     MSVC targets.
   - Automated the Rust build pipeline with PROTOC environment variable
     injection for protobuf generation.
   - Added POST_BUILD commands to automatically deploy livekit_ffi.dll and
     third-party dependencies (protobuf, abseil) to the output directory.
4. Platform Consistency: Maintained the original static linking logic for
   Linux and macOS to preserve performance and simplicity.

Verification:
Validated the generated livekit.lib using `dumpbin /DIRECTIVES`, confirming
the RuntimeLibrary is correctly set to MD_DynamicRelease.
@CLAassistant
Copy link

CLAassistant commented Dec 29, 2025

CLA assistant check
All committers have signed the CLA.

@Sqhh99 Sqhh99 closed this Dec 29, 2025
@Sqhh99 Sqhh99 reopened this Dec 29, 2025
@Sqhh99 Sqhh99 closed this Dec 29, 2025
@Sqhh99 Sqhh99 deleted the sqhh99/windows-vcpkg-support branch December 29, 2025 14:44
@Sqhh99 Sqhh99 mentioned this pull request Dec 29, 2025
@xianshijing-lk
Copy link
Collaborator

The PR looks good, why it was closed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I've forked the project to add Windows support and vcpkg dependency management. Can I submit a PR?

3 participants