|
| 1 | +# Building VTK |
| 2 | + |
| 3 | +## Tools |
| 4 | + |
| 5 | +We will use the Emscripten SDK to compile C++ for wasm architecture. NodeJS will be used as a cross compiling emulator. CMake and Ninja are required to |
| 6 | +setup the project. |
| 7 | + |
| 8 | +### Install requirements |
| 9 | + |
| 10 | +First, clone VTK and checkout a release version. |
| 11 | + |
| 12 | +```sh |
| 13 | +git clone https://gitlab.kitware.com/vtk/vtk.git |
| 14 | +``` |
| 15 | + |
| 16 | +Now, install NodeJS and EMSDK. Go to https://nodejs.org/en/download and follow the instructions for your platform. |
| 17 | + |
| 18 | +::: code-group |
| 19 | +```sh [macOS/Linux] |
| 20 | +# Download and install fnm: |
| 21 | +curl -o- https://fnm.vercel.app/install | bash |
| 22 | +# Download and install Node.js |
| 23 | +fnm install 24.0.1 |
| 24 | +fnm use 24.0.1 |
| 25 | + |
| 26 | +# Download and install EMSDK |
| 27 | +git clone https://github.com/emscripten-core/emsdk.git |
| 28 | +./emsdk/emsdk install 4.0.9 |
| 29 | +export PATH=$PWD/emsdk/upstream/bin:$PWD/emsdk/upstream/emscripten:$PATH |
| 30 | +``` |
| 31 | +```sh [Windows] |
| 32 | +# In Powershell |
| 33 | +# Download and install fnm: |
| 34 | +winget install Schniz.fnm |
| 35 | +# Download and install Node.js |
| 36 | +fnm install 24.0.1 |
| 37 | +fnm env --use-on-cd --shell power-shell | Out-String | Invoke-Expression |
| 38 | +fnm use 24.0.1 |
| 39 | + |
| 40 | +git clone https://github.com/emscripten-core/emsdk.git |
| 41 | +.\emsdk\emsdk install 4.0.9 |
| 42 | +$env:PATH="$PWD\emsdk\upstream\bin;$PWD\emsdk\upstream\emscripten;$env:PATH" |
| 43 | +``` |
| 44 | +::: |
| 45 | + |
| 46 | +Finally, download prebuilt webgpu static libraries and headers for `emdawnwebgpu`. |
| 47 | + |
| 48 | +::: code-group |
| 49 | +```sh [wasm32:macOS/Linux] |
| 50 | +cd vtk |
| 51 | +CMAKE_CONFIGURATION="wasm32" cmake -P ./.gitlab/ci/download_dawn.cmake |
| 52 | +``` |
| 53 | +```sh [wasm64:macOS/Linux] |
| 54 | +cd vtk |
| 55 | +CMAKE_CONFIGURATION="wasm64" cmake -P ./.gitlab/ci/download_dawn.cmake |
| 56 | +``` |
| 57 | +```sh [wasm32:Windows] |
| 58 | +# In Powershell |
| 59 | +cd vtk |
| 60 | +$env:CMAKE_CONFIGURATION="wasm32" |
| 61 | +cmake -P .\.gitlab\ci\download_dawn.cmake |
| 62 | +``` |
| 63 | +```sh [wasm64:Windows] |
| 64 | +# In Powershell |
| 65 | +cd vtk |
| 66 | +$env:CMAKE_CONFIGURATION="wasm64" |
| 67 | +cmake -P .\.gitlab\ci\download_dawn.cmake |
| 68 | +``` |
| 69 | +::: |
| 70 | + |
| 71 | +## Building VTK |
| 72 | + |
| 73 | +:::code-group |
| 74 | +```sh [wasm32:macOS/Linux] |
| 75 | +emcmake cmake \ |
| 76 | +-S . \ |
| 77 | +-B buildRelease \ |
| 78 | +-G "Ninja" \ |
| 79 | +-DCMAKE_BUILD_TYPE=Release \ |
| 80 | +-DBUILD_SHARED_LIBS:BOOL=OFF \ |
| 81 | +-DVTK_ENABLE_WEBGPU:BOOL=ON \ |
| 82 | +-Demdawnwebgpu_DIR="$PWD/.gitlab/dawn/lib/cmake/emdawnwebgpu" |
| 83 | +cmake --build ./buildRelease |
| 84 | +cmake --install ./buildRelease --prefix ./installRelease |
| 85 | +``` |
| 86 | +```sh [wasm64:macOS/Linux] |
| 87 | +emcmake cmake \ |
| 88 | +-S . \ |
| 89 | +-B buildRelease \ |
| 90 | +-G "Ninja" \ |
| 91 | +-DCMAKE_BUILD_TYPE=Release \ |
| 92 | +-DBUILD_SHARED_LIBS:BOOL=OFF \ |
| 93 | +-DVTK_ENABLE_WEBGPU:BOOL=ON \ |
| 94 | +-DVTK_WEBASSEMBLY_64_BIT:BOOL=ON \ |
| 95 | +-Demdawnwebgpu_DIR="$PWD/.gitlab/dawn/lib/cmake/emdawnwebgpu" |
| 96 | +cmake --build ./buildRelease |
| 97 | +cmake --install ./buildRelease --prefix ./installRelease |
| 98 | +``` |
| 99 | +```sh [wasm32:Windows] |
| 100 | +# In Powershell |
| 101 | +emcmake cmake ` |
| 102 | +-S . ` |
| 103 | +-B buildRelease ` |
| 104 | +-G "Ninja" ` |
| 105 | +-DCMAKE_BUILD_TYPE=Release ` |
| 106 | +-DBUILD_SHARED_LIBS:BOOL=OFF ` |
| 107 | +-DVTK_ENABLE_WEBGPU:BOOL=ON ` |
| 108 | +-Demdawnwebgpu_DIR="$PWD\.gitlab\dawn\lib\cmake\emdawnwebgpu" |
| 109 | +cmake --build .\buildRelease |
| 110 | +cmake --install .\buildRelease --prefix .\installRelease |
| 111 | +``` |
| 112 | +```sh [wasm64:Windows] |
| 113 | +# In Powershell |
| 114 | +emcmake cmake ` |
| 115 | +-S . ` |
| 116 | +-B buildRelease ` |
| 117 | +-G "Ninja" ` |
| 118 | +-DCMAKE_BUILD_TYPE=Release ` |
| 119 | +-DBUILD_SHARED_LIBS:BOOL=OFF ` |
| 120 | +-DVTK_ENABLE_WEBGPU:BOOL=ON ` |
| 121 | +-DVTK_WEBASSEMBLY_64_BIT:BOOL=ON ` |
| 122 | +-Demdawnwebgpu_DIR="$PWD\.gitlab\dawn\lib\cmake\emdawnwebgpu" |
| 123 | +cmake --build .\buildRelease |
| 124 | +cmake --install .\buildRelease --prefix .\installRelease |
| 125 | +``` |
| 126 | +::: |
0 commit comments