gear-teeth/cbindgen.cmake
2026-10-20 03:04:10 +03:00

16 lines
521 B
CMake

option(LOCAL_CBINDGEN "Download and build `cbindgen` even if one can be found on the system")
if(NOT LOCAL_CBINDGEN)
find_program(CBINDGEN cbindgen)
endif()
if(NOT CBINDGEN)
message(CONFIGURE_LOG "cbindgen not found, downloading...")
set(crates "${CMAKE_BINARY_DIR}/crates")
file(MAKE_DIRECTORY ${crates})
execute_process(COMMAND ${CARGO} install --root ${crates} cbindgen@0.29.4)
set(CBINDGEN "${crates}/bin/cbindgen")
endif()
set(CBINDGEN "${CBINDGEN}" CACHE FILEPATH "Path to the cbindgen executable." FORCE)