# audiopus_sys calls cmake::build(opus_path), so downstream Cargo env cannot # call cmake-rs Config::define() to override CMake's MSVC Debug CRT defaults. # Instead, point cmake-rs at a small wrapper that injects -D cache/policy # variables during configure while passing cmake --build / --version / -E / # --install / --open through unchanged. This keeps Opus Debug builds on # Rust's release dynamic CRT (/MD) instead of CMake's default debug CRT # (/MDd), which otherwise pulls in unresolved __imp__CrtDbgReportW symbols # at test link. # # IMPORTANT: Cargo's `[target.]` config sections only forward a # fixed allowlist of keys (linker, runner, rustflags, rustdocflags, ar) # to build scripts. Arbitrary keys such as `CMAKE` placed under # `[target.]` are silently ignored and never reach the # audiopus_sys build script. cmake-rs (via cc-style env resolution) # looks up CMAKE in this order: # 1. CMAKE_ # 2. CMAKE_ # 3. TARGET_CMAKE (or HOST_CMAKE when host == target) # 4. CMAKE # We therefore scope the wrapper to Windows MSVC targets by setting the # target-suffixed variant in the global [env] section. Non-Windows # hosts (macOS, Linux, iOS, Android) never see CMAKE set and invoke # `cmake` directly. # # NOTE: CMAKE_POLICY_DEFAULT_CMP0091 and CMAKE_MSVC_RUNTIME_LIBRARY cannot # be set via the process environment because CMake does NOT auto-import # them into its cache; they must be passed as `-D` definitions, which the # wrapper does. # # iOS deployment target (DEC-003: iOS 13.0 minimum) is NOT set here. It is # enforced in two places that own the iOS build: # 1. tools/build-ios.sh — sets IPHONEOS_DEPLOYMENT_TARGET for the cargo # invocation and bypasses audiopus_sys's CMake build via # LIBOPUS_STATIC=1 / LIBOPUS_NO_PKG=1 / LIBOPUS_LIB_DIR. # 2. apps/chanora_flutter/ios/Runner.xcodeproj — sets the Xcode # IPHONEOS_DEPLOYMENT_TARGET build setting for the final link. # Setting it globally here would make native macOS `cargo check` runs try # to link iPhone objects against the macOS SDK. [env] CMAKE_POLICY_VERSION_MINIMUM = "3.5" # Scope the cmake wrapper to Windows MSVC targets only via the # target-suffixed env var name that cc/cmake-rs already resolve. # Force = true so a developer's pre-existing CMAKE_x86_64-pc-windows-msvc # does not silently bypass the wrapper. Relative = true so the path # resolves from the workspace root regardless of where cargo is invoked. CMAKE_x86_64-pc-windows-msvc = { value = "tools/cmake-msvc-release-crt.cmd", force = true, relative = true } CMAKE_aarch64-pc-windows-msvc = { value = "tools/cmake-msvc-release-crt.cmd", force = true, relative = true }