use std::env;

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    let target = env::var("TARGET").expect("Cargo provides TARGET");
    if target.contains("msvc") {
        vcpkg::Config::new()
            .find_package("openjpeg")
            .expect("jpeg2000 requires OpenJPEG 2.5.4 or newer from vcpkg");
    } else {
        pkg_config::Config::new()
            .atleast_version("2.5.4")
            .probe("libopenjp2")
            .expect("jpeg2000 requires pkg-config and OpenJPEG 2.5.4 or newer");
    }
}
