|
1 | | -Building Library |
| 1 | +Build Library |
2 | 2 | ========================== |
3 | 3 |
|
4 | | -The library can be built locally using Cmake_ (`Cmake Installation`_), and several cache variables can be set: |
| 4 | +The library can be built locally using Cmake_ (`Cmake Installation`_) |
| 5 | + |
| 6 | +Create a build directory and navigate to it: |
| 7 | + |
| 8 | +.. code-block:: sh |
| 9 | +
|
| 10 | + mkdir build && cd build |
| 11 | +
|
| 12 | +Configure CMake project |
| 13 | + |
| 14 | +.. code-block:: sh |
| 15 | +
|
| 16 | + cmake .. -DCMAKE_BUILD_TYPE=Debug |
| 17 | +
|
| 18 | +Using this command several cache variables can be set: |
5 | 19 |
|
6 | 20 | * <variable cache name>: [possible values] (default value) - Description |
7 | 21 | * LIBRARY_TYPE: ["Shared", "Static", "HeaderOnly"] ("HeaderOnly") - Library build type |
8 | 22 | * BUILD_DOCS: [true, false] (false) - Turn on to build documentation (requires Sphinx_, Breathe_ and Doxygen_ installed) |
9 | | -* BUILD_TESTS: [true, false] (false) - Turn on to build tests (requires Gtest_ to be installed, see `Conan Packages Installation`_) |
| 23 | +* BUILD_TESTS: [true, false] (false) - Turn on to build tests (requires Gtest_ to be installed, see `Build Library With Conan`_) |
10 | 24 | * BUILD_EXAMPLES: [true, false] (false) - Turn on to build examples |
11 | 25 |
|
12 | | -build the library using the command: |
| 26 | +to set cache variable pass additional option: -D<variable cache name>=[value] |
| 27 | +for example, this command will set the library type to Static and will force examples built |
13 | 28 |
|
14 | 29 | .. code-block:: sh |
15 | 30 |
|
16 | | - cmake --build ./build |
| 31 | + cmake .. -DCMAKE_BUILD_TYPE=Release -DLIBRARY_TYPE=Static -DBUILD_EXAMPLES=true |
| 32 | +
|
| 33 | +Build the library using the command: |
| 34 | + |
| 35 | +.. code-block:: sh |
17 | 36 |
|
| 37 | + cmake --build . |
18 | 38 |
|
19 | | -Conan Packages Installation |
| 39 | +
|
| 40 | +Build Library With Conan |
20 | 41 | ^^^^^^^^^^^^^^^ |
21 | 42 |
|
22 | 43 | Gtest_ library is added to project using Conan_ package manager (`Conan Installation`_), |
23 | | -to install Conan packages run this command in the library root folder: |
| 44 | +If Conan was freshly installed run detect command: |
| 45 | + |
| 46 | +.. code-block:: sh |
| 47 | +
|
| 48 | + conan profile detect |
| 49 | +
|
| 50 | +To install Conan packages run this command in the library root folder: |
24 | 51 |
|
25 | 52 | .. code-block:: sh |
26 | 53 |
|
27 | 54 | conan install . --output-folder=build --build=missing |
28 | 55 |
|
| 56 | +Navigate to the build directory: |
| 57 | + |
| 58 | +.. code-block:: sh |
| 59 | +
|
| 60 | + cd build |
| 61 | +
|
| 62 | +Configure the CMake project, and add also toolchain file as a CMAKE_TOOLCHAIN_FILE cache variable: |
| 63 | + |
| 64 | +.. code-block:: sh |
| 65 | +
|
| 66 | + cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=true -DCMAKE_TOOLCHAIN_FILE:STRING="conan_toolchain.cmake" |
| 67 | +
|
| 68 | +Build the library using the command: |
| 69 | + |
| 70 | +.. code-block:: sh |
| 71 | +
|
| 72 | + cmake --build . |
| 73 | +
|
29 | 74 | .. _Cmake: https://cmake.org/ |
30 | 75 | .. _`Cmake Installation`: https://cmake.org/download/ |
31 | 76 | .. _Sphinx: https://www.sphinx-doc.org/en/master/ |
|
0 commit comments