Build and install

Table of contents

  1. Supported compilers
  2. Dependencies
  3. Build and install
    1. Use with dependency manager
    2. Additional CMake build flags
  4. Dependency management modes
  5. Link with you projects
  6. Build with C++17 standard enabled

Supported compilers

Compilation of Jinja2C++ tested on the following compilers (with C++14 enabled feature):

  • Linux gcc 5.0
  • Linux gcc 6.0
  • Linux gcc 7.0
  • Linux clang 5.0
  • Microsoft Visual Studio 2015 x86, x64
  • Microsoft Visual Studio 2017 x86, x64


Jinja2C++ has several external dependencies:

Build and install

In order to compile Jinja2C++ you need:

  1. Install CMake build system (at least version 3.0)
  2. Clone jinja2cpp repository and update submodules:
    > git clone
    > cd Jinja2Cpp
    > git submodule -q update --init
  3. Create build directory:
    > mkdir .build
  4. Run CMake and build the library:
    > cd .build
    > cmake .. -DCMAKE_INSTALL_PREFIX=<path to install folder>
    > cmake --build . --target install

    “Path to install folder” here is a path to the folder where you want to install Jinja2Cpp lib.

  5. Install library:
    > cmake --build . --target install
  6. Also you can run the tests:
    > ctest -C Release

Use with dependency manager

Jinja2C++ can be used as package. In this case you should do the following steps:

  1. Install according to the documentation ( )
  2. Register the following remote repositories:

    The sample command is: conan remote add martin

  3. Add reference to Jinja2C++ package (jinja2cpp/0.9.1@Manu343726/testing) to your conanfile.txt, or CMakeLists.txt. For instance, with usage of conan-cmake integration it could be written this way:
include (../../cmake/conan.cmake)
    set (CONAN_SETTINGS SETTINGS compiler.libcxx=libstdc++11)
endif ()

                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

Additional CMake build flags

You can define (via -D command line CMake option) the following build flags:

  • JINJA2CPP_BUILD_TESTS (default TRUE) - to build or not to Jinja2C++ tests.
  • JINJA2CPP_STRICT_WARNINGS (default TRUE) - Enable strict mode compile-warnings(-Wall -Werror and etc).
  • JINJA2CPP_BUILD_SHARED (default OFF) - Specify Jinja2C++ library library link type.
  • MSVC_RUNTIME_TYPE (default /MD) - MSVC runtime type to link with (if you use Microsoft Visual Studio compiler).
  • JINJA2CPP_DEPS_MODE (default “internal”) - modes for dependencies handling. Following values possible:
    • internal In this mode Jinja2C++ build script uses dependencies (include boost) shipped as subprojects. Nothing needs to be provided externally.
    • external-boost In this mode Jinja2C++ build script uses only boost as externally-provided dependency. All other dependencies taken from subprojects.
    • 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)
    • conan-build Special mode for building Jinja2C++ via conan recipe.

Dependency management modes


Jinja2C++ is shipped with cmake finder scripts. So you can:

  1. Include Jinja2C++ cmake scripts to the project:
  2. Use regular ‘find’ script:
  3. Add found paths to the project settings: ```cmake #… include_directories( #… ${JINJA2CPP_INCLUDE_DIR} )

target_link_libraries(YourTarget #… ${JINJA2CPP_LIBRARY} ) #…

or just link with Jinja2Cpp target:

Build with C++17 standard enabled

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.