Skip to content

Commit 800d32f

Browse files
committed
doc: Add "Building with CMake" section to README.md
1 parent 85777dc commit 800d32f

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Below we compare the PinSketch algorithm (which `libminisketch` is an implementa
6666
* **Difference type:** PinSketch can only compute the symmetric difference from a merged sketch, while CPISync and IBLT can distinguish which side certain elements were missing on. When the decoder has access to one of the sets, this generally doesn't matter, as he can look up each of the elements in the symmetric difference with one of the sets.
6767
* **Secure sketch:** Whether the sketch satisfies the definition of a secure sketch<sup>[[1]](#myfootnote1)</sup>, which implies a minimal amount about a set can be extracted from a sketch by anyone who does not know most of the elements already. This makes the algorithm appropriate for applications like fingerprint authentication.
6868

69-
## Building
69+
## Building with Autotools
7070

7171
The build system is very rudimentary for now, and [improvements](https://github.com/bitcoin-core/minisketch/pulls) are welcome.
7272

@@ -78,6 +78,44 @@ cd minisketch
7878
./autogen.sh && ./configure && make
7979
```
8080

81+
## Building with CMake
82+
83+
To maintain a pristine source tree, CMake encourages performing an out-of-source build by using a separate dedicated build directory.
84+
85+
### Building on POSIX systems
86+
87+
The following commands will produce the same `libminisketch.a` file as in the example [above](#building-with-autotools):
88+
89+
```bash
90+
cmake -B build -DCMAKE_CXX_FLAGS="-g -O2" # Generate a build system in subdirectory "build"
91+
cmake --build build # Run the actual build process
92+
ctest --test-dir build # Run the test suite
93+
sudo cmake --install build # Install the library into the system (optional)
94+
```
95+
96+
Run `cmake -B build -LH` or `ccmake -B build` to see the full list of configurable build options.
97+
98+
### Cross compiling
99+
100+
The following example works on modern Ubuntu/Debian systems:
101+
102+
```bash
103+
sudo apt install g++-mingw-w64-x86-64-posix
104+
cmake -B build -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix
105+
cmake --build build
106+
```
107+
108+
### Building on Windows
109+
110+
The following example assumes the use of Visual Studio 2022 and CMake v3.21 or newer.
111+
112+
In "Developer Command Prompt for VS 2022":
113+
114+
```cmd
115+
cmake -B build
116+
cmake --build build --config Release
117+
```
118+
81119
## Usage
82120

83121
In this section Alice and Bob are trying to find the difference between their sets.

0 commit comments

Comments
 (0)