Skip to content

Commit f03e3a0

Browse files
committed
fix: complete cross-platform examples build support
- Add include paths for all examples (src/, generated/, protobuf) - Copy DLLs to examples output on Windows - Use FetchContent for SDL3 on all platforms - Remove sdl3 from vcpkg.json (not in baseline)
1 parent fc6490c commit f03e3a0

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

examples/CMakeLists.txt

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ project(livekit-examples)
44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

7-
find_package(SDL3 CONFIG QUIET)
8-
if(NOT SDL3_FOUND)
9-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10-
include(sdl3)
11-
endif()
7+
# Always use FetchContent for SDL3 (vcpkg doesn't have it in stable baseline)
8+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
9+
include(sdl3)
10+
11+
# Common include directories for examples that need private headers
12+
# TODO: These should be refactored to use only public headers
13+
set(EXAMPLES_PRIVATE_INCLUDE_DIRS
14+
${LIVEKIT_ROOT_DIR}/src
15+
${LIVEKIT_BINARY_DIR}/generated
16+
${Protobuf_INCLUDE_DIRS}
17+
)
1218

1319
add_executable(SimpleRoom
1420
simple_room/main.cpp
@@ -24,6 +30,8 @@ add_executable(SimpleRoom
2430
simple_room/wav_audio_source.h
2531
)
2632

33+
target_include_directories(SimpleRoom PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
34+
2735
target_link_libraries(SimpleRoom
2836
PRIVATE
2937
livekit
@@ -50,6 +58,8 @@ add_executable(SimpleRpc
5058
simple_rpc/main.cpp
5159
)
5260

61+
target_include_directories(SimpleRpc PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
62+
5363
target_link_libraries(SimpleRpc
5464
PRIVATE
5565
nlohmann_json::nlohmann_json
@@ -60,6 +70,8 @@ add_executable(SimpleDataStream
6070
simple_data_stream/main.cpp
6171
)
6272

73+
target_include_directories(SimpleDataStream PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
74+
6375
target_link_libraries(SimpleDataStream
6476
PRIVATE
6577
livekit
@@ -71,4 +83,30 @@ add_custom_command(
7183
COMMAND ${CMAKE_COMMAND} -E copy_directory
7284
${LIVEKIT_ROOT_DIR}/data
7385
$<TARGET_FILE_DIR:SimpleDataStream>/data
74-
)
86+
)
87+
88+
# Windows: Copy required DLLs to examples output directory
89+
if(WIN32)
90+
# Get the livekit library output directory (where DLLs are copied during main build)
91+
set(LIVEKIT_LIB_DIR $<TARGET_FILE_DIR:livekit>)
92+
93+
# List of DLLs to copy
94+
set(REQUIRED_DLLS
95+
"livekit_ffi.dll"
96+
"libprotobuf.dll"
97+
"abseil_dll.dll"
98+
)
99+
100+
# Copy DLLs to each example's output directory
101+
foreach(EXAMPLE SimpleRoom SimpleRpc SimpleDataStream)
102+
foreach(DLL ${REQUIRED_DLLS})
103+
add_custom_command(TARGET ${EXAMPLE} POST_BUILD
104+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
105+
"${LIVEKIT_LIB_DIR}/${DLL}"
106+
"$<TARGET_FILE_DIR:${EXAMPLE}>/${DLL}"
107+
COMMENT "Copying ${DLL} to ${EXAMPLE} output directory"
108+
VERBATIM
109+
)
110+
endforeach()
111+
endforeach()
112+
endif()

vcpkg.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"examples": {
1818
"description": "Build example applications",
1919
"dependencies": [
20-
"sdl3",
2120
"nlohmann-json"
2221
]
2322
}

0 commit comments

Comments
 (0)