Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit b415f99

Browse files
Use cmake presets and make configuration, building and testing a breeze.
1 parent d9c9e9c commit b415f99

File tree

4 files changed

+79
-13
lines changed

4 files changed

+79
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist
1010
CMakeCache.txt
1111
CMakeFiles
1212
compile_commands.json
13+
Testing

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ set(installable_libs os2dsrules os2dsrules_compiler_flags)
5959
install(TARGETS ${installable_libs} DESTINATION lib)
6060

6161
# Install header files on system.
62-
install(FILES include/os2dsrules.hpp include/cpr-detector.hpp include/data_structures.hpp include/name_rule.hpp wordlist_rule.hpp DESTINATION include)
62+
install(FILES include/os2dsrules.hpp include/cpr-detector.hpp include/data_structures.hpp include/name_rule.hpp include/wordlist_rule.hpp DESTINATION include)

CMakePresets.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 20,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "default-debug",
11+
"displayName": "Default Debug configuration preset",
12+
"generator": "Ninja",
13+
"binaryDir": "${sourceDir}/build_cmake/debug",
14+
"installDir": "/usr/",
15+
"cacheVariables": {
16+
"CMAKE_BUILD_TYPE": "Debug"
17+
}
18+
},
19+
{
20+
"name": "default-release",
21+
"displayName": "Default Release configuration preset",
22+
"generator": "Ninja",
23+
"binaryDir": "${sourceDir}/build_cmake/release",
24+
"installDir": "/usr/",
25+
"cacheVariables": {
26+
"CMAKE_BUILD_TYPE": "Release"
27+
}
28+
}
29+
],
30+
"buildPresets": [
31+
{
32+
"name": "os2ds-rules-debug",
33+
"displayName": "os2ds-rules Debug build preset",
34+
"verbose": true,
35+
"configurePreset": "default-debug"
36+
},
37+
{
38+
"name": "os2ds-rules-release",
39+
"displayName": "os2ds-rules Release build preset",
40+
"configurePreset": "default-release"
41+
}
42+
],
43+
"testPresets": [
44+
{
45+
"name": "test-debug",
46+
"configurePreset": "default-debug",
47+
"output": {
48+
"outputOnFailure": true
49+
},
50+
"execution": {
51+
"noTestsAction": "error",
52+
"stopOnFailure": true
53+
}
54+
},
55+
{
56+
"name": "test-release",
57+
"configurePreset": "default-release",
58+
"output": {
59+
"outputOnFailure": true
60+
},
61+
"execution": {
62+
"noTestsAction": "error",
63+
"stopOnFailure": true
64+
}
65+
}
66+
]
67+
}

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ You can install either or both of the `C++` library or the `python` extension.
2222
For the `C++` library you need a few different things:
2323

2424
- A compiler that supports `C++20`. We recommend using either `g++` (GCC) or `clang` (LLVM).
25-
- `cmake>=3.20`: Primary build system.
25+
- `cmake>=3.20`: Primary (meta) build system.
26+
- `ninja`: Cross-platform backend for cmake.
2627
- `gtest` (Google Test): For building and running the test suite.
2728

2829
For development, you additionally want:
@@ -36,32 +37,29 @@ To build, run the following:
3637

3738
```sh
3839
# Make a build directory
39-
mkdir build_cmake
40-
cd build_cmake
41-
cmake -DCMAKE_BUILD_TYPE=Release .. # or use 'Debug' for development.
42-
cmake --build .
40+
cmake . --preset default-debug
41+
cmake --build --preset os2ds-rules-debug
4342
```
4443

4544
This will build the shared library `libos2dsrules.so` and the test suite `testsuite`.
4645

4746
To install the library, run the following from the build directory:
4847

4948
```sh
50-
sudo make install
49+
sudo cmake --install build_cmake/debug
5150
```
5251

53-
By default, this will install headers into `/usr/local/include` and shared objects to
54-
`/usr/local/lib`. Make sure your include path and `LD_LIBRARY_PATH` is configured
55-
properly. You can run: `export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH` to
56-
configure the library load path.
52+
By default, this will install headers into `/usr/include` and shared objects to
53+
`/usr/lib`.
5754

5855
To run the test suite:
5956

6057
```sh
61-
ctest --output-on-failure
58+
ctest --preset test-debug
6259
```
6360

64-
Currently, this has only been tested on `linux` and it should work on `macOS` as well.
61+
Currently, this has only been tested on `linux`, but it should work on `macOS` as well.
62+
It remains to be tested on windows.
6563

6664
### The Python extension: `os2ds-rules`
6765

0 commit comments

Comments
 (0)