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

openblas-system should support pkg-config method #90

Open
Fuuzetsu opened this issue Sep 29, 2022 · 2 comments
Open

openblas-system should support pkg-config method #90

Fuuzetsu opened this issue Sep 29, 2022 · 2 comments

Comments

@Fuuzetsu
Copy link

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.

@Fuuzetsu
Copy link
Author

This is of course about system feature of openblas-src crate.

@Fuuzetsu
Copy link
Author

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant