From 26ac4f63156e232947c6f10d9b150268347e6bb0 Mon Sep 17 00:00:00 2001 From: TonyMarkham <49080394+TonyMarkham@users.noreply.github.com> Date: Wed, 29 Oct 2025 13:38:37 -0400 Subject: [PATCH] Fix Windows build: CMake profile matching and missing system libraries - Fix CMake profile to match Cargo's PROFILE env var (debug/release) - Add missing Windows system libraries (advapi32, gdi32, shell32, comdlg32) - Resolves build errors on Windows with MSVC toolchain --- crates/occt-sys/src/lib.rs | 6 +++++- crates/opencascade-sys/build.rs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/occt-sys/src/lib.rs b/crates/occt-sys/src/lib.rs index 0f1b4c33..1b029c9c 100644 --- a/crates/occt-sys/src/lib.rs +++ b/crates/occt-sys/src/lib.rs @@ -18,6 +18,10 @@ pub fn occt_path() -> PathBuf { /// Build the OCCT library. pub fn build_occt() { + // Get the Cargo profile and map it to CMake build type + let profile = var("PROFILE").unwrap_or_else(|_| "debug".to_string()); + let cmake_profile = if profile == "release" { "Release" } else { "Debug" }; + cmake::Config::new(Path::new(env!("OCCT_SRC_DIR"))) .define("BUILD_PATCH", Path::new(env!("OCCT_PATCH_DIR"))) .define("BUILD_LIBRARY_TYPE", "Static") @@ -40,7 +44,7 @@ pub fn build_occt() { .define("USE_XLIB", "FALSE") .define("INSTALL_DIR_LIB", LIB_DIR) .define("INSTALL_DIR_INCLUDE", INCLUDE_DIR) - .profile("Release") + .profile(cmake_profile) .out_dir(occt_path()) .build(); } diff --git a/crates/opencascade-sys/build.rs b/crates/opencascade-sys/build.rs index e03a72f8..7fab9147 100644 --- a/crates/opencascade-sys/build.rs +++ b/crates/opencascade-sys/build.rs @@ -47,6 +47,10 @@ fn main() { if is_windows { println!("cargo:rustc-link-lib=dylib=user32"); + println!("cargo:rustc-link-lib=dylib=advapi32"); + println!("cargo:rustc-link-lib=dylib=gdi32"); + println!("cargo:rustc-link-lib=dylib=shell32"); + println!("cargo:rustc-link-lib=dylib=comdlg32"); } let mut build = cxx_build::bridge("src/lib.rs");