Skip to content

Move all examples to cpp-example-collection#83

Open
stephen-derosa wants to merge 4 commits intolivekit:mainfrom
stephen-derosa:sderosa/examples-migration
Open

Move all examples to cpp-example-collection#83
stephen-derosa wants to merge 4 commits intolivekit:mainfrom
stephen-derosa:sderosa/examples-migration

Conversation

@stephen-derosa
Copy link
Copy Markdown
Contributor

@stephen-derosa stephen-derosa commented Apr 2, 2026

Move all examples to cpp-example-collection repo.

Depends on:
livekit-examples/cpp-example-collection#4

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the in-repo examples/ tree and replaces it with a cpp-example-collection git submodule, integrating its build into the main SDK build when LIVEKIT_BUILD_EXAMPLES is enabled.

Changes:

  • Deleted all existing examples/** sources and the examples/CMakeLists.txt build.
  • Added a new cpp-example-collection submodule and a CMake integration helper to configure/build it.
  • Updated top-level CMake and gitignore to support the new examples workflow.

Reviewed changes

Copilot reviewed 50 out of 51 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
examples/tokens/set_integration_test_tokens.bash Removed token helper script as part of examples migration.
examples/tokens/README.md Removed token examples README as part of examples migration.
examples/tokens/gen_and_set.bash Removed token generation script as part of examples migration.
examples/simple_rpc/README.md Removed SimpleRpc technical README as part of examples migration.
examples/simple_rpc/main.cpp Removed SimpleRpc example source as part of examples migration.
examples/simple_room/main.cpp Removed SimpleRoom example source as part of examples migration.
examples/simple_room/fallback_capture.h Removed SimpleRoom fallback capture header as part of examples migration.
examples/simple_room/fallback_capture.cpp Removed SimpleRoom fallback capture implementation as part of examples migration.
examples/simple_joystick/utils.h Removed joystick example utility header as part of examples migration.
examples/simple_joystick/utils.cpp Removed joystick example utility implementation as part of examples migration.
examples/simple_joystick/sender.cpp Removed joystick sender example as part of examples migration.
examples/simple_joystick/receiver.cpp Removed joystick receiver example as part of examples migration.
examples/simple_joystick/json_utils.h Removed joystick JSON utilities header as part of examples migration.
examples/simple_joystick/json_utils.cpp Removed joystick JSON utilities implementation as part of examples migration.
examples/simple_data_stream/main.cpp Removed SimpleDataStream example source as part of examples migration.
examples/ping_pong/utils.h Removed ping/pong example utilities as part of examples migration.
examples/ping_pong/pong.cpp Removed pong participant example as part of examples migration.
examples/ping_pong/ping.cpp Removed ping participant example as part of examples migration.
examples/ping_pong/messages.h Removed ping/pong message definitions as part of examples migration.
examples/ping_pong/json_converters.h Removed ping/pong JSON converter header as part of examples migration.
examples/ping_pong/json_converters.cpp Removed ping/pong JSON converter implementation as part of examples migration.
examples/ping_pong/constants.h Removed ping/pong constants as part of examples migration.
examples/logging_levels/README.md Removed logging-levels README as part of examples migration.
examples/logging_levels/custom_sinks.cpp Removed custom sinks logging example as part of examples migration.
examples/logging_levels/basic_usage.cpp Removed basic logging usage example as part of examples migration.
examples/hello_livekit/sender.cpp Removed HelloLivekit sender example as part of examples migration.
examples/hello_livekit/receiver.cpp Removed HelloLivekit receiver example as part of examples migration.
examples/common/wav_audio_source.h Removed shared WAV source helper as part of examples migration.
examples/common/wav_audio_source.cpp Removed shared WAV source helper implementation as part of examples migration.
examples/common/sdl_video_renderer.h Removed shared SDL renderer helper as part of examples migration.
examples/common/sdl_video_renderer.cpp Removed shared SDL renderer helper implementation as part of examples migration.
examples/common/sdl_media.h Removed shared SDL media helper as part of examples migration.
examples/common/sdl_media.cpp Removed shared SDL media helper implementation as part of examples migration.
examples/common/sdl_media_manager.h Removed shared SDL media manager header as part of examples migration.
examples/common/sdl_media_manager.cpp Removed shared SDL media manager implementation as part of examples migration.
examples/CMakeLists.txt Removed examples build definition as part of examples migration.
examples/cmake/sdl3.cmake Removed SDL3 FetchContent helper used by in-tree examples.
examples/bridge_rpc/README.md Removed bridge RPC example docs as part of examples migration.
examples/bridge_rpc/custom_receiver.cpp Removed bridge RPC receiver example as part of examples migration.
examples/bridge_rpc/custom_caller.cpp Removed bridge RPC caller example as part of examples migration.
examples/bridge_mute_unmute/receiver.cpp Removed bridge mute/unmute receiver example as part of examples migration.
examples/bridge_mute_unmute/README.md Removed bridge mute/unmute docs as part of examples migration.
examples/bridge_mute_unmute/caller.cpp Removed bridge mute/unmute caller example as part of examples migration.
examples/bridge_human_robot/robot.cpp Removed bridge human/robot robot example as part of examples migration.
examples/bridge_human_robot/human.cpp Removed bridge human/robot human example as part of examples migration.
CMakeLists.txt Switched examples build from add_subdirectory(examples) to cpp-example-collection integration.
cmake/cpp-example-collection.cmake Added helper to install SDK then configure/build the cpp-example-collection submodule.
.gitmodules Added cpp-example-collection submodule entry.
.gitignore Ignored local-install/ used by the new examples build flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +47
add_custom_target(install_livekit_sdk_for_examples
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}"
--prefix "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
--config "$<CONFIG>"
DEPENDS livekit
COMMENT "Installing LiveKit SDK for cpp-example-collection"
VERBATIM
)

add_custom_target(cpp_example_collection ALL
COMMAND ${CMAKE_COMMAND} -S "${LIVEKIT_CPP_EXAMPLES_SOURCE_DIR}"
-B "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
-DCMAKE_PREFIX_PATH="${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
-DLiveKit_DIR="${LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR}"
COMMAND ${CMAKE_COMMAND} --build "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
--config "$<CONFIG>"
DEPENDS install_livekit_sdk_for_examples
COMMENT "Configuring and building cpp-example-collection"
VERBATIM
)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both install_livekit_sdk_for_examples and cpp_example_collection are custom targets with no declared OUTPUT/BYPRODUCTS. CMake generators treat these as always-out-of-date, so enabling LIVEKIT_BUILD_EXAMPLES will re-run the install + external configure/build steps on every build invocation. Consider switching to ExternalProject_Add or using stamp files via add_custom_command(OUTPUT ...) so these steps are incremental and only re-run when inputs change.

Copilot uses AI. Check for mistakes.
@stephen-derosa stephen-derosa force-pushed the sderosa/examples-migration branch 4 times, most recently from eb9b9bb to 7768e1d Compare April 8, 2026 20:13
@stephen-derosa stephen-derosa requested a review from Copilot April 9, 2026 00:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 53 out of 54 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


```bash
./build/examples/SimpleRoom --url $URL --token <jwt-token>
```bash`
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fenced code block opener has an extra backtick (bash`), which breaks Markdown rendering for the SimpleRoom command snippet. Change it to a standard code fence (bash) so the commands render correctly.

Suggested change
```bash`
```bash

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +13
"${CMAKE_SOURCE_DIR}/cpp-example-collection" ABSOLUTE)

get_filename_component(_lk_examples_install_default
"${CMAKE_SOURCE_DIR}/local-install" ABSOLUTE)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module computes paths relative to CMAKE_SOURCE_DIR. If LiveKit is used as a subproject (FetchContent/add_subdirectory), CMAKE_SOURCE_DIR points to the parent project, so the cpp-example-collection submodule will not be found. Use LIVEKIT_ROOT_DIR (already defined by this repo) or CMAKE_CURRENT_LIST_DIR/.. as the base instead.

Suggested change
"${CMAKE_SOURCE_DIR}/cpp-example-collection" ABSOLUTE)
get_filename_component(_lk_examples_install_default
"${CMAKE_SOURCE_DIR}/local-install" ABSOLUTE)
"${LIVEKIT_ROOT_DIR}/cpp-example-collection" ABSOLUTE)
get_filename_component(_lk_examples_install_default
"${LIVEKIT_ROOT_DIR}/local-install" ABSOLUTE)

Copilot uses AI. Check for mistakes.
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting SPDLOG_INSTALL to ON will cause the vendored spdlog project to be installed into the LiveKit SDK install prefix, even though spdlog is described as an internal/private dependency. If downstream consumers shouldn't rely on spdlog being bundled, keep SPDLOG_INSTALL OFF (or gate this behind an explicit option used only for the example-collection install).

Suggested change
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)

Copilot uses AI. Check for mistakes.
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to install SPDLOG here

CACHE PATH "Build directory for cpp-example-collection")

get_filename_component(LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR
"${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/LiveKit"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curiously, where CMAKE_INSTALL_LIBDIR is defined ? and what is its value ?

${_lk_examples_configure_args}
COMMAND ${CMAKE_COMMAND} --build "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
--config "$<CONFIG>"
DEPENDS install_livekit_sdk_for_examples
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to install it twice ?

@stephen-derosa stephen-derosa force-pushed the sderosa/examples-migration branch from d6d25dc to 2c81f13 Compare April 9, 2026 04:36
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.

3 participants