-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add opt in dependency for vcpkg make pkg-config optional but default
- Loading branch information
1 parent
ad91523
commit 1f5093c
Showing
2 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
use pkg_config::find_library; | ||
fn main() { | ||
if cfg!(not(feature = "pkg-config")) && cfg!(not(feature = "vcpkg")) | ||
{ | ||
panic!(r#"Enable "pkg-config" or "vcpkg" feature flags to locate libxml2"#) | ||
} | ||
|
||
#[cfg(feature = "pkg-config")] | ||
{ | ||
if pkg_config_dep::find() { | ||
return; | ||
} | ||
} | ||
|
||
fn main() { | ||
if find_library("libxml-2.0").is_err() { | ||
panic!("Could not find libxml2 using pkg-config") | ||
#[cfg(feature = "vcpkg")] | ||
{ | ||
if vcpkg_dep::find() { | ||
return; | ||
} | ||
} | ||
|
||
panic!("Could not find libxml2.") | ||
} | ||
|
||
#[cfg(feature = "pkg-config")] | ||
mod pkg_config_dep { | ||
use pkg_config; | ||
pub fn find() -> bool { | ||
if pkg_config::find_library("libxml-2.0").is_ok() { | ||
return true; | ||
} | ||
false | ||
} | ||
} | ||
|
||
#[cfg(feature = "vcpkg")] | ||
mod vcpkg_dep { | ||
use vcpkg; | ||
pub fn find() -> bool { | ||
if vcpkg::find_package("libxml2").is_ok() { | ||
return true | ||
} | ||
false | ||
} | ||
} |