2019-10-04 08:29:24 +02:00
|
|
|
# Installation Guide
|
|
|
|
|
|
|
|
## Installation and Reuse
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
There are a few different ways of installing/reusing `units` in your project.
|
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
### Copy
|
2019-04-06 23:25:35 +02:00
|
|
|
|
|
|
|
As `units` is a header-only library you can simply copy `src/include` directory to
|
|
|
|
your source tree and use it as regular header files.
|
|
|
|
|
|
|
|
NOTE: Until C++20 arrives the library has some 3rd party dependencies that provide
|
2019-12-17 09:27:32 +01:00
|
|
|
experimental C++20 features. The list of dependencies include:
|
|
|
|
- `range-v3@ericniebler` (only for gcc-9, gcc-10 uses gcc's concepts implementation)
|
2019-12-11 07:10:28 +01:00
|
|
|
- `fmt@_`
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-12-17 09:27:32 +01:00
|
|
|
All of them are easily to obtain with `conan`.
|
|
|
|
|
|
|
|
NOTE: In case a full library's repository is to be compiled (instead of just copying
|
|
|
|
`src/include` headers), additionally, the library's unit tests depend on
|
|
|
|
`Catch2@catchorg` conan package.
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
### cmake + conan
|
2019-04-06 23:25:35 +02:00
|
|
|
|
|
|
|
To use `units` as a `cmake` imported library via `cmake` configuration files the following
|
2019-04-10 17:20:32 +01:00
|
|
|
steps may be done:
|
2019-12-11 07:10:28 +01:00
|
|
|
- clone the repository with its submodules:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
git clone --recurse-submodules https://github.com/mpusz/units.git
|
|
|
|
```
|
|
|
|
|
|
|
|
or in case it is already cloned without submodules initialize, fetch, and checkout them with:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
git submodule update --init
|
|
|
|
```
|
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
- add the following remotes to your local `conan` instance
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
```shell
|
|
|
|
conan remote add conan-mpusz https://api.bintray.com/conan/mpusz/conan-mpusz
|
2019-04-10 17:20:32 +01:00
|
|
|
```
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
- add `units` as a dependency to your `conan` file. For example to use testing version of
|
2019-12-17 09:14:31 +01:00
|
|
|
`0.5.0` of `mp-units` add:
|
2019-04-10 17:20:32 +01:00
|
|
|
- `conanfile.txt`
|
|
|
|
|
|
|
|
```text
|
|
|
|
[requires]
|
2019-12-17 09:14:31 +01:00
|
|
|
mp-units/0.5.0@mpusz/testing
|
2019-04-10 17:20:32 +01:00
|
|
|
```
|
2019-10-04 08:29:24 +02:00
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
- `conanfile.py`
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
```python
|
2019-12-17 09:14:31 +01:00
|
|
|
requires = "mp-units/0.5.0@mpusz/testing"
|
2019-04-10 17:20:32 +01:00
|
|
|
```
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
- link your `cmake` target with units
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-04-10 17:20:32 +01:00
|
|
|
```text
|
|
|
|
target_link_libraries(<your_target> PUBLIC|PRIVATE|INTERFACE CONAN_PKG::mp-units)
|
|
|
|
```
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
- install `conan` dependencies before configuring cmake
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
```shell
|
|
|
|
cd build
|
2019-12-11 07:10:28 +01:00
|
|
|
conan install .. -pr <your_conan_profile> -s compiler.cppstd=20 -b=outdated -u
|
2019-04-10 17:20:32 +01:00
|
|
|
```
|
2019-04-06 23:25:35 +02:00
|
|
|
|
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
## Full build and unit testing
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2020-01-31 17:02:27 +01:00
|
|
|
In case you would like to build all the code in this repository (with unit tests and examples)
|
|
|
|
you should use the `CMakeLists.txt` from the parent directory and run Conan with
|
|
|
|
`CONAN_RUN_TESTS=True`.
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
```shell
|
2019-12-11 07:10:28 +01:00
|
|
|
git clone --recurse-submodules https://github.com/mpusz/units.git
|
|
|
|
mkdir units/build && cd units/build
|
2020-01-31 17:02:27 +01:00
|
|
|
conan install .. -pr <your_conan_profile> -s compiler.cppstd=20 -e CONAN_RUN_TESTS=True -b outdated
|
|
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release
|
2019-04-06 23:25:35 +02:00
|
|
|
cmake --build .
|
2020-01-31 17:02:27 +01:00
|
|
|
ctest -VV
|
2019-04-06 23:25:35 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
## Packaging
|
2019-04-06 23:25:35 +02:00
|
|
|
|
|
|
|
To create a `conan` package and test `cmake` installation and `conan` packaging run:
|
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
```shell
|
2020-01-31 17:02:27 +01:00
|
|
|
conan create . <username>/<channel> -pr <your_conan_profile> -s compiler.cppstd=20 -e CONAN_RUN_TESTS=True -b outdated
|
2019-04-06 23:25:35 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
## Upload package to conan server
|
2019-04-06 23:25:35 +02:00
|
|
|
|
2019-10-04 08:29:24 +02:00
|
|
|
```shell
|
2019-12-17 09:14:31 +01:00
|
|
|
conan upload -r <remote-name> --all mp-units/0.5.0@<user>/<channel>
|
2019-04-06 23:25:35 +02:00
|
|
|
```
|