`enable_language` option for Rust/Cargo

So, over the weekend, I decided to give this another go. Here is my workig repo: https://gitlab.kitware.com/Ayush1325/cmake/-/commits/rust-support?ref_type=heads

Currently, it can build basic Rust executable/shared/dylib. I can also link Rust shared and dynamic libs and object files (the last one is very basic and mostly only intended for special no-std cases like kernels and RTOS) to C code.

I am using one-step build/link using rustc (similar to old swift). While I got lld to work fine for no-std cases, I failed to link to ruststd without using rustc. I am only passing crate entry to add_executable/library. The dep-info file (generated by rustc) is used to rebuild if any of the modules for the crate change.

However, I am having some problems trying to link shared and dynamic libs to Rust executables:

  1. How to get link libraries parent path? I thought LINKER_FLAGS would have it, but they do not. We would need to pass it to rustc using -L flag.
  2. LINKER_LIBRARIES give full file name for static libs. This is a problem because rustc seems to need library name (liba), not the library output file name (libliba.a).

Hopefully, someone more familiar with the codebase can tell me the proper way to handle the above.