Skip to content

Commit 0e0c714

Browse files
whwjiangbbockelm
authored andcommitted
fix unit test issue
1 parent 70729db commit 0e0c714

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,22 @@ find_package( Filesystem REQUIRED )
4444
# Similar setup for libatomic; required only on 32-bit systems
4545
find_package( Atomic REQUIRED )
4646

47-
# Add nlohmann/json dependency
48-
find_package(nlohmann_json 3.11.2 REQUIRED)
47+
# Add nlohmann/json dependency (use system if available; otherwise, fetch it)
48+
find_package(nlohmann_json 3.11.2 QUIET)
49+
if(NOT nlohmann_json_FOUND)
50+
include(FetchContent)
51+
# Allow a locally-found tarball; if missing, fall back to upstream URL
52+
set(JSON_URL "${CMAKE_CURRENT_SOURCE_DIR}/nlohmann-json-3.11.2.tar.xz")
53+
if(NOT EXISTS "${JSON_URL}")
54+
set(JSON_URL "https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz")
55+
endif()
56+
cmake_policy(SET CMP0135 NEW)
57+
FetchContent_Declare(
58+
nlohmann_json
59+
URL "${JSON_URL}"
60+
)
61+
FetchContent_MakeAvailable(nlohmann_json)
62+
endif()
4963

5064
if( NOT XROOTD_EXTERNAL_TINYXML2 )
5165
include(FetchContent)

0 commit comments

Comments
 (0)