Skip to content

Commit 872561e

Browse files
committed
adding find_library function for windows
1 parent 10e55f4 commit 872561e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ libheif-rs = "0.19.2"
4545
[build-dependencies]
4646
cc = "1.0.79"
4747
pkg-config = "0.3.26"
48+
vcpkg = "0.2.15"

build.rs

+13
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ fn find_library(from_pkg_config: FromPkgConfig, from_env: FromEnv) -> Result<Vec
7878
}
7979

8080
// try to find from pkg_config
81+
find_library_internal(&from_pkg_config)
82+
}
83+
84+
#[cfg(not(target_os = "windows"))]
85+
fn find_library_internal(from_pkg_config: &FromPkgConfig) -> Result<Vec<PathBuf>, String> {
8186
match pkg_config::Config::new()
8287
.atleast_version(from_pkg_config.atleast_version.as_str())
8388
.probe(from_pkg_config.name.as_str()) {
@@ -88,6 +93,14 @@ fn find_library(from_pkg_config: FromPkgConfig, from_env: FromEnv) -> Result<Vec
8893
}
8994
}
9095

96+
#[cfg(target_os = "windows")]
97+
fn find_library_internal(from_pkg_config: &FromPkgConfig) -> Result<Vec<PathBuf>, String> {
98+
let library = vcpkg::find_package(from_pkg_config.name.as_str())
99+
.map_err(|e| Err(String::from(format!("can't find library '{}' using vcpkg", from_pkg_config.name.as_str()))))?;
100+
101+
Ok(library.include_paths)
102+
}
103+
91104
fn find_library_from_env(from_env: &FromEnv) -> Result<Vec<PathBuf>, String> {
92105
let include_dirs = verify_directories_from_env(from_env.env_key_include_dirs.as_str())?;
93106
for dir in include_dirs.iter() {

0 commit comments

Comments
 (0)