@@ -46,6 +46,44 @@ protobuf_generate(
4646 IMPORT_DIRS ${FFI_PROTO_DIR}
4747)
4848
49+ ########### auto-gen build.h #######################
50+
51+ # Where to place the generated header
52+ set (GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /generated" )
53+ file (MAKE_DIRECTORY "${GENERATED_INCLUDE_DIR} " )
54+
55+ # Try to capture git commit; fall back to "unknown" if git isn't available or repo isn't present.
56+ set (GIT_COMMIT "unknown" )
57+ find_package (Git QUIET )
58+ if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR} /.git" )
59+ execute_process (
60+ COMMAND "${GIT_EXECUTABLE} " rev-parse --short HEAD
61+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} "
62+ OUTPUT_VARIABLE GIT_COMMIT
63+ OUTPUT_STRIP_TRAILING_WHITESPACE
64+ ERROR_QUIET
65+ )
66+ endif ()
67+
68+ # Build timestamp
69+ string (TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S" )
70+
71+ # Comment shown at the top of the generated header
72+ set (GENERATED_COMMENT "This file was auto-generated by CMake on ${LIVEKIT_BUILD_DATE} . Do NOT edit manually. Edit build.h.in instead." )
73+
74+ # Generate the header from the template
75+ configure_file (
76+ "${CMAKE_CURRENT_SOURCE_DIR} /build.h.in"
77+ "${GENERATED_INCLUDE_DIR} /build.h"
78+ @ONLY
79+ )
80+
81+ # Include the directory for the headers
82+ include_directories ("${GENERATED_INCLUDE_DIR} " )
83+
84+
85+ ########### Livekit Rust SDK #######################
86+
4987# Find cargo
5088find_program (CARGO_EXECUTABLE NAMES cargo REQUIRED)
5189
@@ -129,6 +167,7 @@ target_include_directories(livekit PUBLIC
129167 ${CMAKE_SOURCE_DIR} /src
130168 ${RUST_ROOT} /livekit-ffi/include
131169 ${PROTO_BINARY_DIR}
170+ ${GENERATED_INCLUDE_DIR}
132171)
133172
134173target_link_libraries (livekit
@@ -143,45 +182,6 @@ message(STATUS "Protobuf: version=${Protobuf_VERSION}; protoc=${Protobuf_PROTOC_
143182add_dependencies (livekit build_rust_ffi)
144183
145184
146- ########### auto-gen build.h #######################
147-
148- # Where to place the generated header
149- set (GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /generated" )
150- file (MAKE_DIRECTORY "${GENERATED_INCLUDE_DIR} " )
151-
152- # Try to capture git commit; fall back to "unknown" if git isn't available or repo isn't present.
153- set (GIT_COMMIT "unknown" )
154- find_package (Git QUIET )
155- if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR} /.git" )
156- execute_process (
157- COMMAND "${GIT_EXECUTABLE} " rev-parse --short HEAD
158- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} "
159- OUTPUT_VARIABLE GIT_COMMIT
160- OUTPUT_STRIP_TRAILING_WHITESPACE
161- ERROR_QUIET
162- )
163- endif ()
164-
165- # Build timestamp
166- string (TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S" )
167-
168- # Comment shown at the top of the generated header
169- set (GENERATED_COMMENT "This file was auto-generated by CMake on ${LIVEKIT_BUILD_DATE} . Do NOT edit manually. Edit build.h.in instead." )
170-
171- # Generate the header from the template
172- configure_file (
173- "${CMAKE_CURRENT_SOURCE_DIR} /build.h.in"
174- "${GENERATED_INCLUDE_DIR} /build.h"
175- @ONLY
176- )
177-
178- # Make the generated header available to your targets:
179- # (Option A) Global include dir
180- include_directories ("${GENERATED_INCLUDE_DIR} " )
181-
182- # (Option B) Or, per-target (recommended):
183- # target_include_directories(<your_target> PRIVATE "${GENERATED_INCLUDE_DIR}")
184-
185185########### Platform specific settings ###########
186186
187187if (APPLE )
0 commit comments