From 3ed92e26c780de8a78fd12de97dbeeb47cb99886 Mon Sep 17 00:00:00 2001 From: Mordinel Date: Sat, 9 Sep 2023 01:10:29 +1200 Subject: [PATCH] Make crate build on macos using pkg-config --- Cargo.toml | 5 ++++- build.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 87d0395..97d00dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,7 @@ num-traits = "0.2" serde = { version = "1.0", optional = true, features = ["derive"] } [dev-dependencies] -serde_json = { version = "1.0" } \ No newline at end of file +serde_json = { version = "1.0" } + +[build-dependencies] +pkg-config = "0.3.27" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..f27be97 --- /dev/null +++ b/build.rs @@ -0,0 +1,13 @@ +fn main() { + #[cfg(target_os = "macos")] + { + let gmp_config = pkg_config::probe_library("gmp").unwrap(); + for link_lib in gmp_config.libs { + println!("cargo:rustc-link-lib={}", link_lib); + } + for link_path in gmp_config.link_paths { + println!("cargo:rustc-link-search=native={}", link_path.to_str().expect("Path is not unicode")); + } + } +} +