summaryrefslogtreecommitdiff
path: root/net-misc/sunshine/files/sunshine-system-json.patch
blob: 62e405e8546ffdf3331da19222fa252307bb5090 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From ec7c960954bba6a3aab03ff74fdbd3bc89948d4c Mon Sep 17 00:00:00 2001
From: James Le Cuirot <chewi@gentoo.org>
Date: Sat, 17 Feb 2024 17:02:45 +0000
Subject: [PATCH] Optionally allow the system installation of nlohmann_json to
 be used

---
 cmake/compile_definitions/common.cmake | 2 +-
 cmake/dependencies/common.cmake        | 8 +++++++-
 cmake/prep/options.cmake               | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake
index 94f1ac5..c65930c 100644
--- a/cmake/compile_definitions/common.cmake
+++ b/cmake/compile_definitions/common.cmake
@@ -135,4 +135,4 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
         ${OPENSSL_LIBRARIES}
         ${CURL_LIBRARIES}
         ${PLATFORM_LIBRARIES}
-        nlohmann_json::nlohmann_json)
+        ${JSON_LIBRARIES})
diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake
index a1f3512..849afe7 100644
--- a/cmake/dependencies/common.cmake
+++ b/cmake/dependencies/common.cmake
@@ -20,7 +20,13 @@ pkg_check_modules(MINIUPNP miniupnpc REQUIRED)
 include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})
 
 # nlohmann_json
-add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json")
+if(NOT SUNSHINE_SYSTEM_NLOHMANN_JSON)
+    add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json")
+    set(JSON_LIBRARIES nlohmann_json::nlohmann_json)
+else()
+    pkg_check_modules(NLOHMANN_JSON nlohmann_json REQUIRED IMPORTED_TARGET)
+    set(JSON_LIBRARIES PkgConfig::NLOHMANN_JSON)
+endif()
 
 # ffmpeg pre-compiled binaries
 if(WIN32)
diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake
index 7a8d728..8a7c2f6 100644
--- a/cmake/prep/options.cmake
+++ b/cmake/prep/options.cmake
@@ -4,6 +4,7 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)
 option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON)
 option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON)
 
+option(SUNSHINE_SYSTEM_NLOHMANN_JSON "Use system installation of nlohmann_json rather than the submodule." OFF)
 option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF)
 
 if(APPLE)
-- 
2.43.0