You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Install CMake build system (at least version 3.0)
37
+
### The simplest case
38
+
In simplest case, if you don't want to understand Jinja2C++ build script internals, you can follow these easy steps. Jinja2C++ library is shipped with all dependencies as a submodules and can use them. So, you have to:
39
+
40
+
1. Install CMake build system (at least version 3.5)
37
41
2. Clone jinja2cpp repository and update submodules:
@@ -47,17 +51,17 @@ In order to compile Jinja2C++ you need:
47
51
4. Run CMake and build the library:
48
52
```
49
53
> cd .build
50
-
> cmake .. -DCMAKE_INSTALL_PREFIX=<path to install folder>
54
+
> cmake .. -DCMAKE_INSTALL_PREFIX=<path to install folder> -DJINJA2_DEPS_MODE=internal
51
55
> cmake --build . --target install
52
56
```
53
-
"Path to install folder" here is a path to the folder where you want to install Jinja2Cpp lib.
54
-
5.Install library:
57
+
"Path to install folder" here is a path to the folder where you want to install Jinja2Cpp lib.`JINJA2_DEPS_MODE` define with `internal` value creates the build script which will take external dependencies from the submodules.
58
+
5.Build library:
55
59
```
56
-
> cmake --build . --target install
60
+
> cmake --build .
57
61
```
58
-
6.Also you can run the tests:
62
+
6.Install library (if necessary):
59
63
```
60
-
> ctest -C Release
64
+
> cmake --build .
61
65
```
62
66
63
67
### Use with conan.io dependency manager
@@ -67,7 +71,7 @@ Jinja2C++ can be used as conan.io package. In this case you should do the follow
67
71
2. Register the following remote conan.io repositories:
The sample command is: `conan remote add martin https://api.bintray.com/conan/martinmoene/nonstd-lite`
73
77
3. Add reference to Jinja2C++ 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:
Different projects require follow different ways for dependencies management. In some cases it's enough to build Jinja2C++ with the internal dependencies only. In other cases it could be necessary that Jinja2C++ use the externally-provided libraries (for instance, boost). To handle this cases Jinja2C++ supports several external dependencies management modes. This modes control via `JINJA2CPP_DEPS_MODE` variable.
109
+
110
+
#### 'internal' mode
111
+
112
+
In this mode Jinja2C++ will take all necessary dependencies (both for library build and tests build) from the submodules. This mode suitable when your project has no other dependencies or these dependencies aren't shared with Jinja2C++ deps. `cmake` invocation for this mode is quite simple:
This mode is default for the upstream (`master`) branch. But for releases branch you need to specify this mode manually.
118
+
119
+
Sample projects for this mode can be found here: [https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal](https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal) and here: [https://github.com/jinja2cpp/examples-build/tree/master/external/internal](https://github.com/jinja2cpp/examples-build/tree/master/external/internal).
120
+
121
+
#### 'external-boost' mode
122
+
123
+
The `boost` library is wildly used (except of other Jinja2C++ dependencies), so it's possible to build Jinja2C++ with only `boost` provided as an external dependencies. In this case Jinja2C++ will take `boost` from the outside of the project tree, but all other dependencies will be taken from the submodules. Jinja2C++ build system tries to find boost with the standard `find_package` approach, so, it's necessary for this mode that path to the `boost` is provided with the standard ways (such as `BOOST_ROOT` environment variable). `cmake` invocation for this mode is also quite simple:
Sample projects for this mode can be found here: [https://github.com/jinja2cpp/examples-build/tree/master/subproject/external_boost](https://github.com/jinja2cpp/examples-build/tree/master/subproject/external_boost) and here: [https://github.com/jinja2cpp/examples-build/tree/master/external/external_boost](https://github.com/jinja2cpp/examples-build/tree/master/external/external_boost).
129
+
130
+
#### 'external'
131
+
132
+
In this mode all Jinja2C++ build system tries to find all necessary dependencies outside the project tree. Path to the projects should be provided via `CMAKE_PREFIX_PATH` variable. This mode is suitable when you want to handle all external libs for your project manually and separately. `cmake` invocation for this mode is also quite simple:
This mode is default for the releases branches in order to make archives with Jinja2C++ sources compilable by default.
137
+
138
+
Sample projects for this mode can be found here: [https://github.com/jinja2cpp/examples-build/tree/master/subproject/external](https://github.com/jinja2cpp/examples-build/tree/master/subproject/external) and here: [https://github.com/jinja2cpp/examples-build/tree/master/external/external](https://github.com/jinja2cpp/examples-build/tree/master/external/external).
139
+
102
140
### Additional CMake build flags
103
141
You can define (via -D command line CMake option) the following build flags:
104
142
105
143
-**JINJA2CPP_BUILD_TESTS** (default TRUE) - to build or not to Jinja2C++ tests.
-**JINJA2CPP_BUILD_SHARED** (default OFF) - Specify Jinja2C++ library library link type.
108
145
-**MSVC_RUNTIME_TYPE** (default /MD) - MSVC runtime type to link with (if you use Microsoft Visual Studio compiler).
109
-
-**JINJA2CPP_DEPS_MODE** (default "internal") - modes for dependencies handling. Following values possible:
110
-
-`internal` In this mode Jinja2C++ build script uses dependencies (include `boost`) shipped as subprojects. Nothing needs to be provided externally.
111
-
-`external-boost` In this mode Jinja2C++ build script uses only `boost` as externally-provided dependency. All other dependencies taken from subprojects.
112
-
-`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)
113
-
-`conan-build` Special mode for building Jinja2C++ via conan recipe.
114
-
115
-
## Dependency management modes
116
-
TODO:
117
146
118
147
## Link with you projects
119
-
Jinja2C++ is shipped with cmake finder scripts. So you can:
120
-
121
-
1. Include Jinja2C++ cmake scripts to the project:
148
+
Jinja2C++ is a CMake project and follow the standard ways of the CMake project `find` script implementation. So, you can either include Jinja2C++ as a subproject of your project. In this case you should link against `jinja2cpp` target. All necessary settings are already associated with this target. For instance:
122
149
```cmake
123
-
list (APPEND CMAKE_MODULE_PATH ${JINJA2CPP_INSTALL_DIR}/lib/jinja2cpp)
Sample project for this build type you can find here: [https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal](https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal)
168
+
169
+
Or you can build Jinja2C++ library separately, install it and the find it via `find_package` cmake function. In this case:
170
+
1. You should build Jinja2C++ with `CMAKE_INSTALL_PREFIX` variable defined and then install it:
set (CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/.jinja2cpp-install)
186
+
187
+
find_package(jinja2cpp REQUIRED)
188
+
189
+
add_executable (${TARGET_NAME} main.cpp)
190
+
191
+
target_link_libraries (${TARGET_NAME} jinja2cpp)
192
+
set_target_properties (${TARGET_NAME} PROPERTIES
193
+
CXX_STANDARD 14
194
+
CXX_STANDARD_REQUIRED ON)
151
195
```
152
196
197
+
153
198
## Build with C++17 standard enabled
154
199
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.
0 commit comments