add CMake support for fetching external potential files
This commit is contained in:
@ -365,6 +365,15 @@ target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES})
|
|||||||
include(StyleHeaderUtils)
|
include(StyleHeaderUtils)
|
||||||
RegisterStyles(${LAMMPS_SOURCE_DIR})
|
RegisterStyles(${LAMMPS_SOURCE_DIR})
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
# Fetch missing external files and archives for packages
|
||||||
|
########################################################
|
||||||
|
foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
|
||||||
|
if(PKG_${PKG})
|
||||||
|
FetchPotentials(${${PKG}_SOURCES_DIR} ${LAMMPS_POTENTIALS_DIR})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# add sources of enabled packages
|
# add sources of enabled packages
|
||||||
############################################
|
############################################
|
||||||
|
|||||||
@ -85,3 +85,20 @@ function(GenerateBinaryHeader varname outfile files)
|
|||||||
file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
|
file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction(GenerateBinaryHeader)
|
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