add CMake support for fetching external potential files
This commit is contained in:
@ -85,3 +85,20 @@ function(GenerateBinaryHeader varname outfile files)
|
||||
file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
|
||||
endforeach()
|
||||
endfunction(GenerateBinaryHeader)
|
||||
|
||||
# fetch missing potential files
|
||||
function(FetchPotentials pkgfolder potfolder)
|
||||
if (EXISTS "${pkgfolder}/potentials.txt")
|
||||
set(LAMMPS_POTENTIALS_URL "https://download.lammps.org/potentials")
|
||||
file(STRINGS "${pkgfolder}/potentials.txt" linelist REGEX "^[^#].")
|
||||
foreach(line ${linelist})
|
||||
string(FIND ${line} " " blank)
|
||||
math(EXPR plusone "${blank}+1")
|
||||
string(SUBSTRING ${line} 0 ${blank} pot)
|
||||
string(SUBSTRING ${line} ${plusone} -1 sum)
|
||||
message("Checking whether to download external potential ${pot} from ${LAMMPS_POTENTIALS_URL}")
|
||||
file(DOWNLOAD "${LAMMPS_POTENTIALS_URL}/${pot}.${sum}" "${LAMMPS_POTENTIALS_DIR}/${pot}"
|
||||
EXPECTED_HASH MD5=${sum} SHOW_PROGRESS)
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction(FetchPotentials)
|
||||
|
||||
Reference in New Issue
Block a user