Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ configure_file(
find_program(CARGO_EXECUTABLE NAMES cargo REQUIRED)

# Determine Rust target triple for cross-compilation on macOS
set(RUST_TARGET_TRIPLE "")
# (may also be pre-set by a cross toolchain file, e.g. cross/toolchain-ameba-armv7.cmake)
if(NOT DEFINED RUST_TARGET_TRIPLE)
set(RUST_TARGET_TRIPLE "")
endif()
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
set(RUST_TARGET_TRIPLE "x86_64-apple-darwin")
Expand Down Expand Up @@ -256,7 +259,7 @@ if(NOT DEFINED CARGO)
message(FATAL_ERROR \"CARGO not set\")
endif()

set(ARGS build)
set(ARGS build -p livekit-ffi)
if(NOT CFG STREQUAL \"Debug\")
list(APPEND ARGS --release)
endif()
Expand Down
30 changes: 23 additions & 7 deletions cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,19 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "" FORCE)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(protobuf_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(protobuf_BUILD_CONFORMANCE OFF CACHE BOOL "" FORCE)
set(protobuf_BUILD_PROTOC_BINARIES ON CACHE BOOL "" FORCE)
if(CMAKE_CROSSCOMPILING)
# protoc must run on the build host, so don't cross-compile it; a host
# protoc matching LIVEKIT_PROTOBUF_VERSION must be provided instead via
# -DProtobuf_PROTOC_EXECUTABLE.
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "" FORCE)
if(NOT Protobuf_PROTOC_EXECUTABLE)
message(FATAL_ERROR
"Cross-compiling: pass -DProtobuf_PROTOC_EXECUTABLE=<host protoc "
"v${LIVEKIT_PROTOBUF_VERSION} binary>")
endif()
else()
set(protobuf_BUILD_PROTOC_BINARIES ON CACHE BOOL "" FORCE)
endif()
set(protobuf_WITH_ZLIB OFF CACHE BOOL "" FORCE)

set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE)
Expand Down Expand Up @@ -198,12 +210,16 @@ foreach(_livekit_protobuf_target IN LISTS _livekit_protobuf_targets)
endforeach()

# Protobuf targets: modern protobuf exports protobuf::protoc etc.
if(TARGET protobuf::protoc)
set(Protobuf_PROTOC_EXECUTABLE "$<TARGET_FILE:protobuf::protoc>" CACHE STRING "protoc (vendored)" FORCE)
elseif(TARGET protoc)
set(Protobuf_PROTOC_EXECUTABLE "$<TARGET_FILE:protoc>" CACHE STRING "protoc (vendored)" FORCE)
else()
message(FATAL_ERROR "Vendored protobuf did not create a protoc target")
# When cross-compiling, protoc binaries are not built; the host protoc
# supplied via Protobuf_PROTOC_EXECUTABLE is used as-is.
if(NOT CMAKE_CROSSCOMPILING)
if(TARGET protobuf::protoc)
set(Protobuf_PROTOC_EXECUTABLE "$<TARGET_FILE:protobuf::protoc>" CACHE STRING "protoc (vendored)" FORCE)
elseif(TARGET protoc)
set(Protobuf_PROTOC_EXECUTABLE "$<TARGET_FILE:protoc>" CACHE STRING "protoc (vendored)" FORCE)
else()
message(FATAL_ERROR "Vendored protobuf did not create a protoc target")
endif()
endif()

# Prefer protobuf-lite (optional; keep libprotobuf around too)
Expand Down
Loading