From 93ec6e40960a5e6f23d6a0d306d3d3baa4b31aab Mon Sep 17 00:00:00 2001 From: Ni Jingzhe <1448976235@qq.com> Date: Tue, 10 Nov 2026 00:16:23 +0800 Subject: [PATCH 1/2] cpp: define _USE_MATH_DEFINES for MinGW (OCCT headers gp_Dir.hxx & co. use M_PI; MinGW's math.h hides it under -std=c++20 / strict ANSI, and until now only MSVC got the define in ScadCompile) --- src/cpp/cmake/ScadCompile.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cpp/cmake/ScadCompile.cmake b/src/cpp/cmake/ScadCompile.cmake index bf0c6470..f7a40f0b 100644 --- a/src/cpp/cmake/ScadCompile.cmake +++ b/src/cpp/cmake/ScadCompile.cmake @@ -31,6 +31,11 @@ function(scad_apply_compile_options target) target_compile_definitions(${target} PRIVATE $<$:_GLIBCXX_ASSERTIONS> $<$:_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE>) + # MinGW: OCCT headers (gp_Dir.hxx & co.) use M_PI, which MinGW's math.h hides under + # -std=c++20 (strict ANSI) unless _USE_MATH_DEFINES is set; MSVC already gets it above. + if(MINGW) + target_compile_definitions(${target} PRIVATE _USE_MATH_DEFINES) + endif() if(SCAD_SANITIZE) target_compile_options(${target} PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer) target_link_options(${target} PRIVATE -fsanitize=address,undefined) From 4b8574db9f5acd63c27fbad6d21fd919d115ff67 Mon Sep 17 00:00:00 2001 From: Ni Jingzhe <1448976235@qq.com> Date: Tue, 10 Nov 2026 00:16:23 +0800 Subject: [PATCH 2/2] tools: build_occt.py picks Ninja on Windows when a MinGW g++ is the compiler (with no cl on the path the default generator fell through to NMake, which a source build without MSVC does not have) --- src/cpp/tools/build_occt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cpp/tools/build_occt.py b/src/cpp/tools/build_occt.py index 8cb5b5a8..c35252d5 100644 --- a/src/cpp/tools/build_occt.py +++ b/src/cpp/tools/build_occt.py @@ -119,10 +119,10 @@ def main() -> int: "INSTALL_DIR_LAYOUT": "Unix", } cmd = ["cmake", "-S", str(src), "-B", str(build)] - # Ninja where a compiler is already on the path (Linux, macOS). On Windows only when the MSVC environment is active - # (`cl` on the path: the release workflow activates it); otherwise the default Visual Studio generator finds MSVC by - # itself, which a bare Ninja would not. - ninja = shutil.which("ninja") is not None and (sys.platform != "win32" or shutil.which("cl") is not None) + # Ninja where a compiler is already on the path (Linux, macOS). On Windows when the MSVC environment is active + # (`cl` on the path: the release workflow activates it) or a MinGW g++ is (with cl absent CMake falls back to + # gcc); otherwise the default Visual Studio generator finds MSVC by itself, which a bare Ninja would not. + ninja = shutil.which("ninja") is not None and (sys.platform != "win32" or shutil.which("cl") is not None or shutil.which("g++") is not None) if ninja: cmd += ["-G", "Ninja"] cmd += [f"-D{k}={v}" for k, v in options.items()]