summaryrefslogtreecommitdiff
path: root/disable-json-download.patch
blob: 9f6084d35bfd3bf0dbb67bcb735f7d154f5c1759 (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
--- CMake/external_json.cmake.orig	2026-04-06 14:26:00.677001990 +0800
+++ CMake/external_json.cmake	2026-04-06 14:26:00.677001990 +0800
@@ -1,49 +1,10 @@
 cmake_minimum_required(VERSION 3.10)
 include(ExternalProject)
 
-
-
 # We use a function to enforce a scoped variables creation only for the build
 # (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
 function(get_nlohmann_json)
-
-    message( STATUS #CHECK_START
-        "Fetching nlohmann/json..." )
-    #list( APPEND CMAKE_MESSAGE_INDENT "  " )  # Indent outputs
-
-    # We want to clone the json repo and build it here, during configuration, so we can use it.
-    # But ExternalProject_add is limited in that it only does its magic during build.
-    # This is possible in CMake 3.12+ with FetchContent and FetchContent_MakeAvailable in 3.14+ (meaning Ubuntu 20)
-    # but we need to adhere to CMake 3.10 (Ubuntu 18).
-    # So instead, we invoke a new CMake project just to download pybind:
-    configure_file( CMake/json-download.cmake.in
-                    ${CMAKE_BINARY_DIR}/external-projects/json-download/CMakeLists.txt )
-    execute_process( COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . "--no-warn-unused-cli"
-                     -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-                     -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-                     -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-                     WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/json-download"
-                     OUTPUT_QUIET
-                     RESULT_VARIABLE configure_ret )
-    execute_process( COMMAND "${CMAKE_COMMAND}" --build .
-                     WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/json-download"
-                     OUTPUT_QUIET
-                     RESULT_VARIABLE build_ret )
-
-    if( configure_ret OR build_ret )
-        message( FATAL_ERROR "Failed to download nlohmann/json" )
-    endif()
-
-    add_subdirectory( "${CMAKE_BINARY_DIR}/third-party/json"
-                      "${CMAKE_BINARY_DIR}/third-party/json/build" )
-
-    # We cannot directly interface with nlohmann_json (doesn't work on bionic)
-    #install( TARGETS nlohmann_json EXPORT realsense2Targets )
-
-    message( STATUS #CHECK_PASS
-        "Fetching nlohmann/json - Done" )
-    #list( POP_BACK CMAKE_MESSAGE_INDENT ) # Unindent outputs (requires cmake 3.15)
-
+    find_package(nlohmann_json REQUIRED)
 endfunction()
 
 # Trigger the build