Skip to content

Commit 8abddba

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 f31cc32 commit 8abddba

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

examples/CMakeLists.txt

Lines changed: 45 additions & 14 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,8 +30,13 @@ add_executable(SimpleRoom
2430
simple_room/wav_audio_source.h
2531
)
2632

27-
target_link_libraries(SimpleRoom PRIVATE livekit SDL3::SDL3)
28-
livekit_windows_link_deps(SimpleRoom)
33+
target_include_directories(SimpleRoom PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
34+
35+
target_link_libraries(SimpleRoom
36+
PRIVATE
37+
livekit
38+
SDL3::SDL3
39+
)
2940

3041
add_custom_command(TARGET SimpleRoom POST_BUILD
3142
COMMAND ${CMAKE_COMMAND} -E copy_directory
@@ -47,6 +58,8 @@ add_executable(SimpleRpc
4758
simple_rpc/main.cpp
4859
)
4960

61+
target_include_directories(SimpleRpc PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
62+
5063
target_link_libraries(SimpleRpc
5164
PRIVATE
5265
nlohmann_json::nlohmann_json
@@ -57,6 +70,8 @@ add_executable(SimpleDataStream
5770
simple_data_stream/main.cpp
5871
)
5972

73+
target_include_directories(SimpleDataStream PRIVATE ${EXAMPLES_PRIVATE_INCLUDE_DIRS})
74+
6075
target_link_libraries(SimpleDataStream
6176
PRIVATE
6277
livekit
@@ -70,12 +85,28 @@ add_custom_command(
7085
$<TARGET_FILE_DIR:SimpleDataStream>/data
7186
)
7287

73-
if (WIN32 AND TARGET SDL3::SDL3)
74-
foreach(tgt SimpleRoom SimpleRpc SimpleDataStream)
75-
add_custom_command(TARGET ${tgt} POST_BUILD
76-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
77-
$<TARGET_FILE:SDL3::SDL3>
78-
$<TARGET_FILE_DIR:${tgt}>
79-
)
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()
80111
endforeach()
81112
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)