Skip to content

Commit

Permalink
Update README with "FetchContent" section
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jul 20, 2023
1 parent eea58b7 commit 98c64b5
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
This is a DEMO repository with examples of using an installed [`secp256k1`](https://github.com/bitcoin-core/secp256k1)
library with [CMake](https://github.com/bitcoin-core/secp256k1/pull/1113).
This is a DEMO repository with examples of using the [`libsecp256k1`](https://github.com/bitcoin-core/secp256k1)
library in downstream projects with CMake.

Source code is borrowed from https://github.com/bitcoin-core/secp256k1/tree/master/examples directly.

---

There are two options to use the `secp256k1` library in a your project:
- install it into your system
- have its source code as a subtree in your project's source tree
There are multiple options to use the `libsecp256k1` library in your project:
- install it into your system,
- have its source code as a subtree in your project's source tree,
- use the `FetchContent` module.


## Installed library
Expand All @@ -16,14 +18,14 @@ Switch to the ["main"](https://github.com/hebasto/secp256k1-CMake-example/tree/m

To build a binary, use commands as follows:
```sh
cmake -S . -B build
cmake -B build
cmake --build build
```

If the `secp256k1` library has been installed in a non-standard path, add its installation prefix to `CMAKE_PREFIX_PATH`.
For example:
```sh
cmake -S . -B build -DCMAKE_PREFIX_PATH=/home/username/custom_lib
cmake -B build -DCMAKE_PREFIX_PATH=/home/username/custom_lib
cmake --build build
```

Expand All @@ -33,8 +35,20 @@ Switch to the ["subtree"](https://github.com/hebasto/secp256k1-CMake-example/tre

```sh
dir=$(mktemp -d)
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$dir
cmake -B build -DCMAKE_INSTALL_PREFIX=$dir
cmake --build build --target install
tree $dir
$dir/bin/secp256k1-example
```
```

## Using `FetchContent` module

Switch to the ["fetch"](https://github.com/hebasto/secp256k1-CMake-example/tree/fetch) branch of this repository.

```sh
dir=$(mktemp -d)
cmake -B build -DCMAKE_INSTALL_PREFIX=$dir
cmake --build build --target install
tree $dir
$dir/bin/secp256k1-example
```

0 comments on commit 98c64b5

Please sign in to comment.