add CMake option to skip automatic download of large potential files

This commit is contained in:
Axel Kohlmeyer
2023-01-21 11:21:02 -05:00
parent 650caa356f
commit 6f3c8fc48e
2 changed files with 23 additions and 19 deletions

View File

@ -566,6 +566,8 @@ RegisterStyles(${LAMMPS_SOURCE_DIR})
######################################################## ########################################################
# Fetch missing external files and archives for packages # Fetch missing external files and archives for packages
######################################################## ########################################################
option(DOWNLOAD_POTENTIALS "Automatically download large potential files" ON)
mark_as_advanced(DOWNLOAD_POTENTIALS)
foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
if(PKG_${PKG}) if(PKG_${PKG})
FetchPotentials(${LAMMPS_SOURCE_DIR}/${PKG} ${LAMMPS_POTENTIALS_DIR}) FetchPotentials(${LAMMPS_SOURCE_DIR}/${PKG} ${LAMMPS_POTENTIALS_DIR})

View File

@ -118,6 +118,7 @@ endfunction(GenerateBinaryHeader)
# fetch missing potential files # fetch missing potential files
function(FetchPotentials pkgfolder potfolder) function(FetchPotentials pkgfolder potfolder)
if(DOWNLOAD_POTENTIALS)
if(EXISTS "${pkgfolder}/potentials.txt") if(EXISTS "${pkgfolder}/potentials.txt")
file(STRINGS "${pkgfolder}/potentials.txt" linelist REGEX "^[^#].") file(STRINGS "${pkgfolder}/potentials.txt" linelist REGEX "^[^#].")
foreach(line ${linelist}) foreach(line ${linelist})
@ -130,7 +131,7 @@ function(FetchPotentials pkgfolder potfolder)
endif() endif()
if(NOT sum STREQUAL oldsum) if(NOT sum STREQUAL oldsum)
message(STATUS "Downloading external potential ${pot} from ${LAMMPS_POTENTIALS_URL}") message(STATUS "Downloading external potential ${pot} from ${LAMMPS_POTENTIALS_URL}")
string(MD5 TMP_EXT "${CMAKE_BINARY_DIR}") string(RANDOM LENGTH 10 TMP_EXT)
file(DOWNLOAD "${LAMMPS_POTENTIALS_URL}/${pot}.${sum}" "${CMAKE_BINARY_DIR}/${pot}.${TMP_EXT}" file(DOWNLOAD "${LAMMPS_POTENTIALS_URL}/${pot}.${sum}" "${CMAKE_BINARY_DIR}/${pot}.${TMP_EXT}"
EXPECTED_HASH MD5=${sum} SHOW_PROGRESS) EXPECTED_HASH MD5=${sum} SHOW_PROGRESS)
file(COPY "${CMAKE_BINARY_DIR}/${pot}.${TMP_EXT}" DESTINATION "${LAMMPS_POTENTIALS_DIR}") file(COPY "${CMAKE_BINARY_DIR}/${pot}.${TMP_EXT}" DESTINATION "${LAMMPS_POTENTIALS_DIR}")
@ -138,6 +139,7 @@ function(FetchPotentials pkgfolder potfolder)
endif() endif()
endforeach() endforeach()
endif() endif()
endif()
endfunction(FetchPotentials) endfunction(FetchPotentials)
# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux # set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux