Skip to content

Commit d0321eb

Browse files
authored
DOC: Update Build Documentation (#1448)
* Update Build_From_Source.md * Add an example CMakeUserPresets.json file
1 parent 3f9c0ee commit d0321eb

File tree

1 file changed

+243
-39
lines changed

1 file changed

+243
-39
lines changed

docs/Build_From_Source.md

Lines changed: 243 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
1-
# Guide to Building From Source #
1+
# Guide to Building From Source
22

3-
## Dependent Libraries ##
3+
## Dependent Libraries
44

55
| Library Name | GitHub Source | Version |
66
|--------------|---------------|---------|
7-
| boost-mp11 | <https://github.com/boostorg/mp11> | 1.77.0 |
8-
| catch2 | <https://github.com/catchorg/Catch2> | 2.13.6 |
9-
| eigen3 | <https://gitlab.com/libeigen/eigen.git> | 3.4.0 |
10-
| expected-lite | <https://github.com/martinmoene/expected-lite> | 0.5.1 |
11-
| fmt | <https://github.com/fmtlib/fmt> | 10.1.1 |
12-
| hdf5 | <https://github.com/HDFGroup/hdf5/> | 1.14.4.3 |
13-
| itk | <https://github.com/InsightSoftwareConsortium/ITK.git> | 5.2.1 |
14-
| nlohmann-json | <https://github.com/nlohmann/json/> | 3.11.12 |
15-
| pybind11 | <https://github.com/pybind/pybind11.git> | 2.12 |
16-
| span-lite | <https://github.com/martinmoene/span-lite> | 0.10.3 |
17-
| tbb | <https://github.com/oneapi-src/onetbb> | 2021.4.0 |
18-
| ebsdlib | <https://www.github.com/bluequartzsoftware/EBSDLib> | 1.0.39 |
7+
| benchmark | <https://github.com/google/benchmark> | 1.8.4 |
8+
| blosc | <https://github.com/Blosc/c-blosc> | 1.18.1 |
9+
| boost-mp11 | <https://github.com/boostorg/mp11> | 1.77.0 |
10+
| catch2 | <https://github.com/catchorg/Catch2> | 2.13.6 |
11+
| ebsdlib | <https://www.github.com/bluequartzsoftware/EBSDLib> | 1.0.39 |
12+
| eigen3 | <https://gitlab.com/libeigen/eigen.git> | 3.4.0 |
13+
| expected-lite | <https://github.com/martinmoene/expected-lite> | 0.8.0 |
14+
| fmt | <https://github.com/fmtlib/fmt> | 11.1.4 |
1915
| h5support | <https://www.github.com/bluequartzsoftware/H5Support> | 1.0.13 |
20-
| nod | <https://github.com/fr00b0/nod.git> | 0.5.4 |
21-
| reproc | <https://github.com/DaanDeMeyer/reproc> | 14.2.4 |
22-
23-
## Prerequisites ##
16+
| hdf5 | <https://github.com/HDFGroup/hdf5/> | 1.14.4.3 |
17+
| itk | <https://github.com/InsightSoftwareConsortium/ITK.git> | 5.4.4 |
18+
| lz4 | <https://github.com/lz4/lz4> | 1.9.4 |
19+
| nlohmann-json | <https://github.com/nlohmann/json/> | 3.11.2 |
20+
| nod | <https://github.com/fr00b0/nod.git> | 0.5.4 |
21+
| nxcommon | <https://github.com/BlueQuartzSoftware/NXCommon> | 0.1.1 |
22+
| nxh5support | <https://github.com/BlueQuartzSoftware/NXH5Support> | 0.1.0 |
23+
| pugixml | <https://github.com/zeux/pugixml> | 1.11.4 |
24+
| pybind11 | <https://github.com/pybind/pybind11.git> | 2.12.0 |
25+
| snappy | <https://github.com/google/snappy> | 1.1.9 |
26+
| span-lite | <https://github.com/martinmoene/span-lite> | 0.10.3 |
27+
| spdlog | <https://github.com/gabime/spdlog> | 1.15.3 |
28+
| tbb | <https://github.com/oneapi-src/onetbb> | 2021.4.0 |
29+
| reproc | <https://github.com/DaanDeMeyer/reproc> | 14.2.5 |
30+
| zlib | <https://www.zlib.net/> | 1.3.1 |
31+
| zstd | <https://facebook.github.io/zstd/> | 1.5.2 |
32+
33+
## Prerequisites
2434

2535
In order to compile `simplnx` you will need a C++20 compiler suite installed on your computer.
2636

@@ -29,11 +39,13 @@ In order to compile `simplnx` you will need a C++20 compiler suite installed on
2939
+ macOS 12.5 and Xcode 14.2 or higher
3040
+ Linux with GCC Version 11.0 or higher or clang 14.
3141

32-
## Install vcpkg ##
42+
For Python Bindings a Python version of 3.8 is the minimum version, but internally 3.11 and 3.12 are the actively used versions.
43+
44+
## Install vcpkg
3345

3446
The `simplnx` project uses the [vcpkg](https://www.github.com/microsoft/vcpkg) to manage it's dependent libraries. If this is not already installed on your system then you will need to download and compile it.
3547

36-
### Windows ###
48+
### Windows
3749

3850
Clone the vcpkg repository into a location that it will be used from. inside your home directory or at `C:/vcpkg` is a reasonable spot. *DO NOT USE A PATH WITH SPACES IN ANY OF THE FOLDERS*.
3951

@@ -44,7 +56,7 @@ git clone https://www.github.com/microsoft/vcpkg
4456

4557
The `bootstrap-vcpkg.bat` file should be run automatically by CMake the first time. This will create the `vcpkg.exe` file. Additionally CMake should automatically find `vcpkg.exe`. If CMake does not find it, you may need to add it to your `PATH` variable.
4658

47-
## Clone Appropriate Repositories ##
59+
## Clone Appropriate Repositories
4860

4961
Within the folder DREAM3D-Dev clone both the `simplnx` and `DREAM3D_Data` repositories. The `DREAM3D_Data` repo is optional but does contain testing data.
5062

@@ -54,13 +66,13 @@ Create a location to keep the `simplnx` repositories and make builds. You can do
5466
git clone --recursive https://github.com/bluequartzsoftware/simplnx
5567
```
5668

57-
## Configure simplnx with CMake ##
69+
## Configure simplnx with CMake
5870

5971
For this example we are going to do an "in-source" build. By default git will ignore some basic names for build directories such as `Debug, Release, x64`. CMake can generate lots of project files from ninja, to nmake to Visual Studio. For this example we are going to use the `ninja` generator so we will need to keep the Debug and Release builds separated.
6072

6173
The first time `simplnx` is configured with CMake, VCPKG will download, build and install the needed dependent libraries. This can take a few minutes so be patient. After `simplnx` is configured you can build it using your IDE (Visual Studio) or ninja (QtCreator, CLion) or cmake itself.
6274

63-
### Windows with Visual Studio IDE ###
75+
### Windows with Visual Studio IDE
6476

6577
This example shows how to configure simplnx to build using Visual Studio IDE
6678

@@ -73,7 +85,7 @@ cd %BUILD_DIR%
7385
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALL_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=%BUILD_DIR% -DVCPKG_MANIFEST_FEATURES="tests;parallel" -DDREAM3D_Data_Dir=../../DREAM3D_Data ../simplnx
7486
```
7587

76-
### Windows with Ninja and IDE of choice (QtCreator, CLion, command line) ###
88+
### Windows with Ninja and IDE of choice (QtCreator, CLion, command line)
7789

7890
Adjust the below commands to the sytle of your shell (The below example is done in Windows Command Prompt Batch file style).
7991

@@ -90,7 +102,7 @@ cd %BUILD_DIR%
90102
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALL_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=%BUILD_DIR% -DVCPKG_MANIFEST_FEATURES="tests;parallel" -DDREAM3D_Data_Dir=../../DREAM3D_Data ../simplnx
91103
```
92104

93-
### macOS ARM64/M1 Compile and IDE of choice (QtCreator, CLion, command line) ###
105+
### macOS ARM64/M1 Compile and IDE of choice (QtCreator, CLion, command line)
94106

95107
```shell
96108
export NINJA_INSTALL=/opt/local/bin
@@ -107,10 +119,10 @@ cd $BUILD_DIR
107119
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALL_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=$BUILD_DIR -DVCPKG_MANIFEST_FEATURES="tests;parallel" -DDREAM3D_DATA_DIR=$HOME/Workspace1/DREAM3D_Data -DVCPKG_TARGET_TRIPLET:STRING=$VCPKG_TARGET_TRIPLET ../simplnx
108120
```
109121

110-
## Required CMake Arguments ##
122+
## Required CMake Arguments
111123

112124
+ `-G` and one of the supported CMake generator strings
113-
+ `Ninja` works very well on all platforms if you have [ninja](https://github.com/ninja-build/ninja/releases)
125+
+ `Ninja` works very well on all platforms if you have [ninja](https://github.com/ninja-build/ninja/releases)
114126
+ `-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg.cmake file]`
115127
+ `-DCMAKE_BUILD_TYPE=[Debug|Release]` but **ONLY** if you are using Ninja or 'Unix MakeFiles' as the generator
116128
+ `-DVCPKG_MANIFEST_FEATURES=....` build options
@@ -119,42 +131,65 @@ cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALL_ROOT/scripts/buildsystems/v
119131
+ MacOS: [x64-osx-dynamic | arm64-osx-dynamic]
120132
+ Linux: x64-linux-dynamic
121133
+ Windows:
134+
+ `-DVCPKG_HOST_TRIPLET=....` Correct VCPKG triplet for your platform/operating system
135+
+ MacOS: [x64-osx-dynamic | arm64-osx-dynamic]
136+
+ Linux: x64-linux-dynamic
137+
+ Windows:
138+
139+
### Notable CMake Arguments
122140

123-
## Adding Plugins ##
141+
| Identifier | Type | Explanation |
142+
|------------|------|-------------|
143+
| `ITKImageProcessing_USE_JOB_POOL` | `BOOL` | When `ON` the amount of threads used to build `ITK` library plugin is capped (see `ITKImageProcessing_JOB_POOL`). Some of the `ITK` files more 2+ GB of memory to compile due to heavy templating. This is to prevent sytems from running out of memory during compilation. |
144+
| `ITKImageProcessing_JOB_POOL` | `STRING` | If `ITKImageProcessing_USE_JOB_POOL` is `ON`, this variable is the maximum number of threads available to the `ITK` plugin during compilation. For example on a system with 32 threads and 64GB of RAM a value of `16` will prevent out-of-memory errors during compilation. |
145+
| `SIMPLNX_BUILD_TESTS` | `BOOL` | Turning this on will compile the filter/library tests and include them in the all ctests target |
146+
| `SIMPLNX_BUILD_DOCS` | `BOOL` | Turning this on will build the library/filters documentation, `SPHINX_BUILD_EXECUTABLE` must be defined |
147+
| `SPHINX_BUILD_EXECUTABLE` | `PATH` | The absolute path to to the sphinx executable; *required* for `SIMPLNX_BUILD_PYTHON_DOCS` and/or `SIMPLNX_BUILD_DOCS` |
148+
| `SIMPLNX_EXTRA_PLUGINS` | `STRING` | A list of plugin targets (separated by `;`) to include into the library. Currently the only offical additional plugin not bundled is `SimplnxReview` which is untested filters |
149+
| `SIMPLNX_ENABLE_BENCHMARK_UTILITY` | `BOOL` | Turning this on will include the preffered benchmarking library; Be sure to **add** `benchmark` **to** `VCPKG_MANIFEST_FEATURES` **list** |
124150

125-
By default the **only** plugin that is compiled is the `SimplnxCore` plugin. If you would like to build any of the additional plugins you can provide additional arguments to the configuration command. **NOTE** For the `SIMPLNX_EXTRA_PLUGINS` CMake argument, if you have multiple plugins separate each with a `;` character (which is why we double quote the value for the SIMPLNX_EXTRA_PLUGINS variable.)
151+
### Python Binding CMake Arguments
126152

127-
### ITKImageProcessing ###
153+
*NOTE: Be sure to **add** `python` **to** `VCPKG_MANIFEST_FEATURES` **list** if you are enabling python bindings*. Remember to separate each manifest feature with a `;`. Example: `tests;parallel;itk;ebsd;benchmark;python`
154+
155+
| Identifier | Type | Explanation |
156+
|------------|------|-------------|
157+
| `SIMPLNX_BUILD_PYTHON` | `BOOL` | Turning this on will enable Python Bindings, but several other variables must be supplied to get it to configure. |
158+
| `Python_EXECUTABLE | `PATH` | The absolute path to to the python executable; *required* for Python Bindings |
159+
| `SIMPLNX_PY_DISABLE_HIDDEN_VISIBILITY` | `BOOL` | Turning this on is *required* for Python Bindings on Unix-based systems |
160+
| `SIMPLNX_EMBED_PYTHON` | `BOOL` | Turning this on will allow you to write python filters/plugins that will be loaded/included into the final compiled library executable |
161+
| `SIMPLNX_BUILD_PYTHON_TESTS` | `BOOL` | Turning this on will also compile the python tests and include them in the all ctests target |
162+
| `SIMPLNX_BUILD_PYTHON_DOCS` | `BOOL` | Turning this on will build the python documentation, `SPHINX_BUILD_EXECUTABLE` must be defined |
163+
164+
### ITKImageProcessing
128165

129166
This plugin gives simplnx access to the ability to read/write images and use the **ITK** library to process images.
130167

131-
There are 2 arguments that need to be added to the CMake configuration command
168+
There are 1 arguments that need to be added to the CMake configuration command
132169

133-
+ `-DSIMPLNX_EXTRA_PLUGINS="ITKImageProcessing"`
134170
+ `-DVCPKG_MANIFEST_FEATURES="tests;parallel;itk"`
135171

136-
### OrientationAnalysis ###
172+
### OrientationAnalysis
137173

138174
This plugin gives simplnx the ability to process typical EBSD style of data.
139175

140-
+ `-DSIMPLNX_EXTRA_PLUGINS="OrientationAnalysis"`
141176
+ `-DVCPKG_MANIFEST_FEATURES="tests;parallel;ebsd"`
142177

143-
## VCPKG Options ##
178+
## VCPKG Options
144179

145-
### Defining where VCPKG installs the dependent libraries ###
180+
### Defining where VCPKG installs the dependent libraries
146181

147182
By default VCPKG will install any library that it compiles into vcpkg specific and platform specific locations. If you would like to specifically set where those libraries are installed the following cmake code will allow that:
148183

149184
+ `-DVCPKG_INSTALLED_DIR=$HOME/workspace/vcpkg-installed`
150185

151-
### Disable VCPKG from checking for updates with each configuration ###
186+
### Disable VCPKG from checking for updates with each configuration
152187

153188
Be default VCPKG will check for updates to the libraries that it compiles. If you would like to skip this step each time the following CMake code is needed:
154189

155190
+ `-DVCPKG_MANIFEST_INSTALL=OFF`
156191

157-
## Defining where test data is stored ##
192+
## Defining where test data is stored
158193

159194
Simplnx and its plugins require test files to be able to perform the unit tests. By default these will be store inside the build directory. This means that if you have multiple build directories, a separate copy of all the test files will be downloaded for each build directory. The developer can set the `DREAM3D_DATA_DIR` variable to a path that will be used. They will need to set this for **each** build directory. You **MUST** define `DREAM3D_DATA_DIR` using an absolute path. Relative paths **will not work**.
160195

@@ -164,7 +199,7 @@ The developer can also turn off the downloading of any test data with the follow
164199

165200
+ `-DSIMPLNX_DOWNLOAD_TEST_FILES=OFF`
166201

167-
## Python Bindings ##
202+
## Python Bindings
168203

169204
Python bindings are available for simplnx. To install them, please use an Anaconda virtual environment like the following:
170205

@@ -175,3 +210,172 @@ conda create -n cxpython python=3.8
175210
conda activate cxpython
176211
conda install -c bluequartzsoftware simplnx
177212
```
213+
214+
## Example Linux/Ninja CMakeUserPresets.json Template
215+
216+
Be sure to update `Python_EXECUTABLE`, `SPHINX_BUILD_EXECUTABLE`, and `VCPKG_INSTALLATION_ROOT`.
217+
218+
Update `generator` with preferred generator if you wish to avoid Ninja.
219+
220+
If adapting for another platform, be sure to update `VCPKG_TARGET_TRIPLET` and `VCPKG_HOST_TRIPLET`, then search and replace "linux" with current OS.
221+
222+
```console
223+
{
224+
"version": 2,
225+
"cmakeMinimumRequired": {
226+
"major": 3,
227+
"minor": 20,
228+
"patch": 0
229+
},
230+
"configurePresets": [
231+
{
232+
"name": "default-all",
233+
"displayName": "default-all",
234+
"description": "Build configuration for Linux",
235+
"generator": "Ninja",
236+
"binaryDir": "${sourceDir}/../DREAM3D-Build/dream3dnx",
237+
"hidden": true,
238+
"cacheVariables": {
239+
"VCPKG_MANIFEST_DIR": {
240+
"type": "STRING",
241+
"value": "${sourceDir}/../simplnx"
242+
},
243+
"VCPKG_MANIFEST_FEATURES": {
244+
"type": "STRING",
245+
"value": "tests;parallel;itk;ebsd;benchmark;python"
246+
},
247+
"VCPKG_INSTALLED_DIR": {
248+
"type": "STRING",
249+
"value": "${sourceDir}/../vcpkg-installed"
250+
},
251+
"VCPKG_MANIFEST_INSTALL": {
252+
"type": "BOOL",
253+
"value": "ON"
254+
},
255+
"SIMPLNX_EXTRA_PLUGINS": {
256+
"type": "STRING",
257+
"value": "SimplnxReview"
258+
},
259+
"CMAKE_TOOLCHAIN_FILE": {
260+
"type": "FILEPATH",
261+
"value": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
262+
},
263+
"SIMPLNX_BUILD_TESTS": {
264+
"type": "BOOL",
265+
"value": "ON"
266+
},
267+
"SIMPLNX_BUILD_DOCS": {
268+
"type": "BOOL",
269+
"value": "OFF"
270+
},
271+
"ITKImageProcessing_USE_JOB_POOL": {
272+
"type": "BOOL",
273+
"value": "ON"
274+
},
275+
"ITKImageProcessing_JOB_POOL": {
276+
"type": "STRING",
277+
"value": "16"
278+
},
279+
"SIMPLNX_BUILD_PYTHON": {
280+
"type": "BOOL",
281+
"value": "ON"
282+
},
283+
"SIMPLNX_EMBED_PYTHON": {
284+
"type": "BOOL",
285+
"value": "ON"
286+
},
287+
"SIMPLNX_BUILD_PYTHON_TESTS": {
288+
"type": "BOOL",
289+
"value": "ON"
290+
},
291+
"SIMPLNX_PY_DISABLE_HIDDEN_VISIBILITY": {
292+
"type": "BOOL",
293+
"value": "ON"
294+
},
295+
"Python_EXECUTABLE": {
296+
"type": "PATH",
297+
"value": "absolute/path/to/python"
298+
},
299+
"SPHINX_BUILD_EXECUTABLE": {
300+
"type": "PATH",
301+
"value": "absolute/path/to/sphinx"
302+
},
303+
"DREAM3D_DATA_DIR": {
304+
"type": "STRING",
305+
"value": "${sourceDir}/../DREAM3D_Data"
306+
},
307+
"SIMPLNX_ENABLE_BENCHMARK_UTILITY": {
308+
"type": "BOOL",
309+
"value": "ON"
310+
}
311+
},
312+
"environment": {"VCPKG_INSTALLATION_ROOT":"absolute/path/to/vcpkg"}
313+
},
314+
{
315+
"name": "x64",
316+
"inherits": "default-all",
317+
"displayName": "x64",
318+
"description": "x64 Arch",
319+
"generator": "Ninja",
320+
"binaryDir": "${sourceDir}/../DREAM3D-Build/DREAM3DNX-Linux-x64",
321+
"hidden": true,
322+
"cacheVariables": {
323+
"VCPKG_TARGET_TRIPLET": {
324+
"type": "STRING",
325+
"value": "x64-linux-dynamic"
326+
},
327+
"VCPKG_HOST_TRIPLET": {
328+
"type": "STRING",
329+
"value": "x64-linux-dynamic"
330+
}
331+
}
332+
},
333+
{
334+
"name": "Linux-Debug-x64",
335+
"inherits": "x64",
336+
"displayName": "Linux-Debug-x64",
337+
"description": "Build configuration for Linux",
338+
"generator": "Ninja",
339+
"binaryDir": "${sourceDir}/../DREAM3D-Build/DREAM3DNX-Debug-Linux-x64",
340+
"cacheVariables": {
341+
"CMAKE_BUILD_TYPE": {
342+
"type": "STRING",
343+
"value": "Debug"
344+
}
345+
}
346+
},
347+
{
348+
"name": "Linux-Release-x64",
349+
"inherits": "x64",
350+
"displayName": "Linux-Release-x64",
351+
"description": "Build configuration for Linux",
352+
"generator": "Ninja",
353+
"binaryDir": "${sourceDir}/../DREAM3D-Build/DREAM3DNX-Release-Linux-x64",
354+
"cacheVariables": {
355+
"CMAKE_BUILD_TYPE": {
356+
"type": "STRING",
357+
"value": "Release"
358+
}
359+
}
360+
}
361+
],
362+
"buildPresets": [
363+
{
364+
"name": "Debug-x64",
365+
"displayName": "Debug-x64",
366+
"description": "Build configuration for Debug-x64",
367+
"configurePreset": "Linux-Debug-x64",
368+
"configuration": "Debug"
369+
},
370+
{
371+
"name": "Release-x64",
372+
"displayName": "Release-x64",
373+
"description": "Build configuration for Release-x64",
374+
"configurePreset": "Linux-Release-x64",
375+
"configuration": "Release"
376+
377+
}
378+
]
379+
}
380+
381+
```

0 commit comments

Comments
 (0)