[CMake] Calling external build system

Niklas Claesson nicke.claesson at gmail.com
Wed Oct 9 16:03:19 EDT 2019


Hello,

I'm creating a static library (*.a) with a separate build system (cargo).
That build system also produces a dependency file in the Makefile format
(also produced by `gcc -M`). Is it possible to include this file into the
generated makefiles either through a makefile inclusion or through cmake
parsing the file?

Obviously I don't want to call `cargo` unless one of my source files
changed.

Here is what I've got so far:

```
add_custom_command(
  OUTPUT
    ${CMAKE_CURRENT_BINARY_DIR}/rust/test/target/${RUST_PROFILE}/libtest.a
  COMMAND
    ${CMAKE_COMMAND} -E env SYSROOT=${CMAKE_SYSROOT}
INCLUDES="${RUST_INCLUDES}" cargo build --manifest-path
${CMAKE_CURRENT_SOURCE_DIR}/rust/test/Cargo.toml --target-dir
${CMAKE_CURRENT_BINARY_DIR}/rust/test/target ${RUST_CARGO_FLAG}
  COMMAND
  )
add_custom_target(rust DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/rust/test/target/${RUST_PROFILE}/libbase.a)
```


Thanks
- Niklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191009/e53de36b/attachment-0001.html>


More information about the CMake mailing list