Skip to content
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
8 changes: 8 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build.env]
passthrough = [ "CBC_ROOT" ]

[target.x86_64-pc-windows-msvc]
image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local"

[target.x86_64-pc-windows-msvc.env]
volumes = [ "CBC_ROOT" ]
25 changes: 24 additions & 1 deletion coin_cbc_sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
extern crate pkg_config;
use std::env;

fn main() {
let _ = pkg_config::probe_library("cbc");
match env::var("CARGO_CFG_TARGET_FAMILY")
.as_ref()
.map(String::as_str)
{
Ok("unix") => {
let _ = pkg_config::probe_library("cbc");
}
Ok("windows") if env::var("CBC_ROOT").is_ok() => {
let cbc_root = env::var("CBC_ROOT").unwrap();
println!("cargo:rustc-link-search={cbc_root}/lib");
println!(r"cargo:rustc-link-lib=static=libCbc");
println!(r"cargo:rustc-link-lib=static=libCbcSolver");
println!(r"cargo:rustc-link-lib=static=libCgl");
println!(r"cargo:rustc-link-lib=static=libClp");
println!(r"cargo:rustc-link-lib=static=libCoinUtils");
println!(r"cargo:rustc-link-lib=static=libOsi");
println!(r"cargo:rustc-link-lib=static=libOsiClp");
}
Ok("windows") if env::var("CBC_ROOT").is_err() => {
println!(r"cargo:warning=CBC_ROOT environment variable not found.")
}
_ => println!(r"cargo:warning=Unsupported target family."),
}
}
6 changes: 5 additions & 1 deletion coin_cbc_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ pub type cbc_callback = Option<
),
>;

#[link(name = "CbcSolver")]
#[cfg_attr(
target_family = "windows",
link(name = "libCbcSolver")
)]
#[cfg_attr(not(target_family = "windows"), link(name = "CbcSolver"))]
extern "C" {
pub fn Cbc_newModel() -> *mut Cbc_Model;
pub fn Cbc_deleteModel(model: *mut Cbc_Model);
Expand Down