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) 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()]