cmake: update RustStaticLibrary.cmake to hook up cargo dependencies

Summary:
Update `RustStaticLibrary.cmake` to let CMake know that running `cargo` will
produce the Rust static library output.  Without this CMake does not know how
to correctly wire up dependencies for libraries.  Previously the code used the
`ALL` target to ensure that the Rust static library was built, but this did
not ensure that it was built before executables that require it.

Reviewed By: pkaush

Differential Revision: D18588010

fbshipit-source-id: 1a1880993bdfa3fcb876a0f6507e5cddfea9b738
This commit is contained in:
Adam Simpkins 2019-11-20 12:26:31 -08:00 committed by Facebook Github Bot
parent 55d980ee42
commit 344661b651

View File

@ -120,7 +120,7 @@ function(rust_static_library TARGET)
endif()
add_custom_target(
${cargo_target} ALL
${cargo_target}
COMMAND
"${CMAKE_COMMAND}" -E env
"CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}"
@ -128,6 +128,9 @@ function(rust_static_library TARGET)
${cargo_cmd}
COMMENT "Building Rust crate '${crate_name}'..."
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
BYPRODUCTS
"${CMAKE_CURRENT_BINARY_DIR}/debug/${staticlib_name}"
"${CMAKE_CURRENT_BINARY_DIR}/release/${staticlib_name}"
)
add_library(${TARGET} INTERFACE)