corrosion icon indicating copy to clipboard operation
corrosion copied to clipboard

Custom target support

Open xTachyon opened this issue 1 year ago • 4 comments

I tried setting a custom target while also using build-std:

set(Rust_CARGO_TARGET "${CMAKE_CURRENT_SOURCE_DIR}/rust_lib/custom-x86_64-unknown-linux-gnu.json")

FetchContent_MakeAvailable(Corrosion)
corrosion_import_crate(MANIFEST_PATH rust_lib/Cargo.toml
    FLAGS -Z build-std=std
)

target_link_libraries(the_bin PRIVATE rust_lib)

The build seems to have succeeded, but this warning appeared:

CMake Warning at build/_deps/corrosion-src/cmake/FindRust.cmake:113 (message):
  Failed to parse target-triple `custom-x86_64-unknown-linux-gnu`.Corrosion
  attempts to link required C libraries depending on the OS specified in the
  Rust target-triple for Linux, MacOS and windows.

  Note: If you are targeting a different OS you can surpress this warning by
  setting the CMake cache variable
  `CORROSION_NO_WARN_PARSE_TARGET_TRIPLE_FAILED`.Please consider opening an
  issue on github if you encounter this warning.
Call Stack (most recent call first):
  build/_deps/corrosion-src/cmake/FindRust.cmake:750 (_corrosion_parse_target_triple)
  build/_deps/corrosion-src/cmake/Corrosion.cmake:63 (find_package)
  build/_deps/corrosion-src/CMakeLists.txt:73 (include)

Removing the "custom-" also removes the warning, but I feel a custom target should have a slightly different name than the original, so it's clear what you're compiling to when you're checking the logs.

Is setting CORROSION_NO_WARN_PARSE_TARGET_TRIPLE_FAILED the official™ solution here? At the very least, I feel the documentation should mention this, or maybe I just missed it.

xTachyon avatar Jul 17 '23 07:07 xTachyon