From 7f7b202df99c0f2fe0237a1b97a65e3c83ea0fa6 Mon Sep 17 00:00:00 2001
From: Syping <schiedelrafael@keppe.org>
Date: Sun, 9 Apr 2023 21:45:58 +0200
Subject: [PATCH] add WITH_BOOST option to build with linked Boost

---
 CMakeLists.txt        | 25 +++++++++++++++++++++++--
 src/SnapmaticJson.cpp |  4 +++-
 src/libragephoto      |  2 +-
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d9651a..63160ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,6 @@ if(APPLE)
 endif()
 
 list(APPEND GTA5VIEW_DEFINES
-    -DBOOST_JSON_STANDALONE
     -DGTA5SYNC_CMAKE
     -DGTA5SYNC_PROJECT
 )
@@ -140,7 +139,6 @@ set(GTA5VIEW_HEADERS
 set(GTA5VIEW_INCLUDEDIR
     src
     src/anpro
-    src/json/include
     src/pcg
     src/uimod
 )
@@ -231,6 +229,29 @@ if(RAGEPHOTO_ABI_WRAPPER)
     )
 endif()
 
+option(WITH_BOOST "Use linked Boost library" OFF)
+if(WITH_BOOST)
+    find_package(Boost REQUIRED
+        COMPONENTS json
+    )
+    list(APPEND GTA5VIEW_LIBS
+        Boost::json
+    )
+    list(APPEND GTA5VIEW_DEFINES
+        -DGTA5SYNC_BOOST
+    )
+    list(APPEND GTA5VIEW_INCLUDEDIR
+        ${Boost_INCLUDE_DIRS}
+    )
+else()
+    list(APPEND GTA5VIEW_DEFINES
+        -DBOOST_JSON_STANDALONE
+    )
+    list(APPEND GTA5VIEW_INCLUDEDIR
+        src/json/include
+    )
+endif()
+
 option(WITH_DONATE "Donate menu option and donation dialog" OFF)
 if(WITH_DONATE)
     set(DONATE_ADDRESSES "" CACHE STRING "Donation addresses")
diff --git a/src/SnapmaticJson.cpp b/src/SnapmaticJson.cpp
index cff9fff..ff04511 100644
--- a/src/SnapmaticJson.cpp
+++ b/src/SnapmaticJson.cpp
@@ -16,9 +16,11 @@
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *****************************************************************************/
 
+#ifndef GTA5SYNC_BOOST
 #include <boost/json/src.hpp>
-#include <sstream>
+#endif
 #include "SnapmaticJson.h"
+#include <sstream>
 
 void serializer(std::ostream &os, const boost::json::value &jv, std::string *indent, bool do_indent)
 {
diff --git a/src/libragephoto b/src/libragephoto
index 9339184..d8c0d7d 160000
--- a/src/libragephoto
+++ b/src/libragephoto
@@ -1 +1 @@
-Subproject commit 933918454f16af118a3cb9e1359a00bca589d7e7
+Subproject commit d8c0d7d47031c670443722db13e3c67c9c7f33a9