From ec7c960954bba6a3aab03ff74fdbd3bc89948d4c Mon Sep 17 00:00:00 2001 From: James Le Cuirot 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