Skip to content
Merged
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
28 changes: 15 additions & 13 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@
"name": "serial",
"inherits": "base",
"displayName": "Serial",
"description": "Default build, no OpenMP (was: make serial / make dyna)",
"description": "Simulation programs only, no OpenMP, no GoogleTest (was: make serial / make dyna)",
"binaryDir": "${sourceDir}/build",
"cacheVariables": { "SLIMED_ENABLE_OPENMP": "OFF" }
"cacheVariables": {
"SLIMED_ENABLE_OPENMP": "OFF",
"SLIMED_BUILD_TESTS": "OFF"
}
},
{
"name": "omp",
"inherits": "base",
"displayName": "OpenMP",
"description": "OpenMP build, -fopenmp and -DOMP (was: make omp / make dyna_omp)",
"description": "Simulation programs only, -fopenmp and -DOMP, no GoogleTest (was: make omp / make dyna_omp)",
"binaryDir": "${sourceDir}/build-omp",
"cacheVariables": { "SLIMED_ENABLE_OPENMP": "ON" }
"cacheVariables": {
"SLIMED_ENABLE_OPENMP": "ON",
"SLIMED_BUILD_TESTS": "OFF"
}
},
{
"name": "coverage",
"inherits": "base",
"displayName": "Coverage",
"description": "Serial build instrumented for gcov/lcov (was: make test COVERAGE=1)",
"description": "Instrumented for gcov/lcov; builds and runs the tests, so needs GoogleTest (was: make test COVERAGE=1)",
"binaryDir": "${sourceDir}/build-cov",
"cacheVariables": {
"SLIMED_ENABLE_OPENMP": "OFF",
Expand All @@ -53,28 +59,24 @@
"hidden": true,
"output": { "outputOnFailure": true }
},
{ "name": "serial", "inherits": "base", "configurePreset": "serial" },
{ "name": "omp", "inherits": "base", "configurePreset": "omp" },
{ "name": "coverage", "inherits": "base", "configurePreset": "coverage" }
],

"workflowPresets": [
{
"name": "serial",
"displayName": "Configure, build and test the serial version",
"displayName": "Configure and build the serial version",
"steps": [
{ "type": "configure", "name": "serial" },
{ "type": "build", "name": "serial" },
{ "type": "test", "name": "serial" }
{ "type": "build", "name": "serial" }
]
},
{
"name": "omp",
"displayName": "Configure, build and test the OpenMP version",
"displayName": "Configure and build the OpenMP version",
"steps": [
{ "type": "configure", "name": "omp" },
{ "type": "build", "name": "omp" },
{ "type": "test", "name": "omp" }
{ "type": "build", "name": "omp" }
]
},
{
Expand Down
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ SLIMED builds with CMake.
Because serial and OpenMP builds are both used routinely, `CMakePresets.json`
defines them as named presets, each with its own build directory:

| Preset | Build directory | Equivalent to |
| --- | --- | --- |
| `serial` | `build/` | `make serial` / `make dyna` |
| `omp` | `build-omp/` | `make omp` / `make dyna_omp` |
| `coverage` | `build-cov/` | `make test COVERAGE=1` |
| Preset | Build directory | Builds | Equivalent to |
| --- | --- | --- | --- |
| `serial` | `build/` | simulation programs | `make serial` / `make dyna` |
| `omp` | `build-omp/` | simulation programs | `make omp` / `make dyna_omp` |
| `coverage` | `build-cov/` | programs + unit tests | `make test COVERAGE=1` |

`serial` and `omp` build the four simulation programs only. They set
`SLIMED_BUILD_TESTS=OFF`, so GoogleTest is never looked for and does not need to
be installed to use them.

Configure, build and test in one command:
Configure and build in one command:

```console
cmake --workflow --preset omp
Expand All @@ -133,7 +137,16 @@ Or drive the steps separately:
```console
cmake --preset omp # configure
cmake --build --preset omp # build (all cores)
ctest --preset omp # test
```

To run the unit tests, either use the `coverage` preset or configure a build
directory by hand -- `SLIMED_BUILD_TESTS` defaults to `ON`, so a plain
configure includes them:

```console
cmake -S . -B build-test
cmake --build build-test -j8
ctest --test-dir build-test --output-on-failure
```

Because each preset owns a separate build directory, switching back and forth
Expand Down Expand Up @@ -276,17 +289,26 @@ libstdc++; use the default Apple Clang when you need the tests.

### Tests

`SLIMED_BUILD_TESTS` defaults to `ON`, so any build directory configured by hand
includes the unit tests:

```console
ctest --test-dir build --output-on-failure
cmake -S . -B build-test
cmake --build build-test -j8
ctest --test-dir build-test --output-on-failure
```

Note that the `serial` and `omp` presets deliberately set it to `OFF`, so
`build/` and `build-omp/` contain no tests; use a separate directory as above,
or the `coverage` preset.

Each GoogleTest case is registered with CTest individually. Several tests open
fixture files by paths relative to the working directory, so CTest runs
`test_main` from the top of the source tree automatically. The binary can also
be run directly, from the source root:

```console
./build/bin/test_main
./build-test/bin/test_main
```

If GoogleTest is not installed, CMake prints a warning and skips the test
Expand All @@ -311,7 +333,7 @@ collect. There is no packaged `coverage-html` target yet.
```console
cmake --build build --target clean # like "make clean"; keeps the configuration
rm -rf build # full reset, forgets all cached options
rm -rf build build-omp build-cov # remove every preset build directory
rm -rf build build-omp build-cov build-test # remove all build directories
```

### The previous Makefile
Expand Down
Loading