Skip to content

Commit

Permalink
Add bundling support on windows
Browse files Browse the repository at this point in the history
We need to always build release builds there (to prevent linker errors
due to mixing up debug and release runtimes) and we need an additional
flag to prevent the static library to expect some proj.dll file to exist
  • Loading branch information
weiznich committed Jan 30, 2024
1 parent ae91aba commit 5a58fdf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions proj-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
config.define("ENABLE_TIFF", "OFF");
}

if cfg!(target_env = "msvc") {
// rust links the release MVSC runtime
// also for debug builds. If we let
// cmake choose debug/release builds
// based on the underlying cargo build
// version that results in linker errors
config.profile("Release");
// see
// https://github.com/OSGeo/PROJ/commit/6e9b324ab7bf5909df7e68409e060282db14fa54#diff-af8fe2f9d33a9c3408ff7683bfebd1e2334b4506f559add92406be3e150268fb
config.cxxflag("-DPROJ_DLL=");
}

let proj = config.build();
// Tell cargo to tell rustc to link libproj, and where to find it
// libproj will be built in $OUT_DIR/lib
Expand Down

0 comments on commit 5a58fdf

Please sign in to comment.