Use system's tinycbor instead of vendoring it in diff -rupN a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs --- a/c2rust-ast-exporter/build.rs 2023-05-22 22:14:35.000000000 +0200 +++ b/c2rust-ast-exporter/build.rs 2024-01-06 22:54:06.039088094 +0100 @@ -142,7 +142,7 @@ fn build_native(llvm_info: &LLVMInfo) { }; // Statically link against 'clangAstExporter' which requires 'tinycbor' - println!("cargo:rustc-link-lib=static=tinycbor"); + println!("cargo:rustc-link-lib=dylib=tinycbor"); println!("cargo:rustc-link-lib=static=clangAstExporter"); println!("cargo:rustc-link-search=native={}", llvm_lib_dir); diff -rupN a/c2rust-ast-exporter/src/CMakeLists.txt b/c2rust-ast-exporter/src/CMakeLists.txt --- a/c2rust-ast-exporter/src/CMakeLists.txt 2023-05-22 22:14:35.000000000 +0200 +++ b/c2rust-ast-exporter/src/CMakeLists.txt 2024-01-06 22:55:39.124799597 +0100 @@ -5,14 +5,9 @@ project(ASTExporter) # TinyCBOR # ################################################# -set(TINYCBOR_REPO "https://github.com/intel/tinycbor.git" CACHE STRING "tinycbor git repo URL") - -# v0.6.3 tag, but using the commit hash instead (of the tarball hash) for integrity checks -# unlike a .tar.gz MD5 hash, this SHA-1 commit hash should stay stable regardless of compression/archiving -# (GitHub has changed this), and still retains the integrity check -set(TINYCBOR_TAG "d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7" CACHE STRING "tinycbor git tag/branch/commit hash") - -set(TINYCBOR_PREFIX "${CMAKE_BINARY_DIR}/tinycbor" CACHE STRING "tinycbor install prefix") +include(FindPkgConfig) +pkg_search_module(TINYCBOR REQUIRED tinycbor) +include_directories(${TINYCBOR_INCLUDE_DIRS}) if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") set(MAKE "gmake") @@ -20,29 +15,6 @@ else() set(MAKE "make") endif() -include(ExternalProject) -ExternalProject_Add(tinycbor_build - PREFIX ${TINYCBOR_PREFIX} - INSTALL_DIR ${CMAKE_BINARY_DIR} - GIT_REPOSITORY ${TINYCBOR_REPO} - GIT_TAG ${TINYCBOR_TAG} - # the fd redirection here fails when the build run inside Cargo. - # patch from upstream: - # https://github.com/intel/tinycbor/commit/6176e0a28d7c5ef3a5e9cbd02521999c412de72c - PATCH_COMMAND patch --forward -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor_fix_build.patch || true - CONFIGURE_COMMAND ${MAKE} .config && cat ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor.config >> .config - BUILD_COMMAND ${MAKE} --quiet prefix= CFLAGS=-fPIC - INSTALL_COMMAND ${MAKE} --quiet prefix= install - BUILD_IN_SOURCE 1 - BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/lib/libtinycbor.a -) - -include_directories(${CMAKE_BINARY_DIR}/include) - -add_library(tinycbor STATIC IMPORTED) -set_target_properties(tinycbor PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib/libtinycbor.a) -add_dependencies(tinycbor tinycbor_build) - set(AST_EXPORTER_SRCS AstExporter.cpp FloatingLexer.cpp