mirror of
https://github.com/isar/rusqlite.git
synced 2025-11-20 15:03:52 +08:00
for msvc abi builds, add support for using sqlite from a vcpkg installation if available
This commit is contained in:
@@ -42,6 +42,9 @@ mod build {
|
||||
mod build {
|
||||
extern crate pkg_config;
|
||||
|
||||
#[cfg(feature = "vcpkg")]
|
||||
extern crate vcpkg;
|
||||
|
||||
use std::env;
|
||||
|
||||
pub enum HeaderLocation {
|
||||
@@ -79,6 +82,10 @@ mod build {
|
||||
return HeaderLocation::FromEnvironment;
|
||||
}
|
||||
|
||||
if let Some(header) = try_vcpkg() {
|
||||
return header;
|
||||
}
|
||||
|
||||
// See if pkg-config can do everything for us.
|
||||
match pkg_config::Config::new().print_system_libs(false).probe("sqlite3") {
|
||||
Ok(mut lib) => {
|
||||
@@ -100,6 +107,23 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "vcpkg")]
|
||||
fn try_vcpkg() -> Option<HeaderLocation> {
|
||||
// See if vcpkg can find it.
|
||||
if let Ok(mut lib) = vcpkg::Config::new().probe("sqlite3") {
|
||||
if let Some(mut header) = lib.include_paths.pop() {
|
||||
header.push("sqlite3.h");
|
||||
return Some(HeaderLocation::FromPath(header.to_string_lossy().into()));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "vcpkg"))]
|
||||
fn try_vcpkg() -> Option<HeaderLocation> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "buildtime_bindgen"))]
|
||||
mod bindings {
|
||||
use super::HeaderLocation;
|
||||
|
||||
Reference in New Issue
Block a user