From 55e99ef0d1f9b292ffb0c75816c8b2480c14a9dd Mon Sep 17 00:00:00 2001 From: sehraf Date: Mon, 16 Jul 2018 23:22:04 +0200 Subject: [PATCH] add auto detection of installed rapidjson --- libretroshare/src/serialiser/rsserializer.h | 4 ++++ libretroshare/src/serialiser/rstypeserializer.cc | 5 ++++- libretroshare/src/serialiser/rstypeserializer.h | 4 ++++ libretroshare/src/use_libretroshare.pri | 10 +++++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/serialiser/rsserializer.h b/libretroshare/src/serialiser/rsserializer.h index 35dc091c3..6bde6930c 100644 --- a/libretroshare/src/serialiser/rsserializer.h +++ b/libretroshare/src/serialiser/rsserializer.h @@ -154,7 +154,11 @@ #include #include #include +#ifdef HAS_RAPIDJSON +#include +#else #include +#endif // HAS_RAPIDJSON #include "retroshare/rsflags.h" #include "serialiser/rsserial.h" diff --git a/libretroshare/src/serialiser/rstypeserializer.cc b/libretroshare/src/serialiser/rstypeserializer.cc index 72d20ecc2..79a3eaab0 100644 --- a/libretroshare/src/serialiser/rstypeserializer.cc +++ b/libretroshare/src/serialiser/rstypeserializer.cc @@ -36,8 +36,11 @@ #include #include // for typeid -#include +#ifdef HAS_RAPIDJSON +#include +#else #include +#endif // HAS_RAPIDJSON //static const uint32_t MAX_SERIALIZED_ARRAY_SIZE = 500 ; static const uint32_t MAX_SERIALIZED_CHUNK_SIZE = 10*1024*1024 ; // 10 MB. diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index 3e3c0b251..e91aa0c45 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -35,7 +35,11 @@ #include "serialiser/rsserializer.h" #include "serialiser/rsserializable.h" +#ifdef HAS_RAPIDJSON +#include +#else #include +#endif // HAS_RAPIDJSON #include // for typeid #include #include diff --git a/libretroshare/src/use_libretroshare.pri b/libretroshare/src/use_libretroshare.pri index 3a3d1acb7..7c5af09b7 100644 --- a/libretroshare/src/use_libretroshare.pri +++ b/libretroshare/src/use_libretroshare.pri @@ -16,7 +16,15 @@ bitdht { # when rapidjson is mainstream on all distribs, we will not need the sources # anymore in the meantime, they are part of the RS directory so that it is # always possible to find them -INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0)) +RAPIDJSON_AVAILABLE = $$system(pkg-config --atleast-version 1.1 RapidJSON && echo yes) +isEmpty(RAPIDJSON_AVAILABLE) { + message("using built-in rapidjson") + INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0)) +} else { + message("using systems rapidjson") + DEFINES *= HAS_RAPIDJSON +} + sLibs = mLibs = $$RS_SQL_LIB ssl crypto $$RS_THREAD_LIB $$RS_UPNP_LIB