# Any advice on bridging the gap between cargo and CPack?

**URL:** <https://discourse.cmake.org/t/any-advice-on-bridging-the-gap-between-cargo-and-cpack/4542>\
**Category:** Code\
**Created:** [November 24, 2021, 2:32pm UTC](https://discourse.cmake.org/t/any-advice-on-bridging-the-gap-between-cargo-and-cpack/4542 "2021-11-24T14:32:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arclight](https://discourse.cmake.org/user_avatar/discourse.cmake.org/arclight/32/785_2.png) [@arclight](https://discourse.cmake.org/u/arclight)\
**Post date:** [November 24, 2021, 2:32pm UTC](https://discourse.cmake.org/t/any-advice-on-bridging-the-gap-between-cargo-and-cpack/4542/1 "2021-11-24T14:32:47Z")

</div>

Has anyone used CMake/CPack to package compiled Rust applications, and if so, how did you obtain the locations of the compiled executables?

I have a simple standalone Rust project that I’d like to package into an installer with CPack. I can build the application just fine with `cargo` or via Corrosion ([GitHub - AndrewGaspar/corrosion: Marrying Rust and CMake - Easy Rust and C/C++ Integration!](https://github.com/AndrewGaspar/corrosion))-- the problem is locating the compiled artifacts (_i.e._ the executable) to pass to `install()`. See [How to identify compiled artifacts for packaging with CPack? · Issue #117 · AndrewGaspar/corrosion · GitHub](https://github.com/AndrewGaspar/corrosion/issues/117) and [Building Rust binaries in CMake project(?) · Issue #5 · micahsnyder/cmake-rust-demo · GitHub](https://github.com/micahsnyder/cmake-rust-demo/issues/5) for details.

With C/C++/Fortran code I typically have a compilation target name that I can pass to `install(TARGETS)`, otherwise I use `install(FILES)` or `install(DIRECTORY)` when I can reliably predict where the compiled results are located. CPack handles the rest. CMake is not strictly necessary here since `cargo` handles all the build tasks I currently need. I use a simple CMake recipe as a driver for CPack (standalone CPack configuration makes no sense to me).

Corrosion (formerly `cmake-cargo`) works well enough as a driver for `cargo` but doesn’t seem to expose the location of the generated binaries or target names that CMake could use with `install(TARGETS)`

Since I’m building a single executable and since Corrosion seems to hard-code the build type as `Debug`, I’ve worked around the issue just by hard-coding the expected location of the executable in `CMakeLists.txt` and modifying the file extension if `WIN32` is set. It’s brittle and I don’t like it; hopefully someone else has successfully packaged Rust applications in a more elegant manner.
