diff --git a/build/fbcode_builder/CMake/RustStaticLibrary.cmake b/build/fbcode_builder/CMake/RustStaticLibrary.cmake index 9e4be959fb9a86..e6f839bdfacb37 100644 --- a/build/fbcode_builder/CMake/RustStaticLibrary.cmake +++ b/build/fbcode_builder/CMake/RustStaticLibrary.cmake @@ -363,7 +363,7 @@ endfunction() # `${TARGET}` CMake library target. # # ```cmake -# rust_cxx_bridge( [CRATE ]) +# rust_cxx_bridge( [CRATE ] [LIBS ]) # ``` # # Parameters: @@ -374,9 +374,11 @@ endfunction() # - CRATE_NAME: # Name of the crate. This parameter is optional. If unspecified, it will # fallback to `${TARGET}`. +# - LIBS [ ...]: +# A list of libraries that this library depends on. # function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) - fb_cmake_parse_args(ARG "" "CRATE" "" "${ARGN}") + fb_cmake_parse_args(ARG "" "CRATE" "LIBS" "${ARGN}") if(DEFINED ARG_CRATE) set(crate_name "${ARG_CRATE}") @@ -476,6 +478,11 @@ function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) $ $ ) + target_link_libraries( + ${crate_name} + PUBLIC + ${ARG_LIBS} + ) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rust") add_custom_command( @@ -517,10 +524,11 @@ function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) COMMENT "Generating cxx bindings for crate ${crate_name}" ) - target_sources(${crate_name} + target_sources( + ${crate_name} PRIVATE - "${CMAKE_CURRENT_BINARY_DIR}/${cxx_header}" - "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h" - "${CMAKE_CURRENT_BINARY_DIR}/${cxx_source}" + "${CMAKE_CURRENT_BINARY_DIR}/${cxx_header}" + "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h" + "${CMAKE_CURRENT_BINARY_DIR}/${cxx_source}" ) endfunction()