Closed Fuuzetsu closed 1 day ago
This is of course about system
feature of openblas-src
crate.
Something like below works for us on 0.10.4. I think pkg-config can be an optional dependency though I'm unsure if it matters?
diff --git a/openblas-src/Cargo.toml b/openblas-src/Cargo.toml
index 16fd3be..8476364 100644
--- a/openblas-src/Cargo.toml
+++ b/openblas-src/Cargo.toml
@@ -49,6 +49,7 @@ libc = "0.2"
[build-dependencies]
dirs = "3.0.1"
+pkg-config = "0.3"
[target.'cfg(target_os="windows")'.build-dependencies]
vcpkg = "0.2"
diff --git a/openblas-src/build.rs b/openblas-src/build.rs
index 5865271..2dcedd0 100644
--- a/openblas-src/build.rs
+++ b/openblas-src/build.rs
@@ -1,4 +1,5 @@
use std::{env, path::*, process::Command};
+extern crate pkg_config;
fn feature_enabled(feature: &str) -> bool {
env::var(format!("CARGO_FEATURE_{}", feature.to_uppercase())).is_ok()
@@ -64,6 +65,12 @@ fn main() {
"dylib"
};
if feature_enabled("system") {
+ if pkg_config::probe_library("openblas").is_ok() {
+ // pkg-config does everything, including output for cargon: we can
+ // jump out early.
+ return;
+ }
+
if cfg!(target_os = "windows") {
if cfg!(target_env = "gnu") {
windows_gnu_system();
There was an old ticket (#4) where this was requested but it was closed as OpenBLAS didn't ship with pkg-config files at the time.
This hasn't been true for years now: you can see it generate the pkg-config files in current version (https://github.com/xianyi/OpenBLAS/blob/e671d0386b3fb8be94abbac1f2ec73174a9e2eaf/CMakeLists.txt#L509) but you can also chase the change down many years back.
So I would like to re-request the pkg-config support: it makes a lot things easier w.r.t. packaging software! Thank you.