Out of source builds (external build directory) with Cargo?

前端 未结 2 1874
暖寄归人
暖寄归人 2021-02-07 09:13

Having used CMake, I\'ve become used to out-of-source builds, which are encouraged with CMake. How can out-of-source builds be done with Cargo?


Using in-source-bui

2条回答
  •  遥遥无期
    2021-02-07 09:54

    While useful manually setting this up isn't all that convenient, I wanted to be able to build multiple crates within a source tree, having all of them out-of-source, something that ../target-dir configuration option wouldn't achieve.


    Helper utility for convenient out-of-source builds

    Using the environment variable I've written a small utility to wrap cargo, so it automatically builds out-of-source, supporting crates both at the top-level, on in a subdirectory of the source tree.


    Thanks to Lukas for pointing out CARGO_TARGET_DIR and target-dir configuration option.

提交回复
热议问题