|
1 | 1 | function(find_json) |
2 | 2 | if(TARGET nlohmann_json::nlohmann_json) |
3 | 3 | message(STATUS "nlohmann_json::nlohmann_json target already imported") |
4 | | - elseif(openPMD_json_src) |
5 | | - message(STATUS "Compiling local nlohmann_json ...") |
6 | | - message(STATUS "nlohmann_json source path: ${openPMD_json_src}") |
7 | | - if(NOT IS_DIRECTORY ${openPMD_json_src}) |
8 | | - message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!") |
9 | | - endif() |
10 | | - elseif(openPMD_json_tar) |
11 | | - message(STATUS "Downloading nlohmann_json ...") |
12 | | - message(STATUS "nlohmann_json source: ${openPMD_json_tar}") |
13 | 4 | elseif(openPMD_USE_INTERNAL_JSON) |
14 | | - message(STATUS "Downloading nlohmann_json ...") |
15 | | - message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})") |
| 5 | + if(openPMD_json_src) |
| 6 | + message(STATUS "Compiling local nlohmann_json ...") |
| 7 | + message(STATUS "nlohmann_json source path: ${openPMD_json_src}") |
| 8 | + if(NOT IS_DIRECTORY ${openPMD_json_src}) |
| 9 | + message(FATAL_ERROR "Specified directory openPMD_json_src='${openPMD_json_src}' does not exist!") |
| 10 | + endif() |
| 11 | + elseif(openPMD_json_tar) |
| 12 | + message(STATUS "Downloading nlohmann_json ...") |
| 13 | + message(STATUS "nlohmann_json source: ${openPMD_json_tar}") |
| 14 | + elseif(openPMD_json_branch) |
| 15 | + message(STATUS "Downloading nlohmann_json ...") |
| 16 | + message(STATUS "nlohmann_json repository: ${openPMD_json_repo} (${openPMD_json_branch})") |
| 17 | + endif() |
16 | 18 | endif() |
17 | 19 | if(TARGET nlohmann_json::nlohmann_json) |
18 | 20 | # nothing to do, target already exists in the superbuild |
19 | | - elseif(openPMD_USE_INTERNAL_JSON OR openPMD_json_src OR openPMD_json_tar) |
20 | | - if(openPMD_json_src) |
21 | | - add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/) |
| 21 | + elseif(openPMD_USE_INTERNAL_JSON AND openPMD_json_src) |
| 22 | + add_subdirectory(${openPMD_json_src} _deps/localnlohmann_json-build/) |
| 23 | + elseif(openPMD_USE_INTERNAL_JSON AND (openPMD_json_tar OR openPMD_json_branch)) |
| 24 | + include(FetchContent) |
| 25 | + if(openPMD_json_tar) |
| 26 | + FetchContent_Declare(fetchednlohmann_json |
| 27 | + URL ${openPMD_json_tar} |
| 28 | + URL_HASH ${openPMD_json_tar_hash} |
| 29 | + BUILD_IN_SOURCE OFF |
| 30 | + ) |
22 | 31 | else() |
23 | | - include(FetchContent) |
24 | | - if(openPMD_json_tar) |
25 | | - FetchContent_Declare(fetchednlohmann_json |
26 | | - URL ${openPMD_json_tar} |
27 | | - URL_HASH ${openPMD_json_tar_hash} |
28 | | - BUILD_IN_SOURCE OFF |
29 | | - ) |
30 | | - else() |
31 | | - FetchContent_Declare(fetchednlohmann_json |
32 | | - GIT_REPOSITORY ${openPMD_json_repo} |
33 | | - GIT_TAG ${openPMD_json_branch} |
34 | | - BUILD_IN_SOURCE OFF |
35 | | - ) |
36 | | - endif() |
37 | | - FetchContent_MakeAvailable(fetchednlohmann_json) |
38 | | - |
39 | | - # advanced fetch options |
40 | | - mark_as_advanced(FETCHCONTENT_BASE_DIR) |
41 | | - mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) |
42 | | - mark_as_advanced(FETCHCONTENT_QUIET) |
43 | | - #mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDnlohmann_json) |
44 | | - mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) |
45 | | - #mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDnlohmann_json) |
| 32 | + FetchContent_Declare(fetchednlohmann_json |
| 33 | + GIT_REPOSITORY ${openPMD_json_repo} |
| 34 | + GIT_TAG ${openPMD_json_branch} |
| 35 | + BUILD_IN_SOURCE OFF |
| 36 | + ) |
46 | 37 | endif() |
| 38 | + FetchContent_MakeAvailable(fetchednlohmann_json) |
| 39 | + |
| 40 | + # advanced fetch options |
| 41 | + mark_as_advanced(FETCHCONTENT_BASE_DIR) |
| 42 | + mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED) |
| 43 | + mark_as_advanced(FETCHCONTENT_QUIET) |
| 44 | + #mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FETCHEDnlohmann_json) |
| 45 | + mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED) |
| 46 | + #mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDnlohmann_json) |
47 | 47 | elseif(NOT openPMD_USE_INTERNAL_JSON) |
48 | 48 | find_package(nlohmann_json 3.9.1 CONFIG REQUIRED) |
49 | 49 | message(STATUS "nlohmann_json: Found version '${nlohmann_json_VERSION}'") |
|
0 commit comments