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)