Compilation of Jinja2C++ tested on the following compilers (with C++14 enabled feature):
Jinja2C++ has several external dependencies:
boost
library (at least version 1.65)nonstd::expected-lite
https://github.com/martinmoene/expected-litenonstd::variant-lite
https://github.com/martinmoene/variant-litenonstd::optional-lite
https://github.com/martinmoene/optional-litenonstd::string-view-lite
https://github.com/martinmoene/string-view-litefmtlib::fmt
https://github.com/fmtlib/fmtrapidjson
https://github.com/Tencent/rapidjsonFor testing purposes:
nlohmannjson
https://github.com/nlohmann/jsonIn 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:
> git clone https://github.com/jinja2cpp/Jinja2Cpp.git
> cd Jinja2Cpp
> git submodule -q update --init
> cd .build
> cmake .. -DCMAKE_INSTALL_PREFIX=<path to install folder> -DJINJA2CPP_DEPS_MODE=internal
> cmake --build . --target install
“Path to install folder” here is a path to the folder where you want to install Jinja2Cpp lib. DJINJA2CPP_DEPS_MODE
define with internal
value creates the build script which will take external dependencies from the submodules.
Jinja2C++ can be used as conan.io package. In this case you should do the following steps:
jinja2cpp/1.2.1
) to your conanfile.txt, conanfile.py or CMakeLists.txt. For instance, with usage of conan-cmake
integration it could be written this way:include (../../cmake/conan.cmake)
if (NOT MSVC)
set (CONAN_SETTINGS SETTINGS compiler.libcxx=libstdc++11)
endif ()
conan_cmake_run(REQUIRES
jinja2cpp/1.1.0
gtest/1.7.0@bincrafters/stable
BASIC_SETUP
${CONAN_SETTINGS}
OPTIONS
jinja2cpp:shared=False
gtest:shared=False
BUILD missing)
set (TARGET_NAME jinja2cpp_build_test)
add_executable (${TARGET_NAME} main.cpp)
target_link_libraries (${TARGET_NAME} ${CONAN_LIBS})
set_target_properties (${TARGET_NAME} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
Dependency management
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.
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:
> cmake <path_to_jinja2cpp_root> -DCMAKE_BUILD_TYPE=Release -DJINJA2CPP_DEPS_MODE=internal
This mode is default for the upstream (master
) branch. But for releases branch you need to specify this mode manually.
Sample projects for this mode can be found here: https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal and here: https://github.com/jinja2cpp/examples-build/tree/master/external/internal.
‘external-boost’ modeThe 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:
> cmake <path_to_jinja2cpp_root> -DCMAKE_BUILD_TYPE=Release -DJINJA2CPP_DEPS_MODE=external-boost
Sample projects for this mode can be found here: https://github.com/jinja2cpp/examples-build/tree/master/subproject/external_boost and here: https://github.com/jinja2cpp/examples-build/tree/master/external/external_boost.
‘external’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:
cmake <path_to_jinja2cpp_root> -DCMAKE_BUILD_TYPE=Release -DJINJA2CPP_BUILD_TESTS=OFF -DJINJA2CPP_DEPS_MODE=external -DCMAKE_PREFIX_PATH="thirdparty/expected-lite;thirdparty/variant-lite;thirdparty/optional-lite;thirdparty/string-view-lite;thirdparty/fmt
This mode is default for the releases branches in order to make archives with Jinja2C++ sources compilable by default.
Sample projects for this mode can be found here: https://github.com/jinja2cpp/examples-build/tree/master/subproject/external and here: https://github.com/jinja2cpp/examples-build/tree/master/external/external.
Additional CMake build flagsYou can define (via -D command line CMake option) the following build flags:
d
suffix which means Debug
version of runtime. Suffix is added automatically.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:
cmake_minimum_required (VERSION 3.0.0 FATAL_ERROR)
project (Jinja2CppBuildTest CXX)
set (TARGET_NAME jinja2cpp_build_test)
set (JINJA2CPP_DEPS_MODE internal CACHE STRING "" FORCE)
add_subdirectory (${JINJA2CPP_DIR} ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jinja2cpp)
add_executable (${TARGET_NAME} main.cpp)
target_link_libraries (${TARGET_NAME} jinja2cpp)
set_target_properties (${TARGET_NAME} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
Sample project for this build type you can find here: https://github.com/jinja2cpp/examples-build/tree/master/subproject/internal
Or you can build Jinja2C++ library separately, install it and the find it via find_package
cmake function. In this case:
CMAKE_INSTALL_PREFIX
variable defined and then install it: shell script cmake thirdparty/Jinja2Cpp -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../.jinja2cpp-install -DJINJA2CPP_BUILD_TESTS=OFF cmake --build . --target install
cmake
invocation of your project: shell script cmake .. -DCMAKE_BUILD_TYPE=Release -Djinja2cpp_DIR=../.jinja2cpp-install/lib/jinja2cpp
find_package
invocation:cmake_minimum_required (VERSION 3.0.0 FATAL_ERROR)
project (Jinja2CppBuildTest CXX)
set (TARGET_NAME jinja2cpp_build_test)
set (CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/.jinja2cpp-install)
find_package(jinja2cpp REQUIRED)
add_executable (${TARGET_NAME} main.cpp)
target_link_libraries (${TARGET_NAME} jinja2cpp)
set_target_properties (${TARGET_NAME} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4