|
1 | 1 | # Building VTK |
2 | 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.10 |
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.10 |
42 | | -$env:PATH="$PWD\emsdk\upstream\bin;$PWD\emsdk\upstream\emscripten;$env:PATH" |
43 | | -``` |
44 | | -::: |
45 | | - |
46 | | -## Building VTK |
47 | | - |
48 | | -:::code-group |
49 | | -```sh [wasm32:macOS/Linux] |
50 | | -emcmake cmake \ |
51 | | --S . \ |
52 | | --B buildRelease \ |
53 | | --G "Ninja" \ |
54 | | --DCMAKE_BUILD_TYPE=Release \ |
55 | | --DBUILD_SHARED_LIBS:BOOL=OFF \ |
56 | | --DVTK_ENABLE_WEBGPU:BOOL=ON |
57 | | -cmake --build ./buildRelease |
58 | | -cmake --install ./buildRelease --prefix ./installRelease |
59 | | -``` |
60 | | -```sh [wasm64:macOS/Linux] |
61 | | -emcmake cmake \ |
62 | | --S . \ |
63 | | --B buildRelease \ |
64 | | --G "Ninja" \ |
65 | | --DCMAKE_BUILD_TYPE=Release \ |
66 | | --DBUILD_SHARED_LIBS:BOOL=OFF \ |
67 | | --DVTK_ENABLE_WEBGPU:BOOL=ON \ |
68 | | --DVTK_WEBASSEMBLY_64_BIT:BOOL=ON |
69 | | -cmake --build ./buildRelease |
70 | | -cmake --install ./buildRelease --prefix ./installRelease |
71 | | -``` |
72 | | -```sh [wasm32:Windows] |
73 | | -# In Powershell |
74 | | -emcmake cmake ` |
75 | | --S . ` |
76 | | --B buildRelease ` |
77 | | --G "Ninja" ` |
78 | | --DCMAKE_BUILD_TYPE=Release ` |
79 | | --DBUILD_SHARED_LIBS:BOOL=OFF ` |
80 | | --DVTK_ENABLE_WEBGPU:BOOL=ON |
81 | | -cmake --build .\buildRelease |
82 | | -cmake --install .\buildRelease --prefix .\installRelease |
83 | | -``` |
84 | | -```sh [wasm64:Windows] |
85 | | -# In Powershell |
86 | | -emcmake cmake ` |
87 | | --S . ` |
88 | | --B buildRelease ` |
89 | | --G "Ninja" ` |
90 | | --DCMAKE_BUILD_TYPE=Release ` |
91 | | --DBUILD_SHARED_LIBS:BOOL=OFF ` |
92 | | --DVTK_ENABLE_WEBGPU:BOOL=ON ` |
93 | | --DVTK_WEBASSEMBLY_64_BIT:BOOL=ON |
94 | | -cmake --build .\buildRelease |
95 | | -cmake --install .\buildRelease --prefix .\installRelease |
96 | | -``` |
97 | | -::: |
| 3 | +Follow step-by-step instructions at [docs.vtk.org/build_wasm_emscripten#build-project](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html#build-project) to configure and build VTK using emscripten. |
0 commit comments