-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathjson.cmake
More file actions
74 lines (69 loc) · 3.23 KB
/
json.cmake
File metadata and controls
74 lines (69 loc) · 3.23 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function(find_json)
if(TARGET nlohmann_json::nlohmann_json)
message(STATUS "nlohmann_json::nlohmann_json target already imported")
elseif(openPMD_USE_INTERNAL_JSON)
if(openPMD_json_src)
message(STATUS "Compiling local nlohmann_json ...")
message(STATUS "nlohmann_json source path: ${openPMD_json_src}")
if(NOT IS_DIRECTORY ${openPMD_json_src})
message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!")
endif()
elseif(openPMD_json_tar)
message(STATUS "Downloading nlohmann_json ...")
message(STATUS "nlohmann_json source: ${openPMD_json_tar}")
elseif(openPMD_json_branch)
message(STATUS "Downloading nlohmann_json ...")
message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})")
endif()
endif()
if(TARGET nlohmann_json::nlohmann_json)
# nothing to do, target already exists in the superbuild
elseif(openPMD_USE_INTERNAL_JSON AND openPMD_json_src)
add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/)
elseif(openPMD_USE_INTERNAL_JSON AND (openPMD_json_tar OR openPMD_json_branch))
include(FetchContent)
if(openPMD_json_tar)
FetchContent_Declare(fetchednlohmann_json
URL ${openPMD_json_tar}
URL_HASH ${openPMD_json_tar_hash}
BUILD_IN_SOURCE OFF
)
else()
FetchContent_Declare(fetchednlohmann_json
GIT_REPOSITORY ${openPMD_json_repo}
GIT_TAG ${openPMD_json_branch}
BUILD_IN_SOURCE OFF
)
endif()
FetchContent_MakeAvailable(fetchednlohmann_json)
# advanced fetch options
mark_as_advanced(FETCHCONTENT_BASE_DIR)
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_QUIET)
#mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDnlohmann_json)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
#mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDnlohmann_json)
elseif(NOT openPMD_USE_INTERNAL_JSON)
find_package(nlohmann_json 3.9.1 CONFIG REQUIRED)
message(STATUS "nlohmann_json: Found version '${nlohmann_json_VERSION}'")
endif()
endfunction()
# local source-tree
set(openPMD_json_src ""
CACHE PATH
"Local path to nlohmann_json source directory (preferred if set)")
# tarball fetcher
set(openPMD_json_tar "https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz"
CACHE STRING
"Remote tarball link to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)")
set(openPMD_json_tar_hash "SHA256=4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187"
CACHE STRING
"Hash checksum of the tarball of nlohmann_json if(openPMD_USE_INTERNAL_JSON)")
# Git fetcher
set(openPMD_json_repo "https://github.com/nlohmann/json.git"
CACHE STRING
"Repository URI to pull and build nlohmann_json from if(openPMD_USE_INTERNAL_JSON)")
set(openPMD_json_branch "v3.12.0"
CACHE STRING
"Repository branch for openPMD_json_repo if(openPMD_USE_INTERNAL_JSON)")
find_json()