Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions .github/workflows/build_windows_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build Windows ARM64

on:
push:
branches: [ feat/windows-arm64 ]
pull_request:
branches: [ main ]
paths:
- 'deps/**'
- 'src/**'
- 'CMakeLists.txt'
- 'build_release_vs2022.bat'
- '.github/workflows/build_windows_arm64.yml'

jobs:
build-arm64:
name: Windows ARM64 (native)
runs-on: windows-11-arm

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install MSYS2 (clangarm64) with GMP/MPFR and LLVM tools
uses: msys2/setup-msys2@v2
with:
msystem: CLANGARM64
update: true
install: >-
mingw-w64-clang-aarch64-gmp
mingw-w64-clang-aarch64-mpfr
mingw-w64-clang-aarch64-llvm

- name: Generate MSVC-compatible import libs for GMP and MPFR
# llvm-readobj --coff-exports parses PE DLL export tables.
# llvm-dlltool -m arm64 emits a COFF .lib that MSVC link.exe accepts.
shell: msys2 {0}
run: |
set -euo pipefail
BIN=/clangarm64/bin
REPO=$(cygpath -u "$GITHUB_WORKSPACE")

# Diagnose available tools if something goes wrong
echo "=== llvm tools in PATH ==="
ls /clangarm64/bin/llvm-* 2>/dev/null | head -20 || echo "(none found)"

make_import_lib() {
local dll="$1"
local lib="$2"
local def="/tmp/${dll%.dll}.def"
echo "--- $dll ---"
echo "EXPORTS" > "$def"
llvm-readobj --coff-exports "$BIN/$dll" \
| awk '/Name: /{print $2}' >> "$def"
echo " $(( $(wc -l < "$def") - 1 )) exports"
llvm-dlltool -m arm64 -D "$dll" -d "$def" -l "$BIN/$lib"
echo " $lib: $(wc -c < "$BIN/$lib") bytes"
}

make_import_lib libgmp-10.dll libgmp-10.lib

# MPFR 4.x (soname 6) ships as libmpfr-6.dll in MSYS2 CLANGARM64;
# fall back to libmpfr-4.dll if an older package is installed.
MPFR_DLL=$(ls $BIN/libmpfr-*.dll 2>/dev/null | head -1 | xargs basename)
echo "Found MPFR DLL: $MPFR_DLL"
make_import_lib "$MPFR_DLL" "${MPFR_DLL%.dll}.lib"
# cmake expects libmpfr-4.{dll,lib} — copy under that canonical name
if [ "$MPFR_DLL" != "libmpfr-4.dll" ]; then
cp "$BIN/$MPFR_DLL" "$BIN/libmpfr-4.dll"
cp "$BIN/${MPFR_DLL%.dll}.lib" "$BIN/libmpfr-4.lib"
fi

# Stage into repo blob dirs so cmake's win-${DEPS_ARCH} lookup works
mkdir -p $REPO/deps/GMP/gmp/lib/win-arm64
mkdir -p $REPO/deps/MPFR/mpfr/lib/win-arm64

cp $BIN/libgmp-10.dll $REPO/deps/GMP/gmp/lib/win-arm64/
cp $BIN/libgmp-10.lib $REPO/deps/GMP/gmp/lib/win-arm64/
cp $BIN/libmpfr-4.dll $REPO/deps/MPFR/mpfr/lib/win-arm64/
cp $BIN/libmpfr-4.lib $REPO/deps/MPFR/mpfr/lib/win-arm64/
cp /clangarm64/include/gmp.h $REPO/deps/GMP/gmp/include/
cp /clangarm64/include/mpfr.h $REPO/deps/MPFR/mpfr/include/ || true
echo "Done staging GMP/MPFR win-arm64 blobs."

- name: Cache deps
uses: actions/cache@v4
id: cache-deps
with:
path: deps/build-arm64/OrcaSlicer_dep
key: deps-arm64-${{ hashFiles('deps/**') }}-${{ runner.os }}

- name: Build dependencies (ARM64)
if: steps.cache-deps.outputs.cache-hit != 'true'
shell: cmd
run: |
cd deps
mkdir build-arm64
cd build-arm64
cmake ../ -G "Visual Studio 17 2022" -A ARM64 ^
-DDESTDIR="%CD%/OrcaSlicer_dep" ^
-DCMAKE_BUILD_TYPE=Release ^
-DDEP_DEBUG=OFF ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build . --config Release --target deps -- -m

- name: Build Snapmaker OrcaSlicer (ARM64)
shell: cmd
run: |
set DEPS=%CD%\deps\build-arm64\OrcaSlicer_dep
mkdir build-arm64
cd build-arm64
cmake .. -G "Visual Studio 17 2022" -A ARM64 ^
-DBBL_RELEASE_TO_PUBLIC=1 ^
-DORCA_TOOLS=ON ^
-DSLIC3R_ENABLE_STEP=OFF ^
-DCMAKE_PREFIX_PATH="%DEPS%/usr/local" ^
-DCMAKE_INSTALL_PREFIX="./Snapmaker_Orca" ^
-DCMAKE_BUILD_TYPE=Release ^
-DWIN10SDK_PATH="%WindowsSdkDir%Include\%WindowsSDKVersion%\"
cmake --build . --config Release --target ALL_BUILD -- -m
cmake --build . --target install --config Release

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Snapmaker-OrcaSlicer-Windows-ARM64
path: build-arm64/Snapmaker_Orca/
retention-days: 30
91 changes: 57 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ endif()
option(SLIC3R_STATIC "Compile Snapmaker_Orca with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL})
option(SLIC3R_GUI "Compile Snapmaker_Orca with GUI components (OpenGL, wxWidgets)" 1)
option(SLIC3R_FHS "Assume Snapmaker_Orca is to be installed in a FHS directory structure" 0)

# STEP/OCCT support requires OpenCASCADE 7.7+ for Windows ARM64. Default OFF on ARM64.
if (WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
set(_step_default OFF)
else()
set(_step_default ON)
endif()
option(SLIC3R_ENABLE_STEP "Compile with STEP file import support (requires OpenCASCADE)" ${_step_default})
option(SLIC3R_WX_STABLE "Build against wxWidgets stable (3.0) as oppsed to dev (3.1) on Linux" 0)
option(SLIC3R_PROFILE "Compile Snapmaker_Orca with an invasive Shiny profiler" 0)
option(SLIC3R_PCH "Use precompiled headers" 1)
Expand Down Expand Up @@ -764,6 +772,8 @@ function(Snapmaker_Orca_copy_dlls target config postfix output_dlls)
set(_arch "x64")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "X86")
set(_arch "x86")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ARM64")
set(_arch "arm64")
else ()
message(FATAL_ERROR "Unable to detect architecture")
endif ()
Expand All @@ -782,9 +792,12 @@ function(Snapmaker_Orca_copy_dlls target config postfix output_dlls)
message ("set out_dir to CMAKE_CURRENT_BINARY_DIR: ${_out_dir}")
endif ()

file(COPY ${TOP_LEVEL_PROJECT_DIR}/deps/GMP/gmp/lib/win-${_arch}/libgmp-10.dll
${TOP_LEVEL_PROJECT_DIR}/deps/MPFR/mpfr/lib/win-${_arch}/libmpfr-4.dll
${TOP_LEVEL_PROJECT_DIR}/deps/WebView2/lib/win-${_arch}/WebView2Loader.dll
if (NOT "${_arch}" STREQUAL "arm64")
file(COPY ${TOP_LEVEL_PROJECT_DIR}/deps/GMP/gmp/lib/win-${_arch}/libgmp-10.dll
${TOP_LEVEL_PROJECT_DIR}/deps/MPFR/mpfr/lib/win-${_arch}/libmpfr-4.dll
DESTINATION ${_out_dir})
endif()
file(COPY ${TOP_LEVEL_PROJECT_DIR}/deps/WebView2/lib/win-${_arch}/WebView2Loader.dll
DESTINATION ${_out_dir})

# Copy Sentry and Crashpad artifacts if they were built by deps
Expand All @@ -795,6 +808,7 @@ function(Snapmaker_Orca_copy_dlls target config postfix output_dlls)
)
endif()

if (SLIC3R_ENABLE_STEP)
file(COPY ${CMAKE_PREFIX_PATH}/bin/occt/TKBO.dll
${CMAKE_PREFIX_PATH}/bin/occt/TKBRep.dll
${CMAKE_PREFIX_PATH}/bin/occt/TKCAF.dll
Expand Down Expand Up @@ -823,43 +837,52 @@ function(Snapmaker_Orca_copy_dlls target config postfix output_dlls)
${CMAKE_PREFIX_PATH}/bin/occt/TKXSBase.dll
${CMAKE_PREFIX_PATH}/bin/freetype.dll
DESTINATION ${_out_dir})
endif() # SLIC3R_ENABLE_STEP

# Build the DLL list in a local variable first
set(_dll_list
${_out_dir}/libgmp-10.dll
${_out_dir}/libmpfr-4.dll
${_out_dir}/WebView2Loader.dll

${_out_dir}/TKBO.dll
${_out_dir}/TKBRep.dll
${_out_dir}/TKCAF.dll
${_out_dir}/TKCDF.dll
${_out_dir}/TKernel.dll
${_out_dir}/TKG2d.dll
${_out_dir}/TKG3d.dll
${_out_dir}/TKGeomAlgo.dll
${_out_dir}/TKGeomBase.dll
${_out_dir}/TKHLR.dll
${_out_dir}/TKLCAF.dll
${_out_dir}/TKMath.dll
${_out_dir}/TKMesh.dll
${_out_dir}/TKPrim.dll
${_out_dir}/TKService.dll
${_out_dir}/TKShHealing.dll
${_out_dir}/TKSTEP.dll
${_out_dir}/TKSTEP209.dll
${_out_dir}/TKSTEPAttr.dll
${_out_dir}/TKSTEPBase.dll
${_out_dir}/TKTopAlgo.dll
${_out_dir}/TKV3d.dll
${_out_dir}/TKVCAF.dll
${_out_dir}/TKXCAF.dll
${_out_dir}/TKXDESTEP.dll
${_out_dir}/TKXSBase.dll

${_out_dir}/freetype.dll
)

if (NOT "${_arch}" STREQUAL "arm64")
list(APPEND _dll_list
${_out_dir}/libgmp-10.dll
${_out_dir}/libmpfr-4.dll
)
endif()

if (SLIC3R_ENABLE_STEP)
list(APPEND _dll_list
${_out_dir}/TKBO.dll
${_out_dir}/TKBRep.dll
${_out_dir}/TKCAF.dll
${_out_dir}/TKCDF.dll
${_out_dir}/TKernel.dll
${_out_dir}/TKG2d.dll
${_out_dir}/TKG3d.dll
${_out_dir}/TKGeomAlgo.dll
${_out_dir}/TKGeomBase.dll
${_out_dir}/TKHLR.dll
${_out_dir}/TKLCAF.dll
${_out_dir}/TKMath.dll
${_out_dir}/TKMesh.dll
${_out_dir}/TKPrim.dll
${_out_dir}/TKService.dll
${_out_dir}/TKShHealing.dll
${_out_dir}/TKSTEP.dll
${_out_dir}/TKSTEP209.dll
${_out_dir}/TKSTEPAttr.dll
${_out_dir}/TKSTEPBase.dll
${_out_dir}/TKTopAlgo.dll
${_out_dir}/TKV3d.dll
${_out_dir}/TKVCAF.dll
${_out_dir}/TKXCAF.dll
${_out_dir}/TKXDESTEP.dll
${_out_dir}/TKXSBase.dll
${_out_dir}/freetype.dll
)
endif()

# Add Sentry DLLs to the list if Sentry is enabled
if (SLIC3R_SENTRY)
list(APPEND _dll_list
Expand Down
10 changes: 7 additions & 3 deletions build_release_vs2022.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ if "%1"=="pack" (

set debug=OFF
set debuginfo=OFF
set arch=x64
if "%1"=="debug" set debug=ON
if "%2"=="debug" set debug=ON
if "%1"=="debuginfo" set debuginfo=ON
if "%2"=="debuginfo" set debuginfo=ON
if "%1"=="arm64" set arch=ARM64
if "%2"=="arm64" set arch=ARM64
if "%debug%"=="ON" (
set build_type=Debug
set build_dir=build-dbg
Expand All @@ -31,7 +34,8 @@ if "%debug%"=="ON" (
set build_dir=build
)
)
echo build type set to %build_type%
if "%arch%"=="ARM64" set build_dir=%build_dir%-arm64
echo build type set to %build_type%, arch=%arch%

setlocal DISABLEDELAYEDEXPANSION
cd deps
Expand All @@ -47,7 +51,7 @@ if "%1"=="slicer" (
echo "building deps.."

echo on
cmake ../ -G "Visual Studio 17 2022" -A x64 -DDESTDIR="%DEPS%" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo%
cmake ../ -G "Visual Studio 17 2022" -A %arch% -DDESTDIR="%DEPS%" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo%
cmake --build . --config %build_type% --target deps -- -m
@echo off

Expand All @@ -60,7 +64,7 @@ mkdir %build_dir%
cd %build_dir%

echo on
cmake .. -G "Visual Studio 17 2022" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./Snapmaker_Orca" -DCMAKE_BUILD_TYPE=%build_type% -DWIN10SDK_PATH="%WindowsSdkDir%Include\%WindowsSDKVersion%\"
cmake .. -G "Visual Studio 17 2022" -A %arch% -DBBL_RELEASE_TO_PUBLIC=1 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./Snapmaker_Orca" -DCMAKE_BUILD_TYPE=%build_type% -DWIN10SDK_PATH="%WindowsSdkDir%Include\%WindowsSDKVersion%\"
cmake --build . --config %build_type% --target ALL_BUILD -- -m
@echo off
cd ..
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/FindGLEW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ endif()

if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "x64" OR "${CMAKE_GENERATOR}" MATCHES "Win64")
set(_arch "x64")
elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64")
set(_arch "x64") # GLEW ships a single set of headers; ARM64 uses x64 import path
else()
set(_arch "Win32")
endif()
Expand Down
33 changes: 23 additions & 10 deletions deps/CGAL/CGAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ if (IN_GIT_REPO)
set(CGAL_DIRECTORY_FLAG --directory ${BINARY_DIR_REL}/dep_CGAL-prefix/src/dep_CGAL)
endif ()

Snapmaker_Orca_add_cmake_project(
CGAL
# GIT_REPOSITORY https://github.com/CGAL/cgal.git
# GIT_TAG bec70a6d52d8aacb0b3d82a7b4edc3caa899184b # releases/CGAL-5.0
# For whatever reason, this keeps downloading forever (repeats downloads if finished)
URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
PATCH_COMMAND git apply ${CGAL_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch
DEPENDS dep_Boost dep_GMP dep_MPFR
)
if (MSVC AND "${DEPS_ARCH}" STREQUAL "arm64")
# Windows ARM64: build CGAL without GMP/MPFR (exact-arithmetic kernels unavailable).
# STEP/OCCT import is disabled on ARM64 (OCCT 7.6 has no ARM64 support).
Snapmaker_Orca_add_cmake_project(
CGAL
URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
PATCH_COMMAND git apply ${CGAL_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch
DEPENDS dep_Boost
CMAKE_ARGS -DCGAL_DISABLE_GMP=ON
)
else()
Snapmaker_Orca_add_cmake_project(
CGAL
# GIT_REPOSITORY https://github.com/CGAL/cgal.git
# GIT_TAG bec70a6d52d8aacb0b3d82a7b4edc3caa899184b # releases/CGAL-5.0
# For whatever reason, this keeps downloading forever (repeats downloads if finished)
URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
PATCH_COMMAND git apply ${CGAL_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-clang19.patch
DEPENDS dep_Boost dep_GMP dep_MPFR
)
endif()

include(GNUInstallDirs)
Loading