mirror of
https://github.com/k2-fsa/sherpa-onnx.git
synced 2026-11-10 13:04:05 +08:00
47 lines
1.3 KiB
CMake
47 lines
1.3 KiB
CMake
include_guard(GLOBAL)
|
|
|
|
function(download_json)
|
|
include(FetchContent)
|
|
|
|
set(json_URL "https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz")
|
|
set(json_HASH "SHA256=4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187")
|
|
|
|
# If you don't have access to the Internet,
|
|
# please pre-download json
|
|
set(possible_file_locations
|
|
$ENV{HOME}/Downloads/json-3.12.0.tar.gz
|
|
${CMAKE_SOURCE_DIR}/json-3.12.0.tar.gz
|
|
${CMAKE_BINARY_DIR}/json-3.12.0.tar.gz
|
|
/tmp/json-3.12.0.tar.gz
|
|
/star-fj/fangjun/download/github/json-3.12.0.tar.gz
|
|
)
|
|
|
|
foreach(f IN LISTS possible_file_locations)
|
|
if(EXISTS ${f})
|
|
set(json_URL "${f}")
|
|
file(TO_CMAKE_PATH "${json_URL}" json_URL)
|
|
message(STATUS "Found local downloaded json: ${json_URL}")
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
|
|
FetchContent_Declare(json
|
|
URL ${json_URL}
|
|
URL_HASH ${json_HASH}
|
|
)
|
|
|
|
FetchContent_GetProperties(json)
|
|
if(NOT json_POPULATED)
|
|
message(STATUS "Downloading json from ${json_URL}")
|
|
FetchContent_Populate(json)
|
|
endif()
|
|
message(STATUS "json is downloaded to ${json_SOURCE_DIR}")
|
|
message(STATUS "json's binary dir is ${json_BINARY_DIR}")
|
|
include_directories(${json_SOURCE_DIR}/include)
|
|
|
|
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
endfunction()
|
|
|
|
download_json()
|
|
|