I found this: https://github.com/AndrewGaspar/cmake-cargo but couldn't make it work
Anyway, if I were to use a Makefile instead of CMake, I'd simply create a rule that watches for the .rs files to change and recompile.
I couldn't find a solution for calling Cargo from Cmake (not the other way around) so I'm opening one here.
How can I make my CMakeLists.txt
watch for .rs file changes and recompile by calling cargo build
?
Following recommendations, I simply added the command cargo build
as a dependency to my library
add_library(libsmoltcp_cpp ${libsmoltcp_cpp_sources})
add_custom_target(
lib_smol_tcp_rust
COMMAND cargo build
)
add_dependencies(libsmoltcp_cpp lib_smol_tcp_rust)
I'm the author of the linked project in the OP. I apologize for the sorry state it was in when you found it, but in the last month or so I've invested a bunch of time to really flesh it out, and gave it a more inspiring name: https://github.com/AndrewGaspar/corrosion
I hope you could check out the latest README and let me know if you can get it working for your scenario. And if not, please file an issue, letting me know where in the documentation you ran into issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With