forked from ROMEO/obsw
40 lines
1.2 KiB
CMake
40 lines
1.2 KiB
CMake
################################################
|
|
# Mission code in rust
|
|
# exports code as static library `mission_rust`
|
|
################################################
|
|
|
|
|
|
|
|
#TODO can we get CMake to configure cmake --build --clean to run cargo clean?
|
|
#TODO look into corrosion cmake plugin
|
|
|
|
if (${CMAKE_CROSSCOMPILING})
|
|
|
|
add_custom_target(
|
|
mission_rust_internal
|
|
COMMAND cargo build -Zbuild-std=core --target=${CMAKE_SYSTEM_PROCESSOR} $<$<CONFIG:Release>:--release>
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
)
|
|
|
|
add_library(mission_rust INTERFACE)
|
|
|
|
add_dependencies(mission_rust mission_rust_internal)
|
|
|
|
target_link_libraries(mission_rust INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/target/${CMAKE_SYSTEM_PROCESSOR}/$<IF:$<CONFIG:Release>,release,debug>/libmission_rust.a)
|
|
|
|
else()
|
|
|
|
add_custom_target(
|
|
mission_rust_internal
|
|
COMMAND cargo build $<$<CONFIG:Release>:--release>
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
)
|
|
|
|
add_library(mission_rust INTERFACE)
|
|
|
|
add_dependencies(mission_rust mission_rust_internal)
|
|
|
|
target_link_libraries(mission_rust INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/target/$<IF:$<CONFIG:Release>,release,debug>/libmission_rust.a)
|
|
|
|
|
|
endif() |