Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link system liblz4 when available #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lz4-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ libc = "0.2"

[build-dependencies]
cc = "1.1"
pkg-config = "0.3.9"
13 changes: 12 additions & 1 deletion lz4-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ fn main() {
}

fn run() -> Result<(), Box<dyn Error>> {
let target = get_from_env("TARGET")?;

if !target.contains("windows")
&& pkg_config::Config::new()
.print_system_libs(false)
.cargo_metadata(true)
.probe("liblz4")
.is_ok()
{
return Ok(());
}

let mut compiler = cc::Build::new();
compiler
.file("liblz4/lib/lz4.c")
Expand All @@ -24,7 +36,6 @@ fn run() -> Result<(), Box<dyn Error>> {
// We always compile the C with optimization, because otherwise it is 20x slower.
.opt_level(3);

let target = get_from_env("TARGET")?;
if target.contains("windows") {
if target == "i686-pc-windows-gnu" {
// Disable auto-vectorization for 32-bit MinGW target.
Expand Down
Loading