diff --git a/python/templates/Collection.cc.jinja2 b/python/templates/Collection.cc.jinja2 index b7c49cdab..4828750a9 100644 --- a/python/templates/Collection.cc.jinja2 +++ b/python/templates/Collection.cc.jinja2 @@ -13,6 +13,10 @@ {{ include }} {% endfor %} +#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__) +#include "nlohmann/json.hpp" +#endif + // standard includes #include #include diff --git a/python/templates/Collection.h.jinja2 b/python/templates/Collection.h.jinja2 index 0e49aec53..616e1bfc8 100644 --- a/python/templates/Collection.h.jinja2 +++ b/python/templates/Collection.h.jinja2 @@ -19,7 +19,7 @@ #include "podio/CollectionIDTable.h" #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__) -#include "nlohmann/json.hpp" +#include "nlohmann/json_fwd.hpp" #endif #include diff --git a/python/templates/MutableObject.cc.jinja2 b/python/templates/MutableObject.cc.jinja2 index 9ed099278..edbca8da9 100644 --- a/python/templates/MutableObject.cc.jinja2 +++ b/python/templates/MutableObject.cc.jinja2 @@ -8,6 +8,10 @@ {{ include }} {% endfor %} +#ifdef PODIO_JSON_OUTPUT && !defined(__CLING__) +#include "nlohmann/json.hpp" +#endif + #include {{ utils.namespace_open(class.namespace) }} diff --git a/python/templates/MutableObject.h.jinja2 b/python/templates/MutableObject.h.jinja2 index ebdac4f53..b669a2b80 100644 --- a/python/templates/MutableObject.h.jinja2 +++ b/python/templates/MutableObject.h.jinja2 @@ -17,7 +17,7 @@ #include #ifdef PODIO_JSON_OUTPUT -#include "nlohmann/json.hpp" +#include "nlohmann/json_fwd.hpp" #endif {{ utils.forward_decls(forward_declarations) }} diff --git a/python/templates/Object.cc.jinja2 b/python/templates/Object.cc.jinja2 index 0d4b07b7e..37414ec52 100644 --- a/python/templates/Object.cc.jinja2 +++ b/python/templates/Object.cc.jinja2 @@ -8,6 +8,10 @@ {{ include }} {% endfor %} +#ifdef PODIO_JSON_OUTPUT && !defined(__CLING__) +#include "nlohmann/json.hpp" +#endif + #include {{ utils.namespace_open(class.namespace) }} diff --git a/python/templates/Object.h.jinja2 b/python/templates/Object.h.jinja2 index 42d737cb5..bec9fc0da 100644 --- a/python/templates/Object.h.jinja2 +++ b/python/templates/Object.h.jinja2 @@ -14,8 +14,8 @@ #include #include -#ifdef PODIO_JSON_OUTPUT -#include "nlohmann/json.hpp" +#ifdef PODIO_JSON_OUTPUT && !defined(__CLING__) +#include "nlohmann/json_fwd.hpp" #endif {{ utils.forward_decls(forward_declarations) }} diff --git a/python/templates/macros/declarations.jinja2 b/python/templates/macros/declarations.jinja2 index af46f499e..a0c976bc4 100644 --- a/python/templates/macros/declarations.jinja2 +++ b/python/templates/macros/declarations.jinja2 @@ -134,7 +134,7 @@ {%- endmacro %} {% macro json_output(type, prefix='') %} -#ifdef PODIO_JSON_OUTPUT +#ifdef PODIO_JSON_OUTPUT && !defined(__CLING__) void to_json(nlohmann::json& j, const {{ prefix }}{{ type }}& value); #endif {% endmacro %}