Newer
Older
This project is a stub illustrating how the building of nse-projects
with CMake is (should be) organized. This one represents *nse-XXX-XXX*
(e.g. [nse-sphere3d-geo](http://tesla.parallel.ru/vonopr/nse-sphere3d-geo))
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Throughout the example projects prefix *nse* is substituted with *exple*.
## Dependencies
The project depends on
[explelibx-common](http://tesla.parallel.ru/vonopr/explelibx-common)
and
[explelibx-mgrid](http://tesla.parallel.ru/vonopr/explelibx-mgrid) projects.
You must have git, cmake (>= 3.14) and C++ compiler on your system path.
## Download
Download the current project with
```bash
mkdir exple-cmake-build
cd exple-cmake-build
git clone http://tesla.parallel.ru/vonopr/exple-cmake-build.git
cd ..
```
### Simple build
After downloading the project build it with
```bash
mkdir exple-cmake-build/build
cd exple-cmake-build/build
cmake -B . -S ../exple-cmake-build
cmake --build .
```
CMake should download the dependencies automatically during first invocation and generate
executable files *exple-add-numbers* or *exple-add-numbers.exe* during build stage.
Run it with `./exple-add-numbers` on UNIX or with `.\exple-add-numbers.exe` on Windows.
The output should be
```Multiplication of sum of 2 and 3 by 4 is... 20```
### Build with depndencies local dependencies
If you are a developer you might need a possibility to edit the sources provided by *nselibx-\** projects
(*explelibx-\** here). This can be done by passing `-DDOWNLOAD_DEPS=OFF` to the CMake configuration command.
Then dependencies should be located in `../..` relative to the local repository of *exple-cmake-build*.
Thus the directory structure should be
```tree
.
├── exple-cmake-build
│ └── exple-cmake-build
│ └── exple-cmake-build
├── explelibx-common
│ └── explelibx-common
└── explelibx-mgrid
└── explelibx-mgrid
```
You can first [download the current project](#download) and then
download dependencies and configure cmake with `-DDOWNLOAD_DEPS=OFF`
```bash
git clone http://tesla.parallel.ru/vonopr/explelibx-common.git
git clone http://tesla.parallel.ru/vonopr/explelibx-mgrid.git
mkdir build
cd build
cmake -B . -S ../exple-cmake-build/exple-cmake-build -DDOWNLOAD_DEPS=OFF
cmake --build .
```
During cmake configuration simillar messages should appear
```
-- Path to 'explelibx-common' project
COMMON_DIR: D:/nse/example-structures/explelibx-common
-- Path to 'explelibx-mgrid' project
GRID_DIR: D:/nse/example-structures/explelibx-mgrid
```
### Custom paths to dependencies
Otherwise, you can change the default paths with cmake's *COMMON_DIR* and
*GRID_DIR* variables. Works only if download is disables, i.e. *DOWNLOAD_DEPS=OFF*
E.g. if you want to build the sources' directory structure as follows
```tree
.
├── exple-cmake-build
│ └── exple-cmake-build
│ └── exple-cmake-build
├── explelibx-common
│ └── explelibx-common
└── explelibx-mgrid
└── explelibx-mgrid
```
do
```bash
git clone http://tesla.parallel.ru/vonopr/exple-cmake-build.git
git clone http://tesla.parallel.ru/vonopr/explelibx-common.git
git clone http://tesla.parallel.ru/vonopr/explelibx-mgrid.git
mkdir build
cd build
cmake -B . -S ../exple-cmake-build -DDOWNLOAD_DEPS=OFF -DCOMMON_DIR=../explelibx-common -DGRID_DIR=../explelibx-mgrid
```
(This time [the initial download step](#download) should be skipped)
### Notes on building on Windows
C++ compiler and cmake's default building generator may be incompatible. If so you should provide the appropriate
generator with `-G` option. Visual Studio C++ Compiler should be used with `Visual Studio 17 2022`-like generators,
Intel C++ Compiler should be used with `NMake Makefiles`, MinGW C++ should be used `MinGW Makefiles`:
```
cmake -B . -S ../exple-cmake-build -G"Visual Studio 17 2022"
```