8000 Update build_and_install.md · jinja2cpp/jinja2cpp.github.io@0c1917a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c1917a

Browse files
authored
Update build_and_install.md
1 parent 3ec0727 commit 0c1917a

File tree

1 file changed

+74
-27
lines changed

1 file changed

+74
-27
lines changed

docs/build_and_install.md

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,126 @@ title: Build and Install
44
nav_order: 4
55
---
66

7+
# Build and install
8+
{: .no_toc }
9+
10+
## Table of contents
11+
{: .no_toc .text-delta }
12+
13+
1. TOC
14+
{:toc}
715

8-
# Supported compilers
9-
Compilation of Jinja2Cpp tested on the following compilers (with C++14 enabled feature):
16+
## Supported compilers
17+
Compilation of Jinja2C++ tested on the following compilers (with C++14 enabled feature):
1018
- Linux gcc 5.0
1119
- Linux gcc 6.0
1220
- Linux gcc 7.0
1321
- Linux clang 5.0
1422
- Microsoft Visual Studio 2015 x86, x64
1523
- Microsoft Visual Studio 2017 x86, x64
1624

17-
# Build and install
18-
Jinja2Cpp has five external dependencies: boost library (at least version 1.55) and several header-only dependecies from nonstd project(expected-lite, variant-lite, value-ptr-lite, optional-lite). Because of types from boost are used inside library, you should compile both your projects and Jinja2Cpp library with similar compiler settings. Otherwise ABI could be broken.
25+
## Dependencies
26+
Jinja2C++ has several external dependencies:
27+
- `boost` library (at least version 1.55)
28+
- `nonstd::expected-lite` [https://github.com/martinmoene/expected-lite](https://github.com/martinmoene/expected-lite)
29+
- `nonstd::variant-lite` [https://github.com/martinmoene/variant-lite](https://github.com/martinmoene/variant-lite)
30+
- `nonstd::value-ptr-lite` [https://github.com/martinmoene/value-ptr-lite](https://github.com/martinmoene/value-ptr-lite)
31+
- `nonstd::optional-lite` [https://github.com/martinmoene/optional-lite](https://github.com/martinmoene/optional-lite)
1932

20-
In order to compile Jinja2Cpp you need:
33+
## Build and install
34+
In order to compile Jinja2C++ you need:
2135

2236
1. Install CMake build system (at least version 3.0)
2337
2. Clone jinja2cpp repository and update submodules:
24-
2538
```
2639
> git clone https://github.com/flexferrum/Jinja2Cpp.git
2740
> git submodule -q update --init
2841
```
29-
3042
3. Create build directory:
31-
3243
```
3344
> cd Jinja2Cpp
3445
> mkdir build
3546
```
36-
3747
4. Run CMake and build the library:
38-
3948
```
4049
> cd build
4150
> cmake .. -DCMAKE_INSTALL_PREFIX=<path to install folder>
4251
> cmake --build . --target all
4352
```
4453
"Path to install folder" here is a path to the folder where you want to install Jinja2Cpp lib.
45-
4654
5. Install library:
47-
4855
```
4956
> cmake --build . --target install
5057
```
51-
5258
6. Also you can run the tests:
53-
5459
```
5560
> ctest -C Release
5661
```
5762

58-
## Additional CMake build flags
59-
You can define (via -D command line CMake option) the following build flags:
63+
### Use with conan.io dependency manager
64+
Jinja2Cpp can be used as conan.io package. In this case you should do the following steps:
65+
66+
1. Install conan.io according to the documentation ( https://docs.conan.io/en/latest/installation.html )
67+
2. Register the following remote conan.io repositories:
68+
- https://api.bintray.com/conan/martinmoene/nonstd-lite
69+
- https://api.bintray.com/conan/bincrafters/public-conan
70+
- https://api.bintray.com/conan/manu343726/conan-packages
71+
The sample command is: `conan remote add martin https://api.bintray.com/conan/martinmoene/nonstd-lite`
72+
3. Add reference to Jinja2Cpp package (`jinja2cpp/0.9.1@Manu343726/testing`) to your conanfile.txt, conanfile.py or CMakeLists.txt. For instance, with usage of `conan-cmake` integration it could be written this way:
73+
```cmake
74+
include (../../cmake/conan.cmake)
75+
if (NOT MSVC)
76+
set (CONAN_SETTINGS SETTINGS compiler.libcxx=libstdc++11)
77+
endif ()
78+
79+
conan_cmake_run(REQUIRES
80+
jinja2cpp/0.9.1@Manu343726/testing
81+
gtest/1.7.0@bincrafters/stable
82+
BASIC_SETUP
83+
${CONAN_SETTINGS}
84+
OPTIONS
85+
jinja2cpp:shared=False
86+
gtest:shared=False
87+
BUILD missing)
88+
89+
set (TARGET_NAME jinja2cpp_build_test)
90+
91+
add_executable (${TARGET_NAME} main.cpp)
92+
93+
target_link_libraries (${TARGET_NAME} ${CONAN_LIBS})
94+
set_target_properties (${TARGET_NAME} PROPERTIES
95+
CXX_STANDARD 14
96+
CXX_STANDARD_REQUIRED ON)
6097
61-
* **JINJA2CPP_BUILD_TESTS** (default TRUE) - to build or not to Jinja2Cpp tests.
62-
* **JINJA2CPP_STRICT_WARNINGS** (default TRUE) - Enable strict mode compile-warnings(-Wall -Werror and etc).
63-
* **JINJA2CPP_BUILD_SHARED** (default OFF) - Specify Jinja2Cpp library library link type.
64-
* **MSVC_RUNTIME_TYPE** (default /MD) - MSVC runtime type to link with (if you use Microsoft Visual Studio compiler).
65-
* **BOOST_ROOT** - Path to the prebuilt boost installation
98+
```
6699

67-
# Link with you projects
100+
### Additional CMake build flags
101+
You can define (via -D command line CMake option) the following build flags:
102+
103+
- **JINJA2CPP_BUILD_TESTS** (default TRUE) - to build or not to Jinja2Cpp tests.
104+
- **JINJA2CPP_STRICT_WARNINGS** (default TRUE) - Enable strict mode compile-warnings(-Wall -Werror and etc).
105+
- **JINJA2CPP_BUILD_SHARED** (default OFF) - Specify Jinja2Cpp library library link type.
106+
- **MSVC_RUNTIME_TYPE** (default /MD) - MSVC runtime type to link with (if you use Microsoft Visual Studio compiler).
107+
- **JINJA2CPP_DEPS_MODE** (default "internal") - modes for dependencies handling. Following values possible:
108+
- `internal` In this mode Jinja2Cpp build script uses dependencies (include `boost`) shipped as subprojects. Nothing needs to be provided externally.
109+
- `external-boost` In this mode Jinja2Cpp build script uses only `boost` as externally-provided dependency. All other dependencies taken from subprojects.
110+
- `external` In this mode all dependencies should be provided externally. Paths to `boost`, `nonstd-*` libs etc. should be specified via standard CMake variables (like `CMAKE_PREFIX_PATH` or libname_DIR)
111+
- `conan-build` Special mode for building Jinja2Cpp via conan recipe.
112+
113+
## Dependency management modes
114+
TODO:
115+
116+
## Link with you projects
68117
Jinja2Cpp is shipped with cmake finder script. So you can:
69118

70119
1. Include Jinja2Cpp cmake scripts to the project:
71120
```cmake
72121
list (APPEND CMAKE_MODULE_PATH ${JINJA2CPP_INSTALL_DIR}/cmake)
73122
```
74-
75123
2. Use regular 'find' script:
76124
```cmake
77-
find_package(Jinja2Cpp)
125+
find_package(jinja2cpp)
78126
```
79-
80127
3. Add found paths to the project settings:
81128
```cmake
82129
#...
@@ -91,7 +138,6 @@ target_link_libraries(YourTarget
91138
)
92139
#...
93140
```
94-
95141
or just link with Jinja2Cpp target:
96142
```cmake
97143
#...
@@ -101,6 +147,7 @@ target_link_libraries(YourTarget
101147
)
102148
#...
103149
```
104-
4. Build with C++17 standard enabled
150+
151+
## Build with C++17 standard enabled
105152
In case of C++17 standard enabled for your project you should define `variant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD` macro in the build settings.
106153

0 commit comments

Comments
 (0)
0