From 044323e73a62d3b10188e0a591651cf6470b7721 Mon Sep 17 00:00:00 2001 From: Zach Lewis Date: Mon, 28 Sep 2026 16:41:10 -0400 Subject: [PATCH] Fix MSVC mutex initialization with older host runtimes Disable constexpr mutex construction for MSVC builds, following OIIO's workaround for crashes with older runtimes bundled by host applications. Signed-off-by: Zach Lewis --- share/cmake/utils/CompilerFlags.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/cmake/utils/CompilerFlags.cmake b/share/cmake/utils/CompilerFlags.cmake index 92f64fc0d1..167679d912 100644 --- a/share/cmake/utils/CompilerFlags.cmake +++ b/share/cmake/utils/CompilerFlags.cmake @@ -55,6 +55,10 @@ endif() if(USE_MSVC) + # Keep mutex initialization compatible with older MSVC runtimes in host applications. + # See https://github.com/AcademySoftwareFoundation/OpenImageIO/issues/4641 + add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) + set(PLATFORM_COMPILE_OPTIONS "${PLATFORM_COMPILE_OPTIONS};/DUSE_MSVC") # /we4062 Enables warning in switch when an enumeration value is not explicitly handled.