From f16d619d308eb79fa542131c0fc01be18dd15bf8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 10 Apr 2019 17:20:32 +0100 Subject: [PATCH] Documentation updated --- README.md | 13 +++++++-- doc/DESIGN.md | 15 +++++++--- doc/INSTALL.md | 75 ++++++++++++++++++++++---------------------------- 3 files changed, 54 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 8a9bfeb9..fac5b6d8 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,21 @@ analysis and unit/quantity manipulation. The basic idea and design heavily bases Here is a small example of possible operations: ```cpp -static_assert(1000 / 1_s == 1_kHz); +// simple numeric operations +static_assert(10_km / 2 == 5_km); + +// unit conversions static_assert(1_h == 3600_s); static_assert(1_km + 1_m == 1001_m); -static_assert(10_km / 5_km == 2); -static_assert(10_km / 2 == 5_km); + +// dimension conversions static_assert(1_km / 1_s == 1000_mps); static_assert(2_kmph * 2_h == 4_km); static_assert(2_km / 2_kmph == 1_h); + +static_assert(1000 / 1_s == 1_kHz); + +static_assert(10_km / 5_km == 2); ``` diff --git a/doc/DESIGN.md b/doc/DESIGN.md index a016d618..3330fe6d 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -9,14 +9,21 @@ analysis and unit/quantity manipulation. The basic idea and design heavily bases Here is a small example of possible operations: ```cpp -static_assert(1000 / 1_s == 1_kHz); +// simple numeric operations +static_assert(10_km / 2 == 5_km); + +// unit conversions static_assert(1_h == 3600_s); static_assert(1_km + 1_m == 1001_m); -static_assert(10_km / 5_km == 2); -static_assert(10_km / 2 == 5_km); + +// dimension conversions static_assert(1_km / 1_s == 1000_mps); static_assert(2_kmph * 2_h == 4_km); static_assert(2_km / 2_kmph == 1_h); + +static_assert(1000 / 1_s == 1_kHz); + +static_assert(10_km / 5_km == 2); ``` @@ -399,7 +406,7 @@ concept Velocity = Quantity && Same(l); } constexpr auto operator""_mps(long double l) { return velocity(l); } } diff --git a/doc/INSTALL.md b/doc/INSTALL.md index beb72808..8d937506 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -1,6 +1,8 @@ # Installation and Reuse -There are a few different ways of installing/reusing `units` in your project +There are a few different ways of installing/reusing `units` in your project. + +NOTE: This library as of now compiles correctly only with gcc-8. ## Copy @@ -17,54 +19,43 @@ requires = ( ) ``` -## cmake +## cmake + conan To use `units` as a `cmake` imported library via `cmake` configuration files the following -steps may be done. - -### cmake install - -```bash -$ mkdir build && cd build -$ cmake ../src -DCMAKE_INSTALL_PREFIX= -$ cmake --build . --target install -``` - -To use such `cmake` target in your project it is enough to add following line to your -`CMakeList.txt` file - -```cmake -find_package(units CONFIG REQUIRED) -``` - -and configure it with - -```bash -$ cmake .. -DCMAKE_INSTALL_PREFIX= -``` - -### cmake + conan - -To use `units` with `cmake` via `conan` it is enough to: +steps may be done: - add the following remotes to your local `conan` instance -```bash -$ conan remote add conan-mpusz https://bintray.com/mpusz/conan-mpusz -$ conan remote add conan-nonstd https://api.bintray.com/conan/martinmoene/nonstd-lite -``` + ```bash + $ conan remote add conan-mpusz https://bintray.com/mpusz/conan-mpusz + $ conan remote add conan-nonstd https://api.bintray.com/conan/martinmoene/nonstd-lite + ``` -- add the following dependency to your `conanfile.txt` or `conanfile.py` files +- add `units` as a dependency to your `conan` file + - `conanfile.txt` + + ```text + [requires] + mp-units/0.0.1@mpusz/testing + ``` + + - `conanfile.py` -```python -requires = "mp-units/0.0.1@mpusz/testing" -``` + ```python + requires = "mp-units/0.0.1@mpusz/testing" + ``` + +- link your `cmake` target with units + + ```text + target_link_libraries( PUBLIC|PRIVATE|INTERFACE CONAN_PKG::mp-units) + ``` - install conan dependencies before configuring cmake -```bash -$ cd build -$ conan install .. -pr -b=outdated -u -``` + ```bash + $ cd build + $ conan install .. -pr -s cppstd=20 -b=outdated -u + ``` # Full build and unit testing @@ -74,7 +65,7 @@ you should use `CMakeLists.txt` from the parent directory. ```bash mkdir build && cd build -conan install .. +conan install .. -s cppstd=20 cmake .. cmake --build . ``` @@ -85,7 +76,7 @@ cmake --build . To create a `conan` package and test `cmake` installation and `conan` packaging run: ```bash -$ conan create . / --build=outdated +$ conan create . / -s cppstd=20 -b=outdated ```