Description: search for nlohmann_json path
Author: Joao Eriberto Mota Filho <eriberto@debian.org>
Forwarded: https://github.com/FiniteSingularity/obs-advanced-masks/pull/86
Last-Update: 2025-09-04
Index: obs-advanced-masks/CMakeLists.txt
===================================================================
--- obs-advanced-masks.orig/CMakeLists.txt
+++ obs-advanced-masks/CMakeLists.txt
@@ -73,9 +73,13 @@ if(BUILD_OUT_OF_TREE)
         add_library(nlohmann_json INTERFACE)
         target_include_directories(nlohmann_json INTERFACE "${CMAKE_BINARY_DIR}/json/single_include")
     else()
-        include(FetchContent)
-        FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
-        FetchContent_MakeAvailable(json)
+        # Try to find a system-installed nlohmann_json (Debian: nlohmann-json3-dev)
+        find_package(nlohmann_json QUIET)
+        if(NOT nlohmann_json_FOUND)
+            include(FetchContent)
+            FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
+            FetchContent_MakeAvailable(json)
+        endif()
     endif()
 else()
 	if(OBS_VERSION VERSION_GREATER_EQUAL 30.1.0)
