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

Add XIAPI_INCLUDE_DIR for hermetic/cross builds #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ These bindings have been tested with xiAPI version 4.25 on Windows and Linux. Ne
some new features may be unsupported. All cameras that are supported by xiAPI are also supported by these bindings.

### Requirements
To use these bindings, the XIMEA software package must be installed in the default path
To use these bindings without configuration, the XIMEA software package must be installed in the default path
(For Windows: C:\XIMEA; For Linux: /opt/XIMEA).

#### Non-standard library location
If your xiAPI installation uses a non-standard install directory, set `XIAPI_INCLUDE_DIR` to the path of the `$XIAPI/include`
path to specify the header location.

### Documentation
Specific documentation for this package is still WIP.
For general documentation on xiAPI please have a look at the [API manual](https://www.ximea.com/support/wiki/apis/XiAPI_Manual).
Expand Down
17 changes: 12 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ use std::path::PathBuf;

fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("Unknown target OS");
let (link_lib, include_path) = match target_os.as_str() {
"windows" => ("xiapi64","C:/XIMEA/API/xiAPI"),
"linux" => ("m3api", "/opt/XIMEA/include"),
"macos" => ("m3api","/Library/Frameworks/m3api.framework/Headers"),
let (link_lib, mut include_path) = match target_os.as_str() {
"windows" => ("xiapi64", "C:/XIMEA/API/xiAPI".to_string()),
"linux" => ("m3api", "/opt/XIMEA/include".to_string()),
"macos" => (
"m3api",
"/Library/Frameworks/m3api.framework/Headers".to_string(),
),
x => panic!("Unknown platform: {x}"),
};

if let Ok(override_include_path) = env::var("XIAPI_INCLUDE_DIR") {
include_path = override_include_path;
};

println!("cargo:rerun-if-changed=wrapper.h");

if target_os.as_str() == "macos" {
Expand All @@ -22,7 +29,7 @@ fn main() {
}

if target_os.as_str() == "windows" {
println!("cargo:rustc-link-search={}",include_path);
println!("cargo:rustc-link-search={}", include_path);
}

let bindings = bindgen::Builder::default()
Expand Down