From df2050343486e784dfbfd651eb766d0677554b14 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 9 Feb 2023 07:44:40 -0500 Subject: [PATCH] make fallback url function available to plugin compilations --- cmake/Modules/LAMMPSInterfacePlugin.cmake | 12 ++++++++++++ cmake/Modules/LAMMPSUtils.cmake | 1 + 2 files changed, 13 insertions(+) diff --git a/cmake/Modules/LAMMPSInterfacePlugin.cmake b/cmake/Modules/LAMMPSInterfacePlugin.cmake index 79e9a0955c..c1cc613496 100644 --- a/cmake/Modules/LAMMPSInterfacePlugin.cmake +++ b/cmake/Modules/LAMMPSInterfacePlugin.cmake @@ -88,6 +88,18 @@ function(get_lammps_version version_header variable) set(${variable} "${date}" PARENT_SCOPE) endfunction() +# determine canonical URL for downloading backup copy from download.lammps.org/thirdparty +function(GetFallbackURL input output) + string(REPLACE "_URL" "" _tmp ${input}) + string(TOLOWER ${_tmp} libname) + string(REGEX REPLACE "^https://.*/([^/]+gz)" "${LAMMPS_THIRDPARTY_URL}/${libname}-\\1" newurl "${${input}}") + if ("${newurl}" STREQUAL "${${input}}") + set(${output} "" PARENT_SCOPE) + else() + set(${output} ${newurl} PARENT_SCOPE) + endif() +endfunction(GetFallbackURL) + ################################################################################# # LAMMPS C++ interface. We only need the header related parts except on windows. add_library(lammps INTERFACE) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 9dd123e55a..03ac8a3258 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -150,6 +150,7 @@ if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (EXISTS /etc/os-release)) set(CMAKE_DISTRO_VERSION ${disversion}) endif() +# determine canonical URL for downloading backup copy from download.lammps.org/thirdparty function(GetFallbackURL input output) string(REPLACE "_URL" "" _tmp ${input}) string(TOLOWER ${_tmp} libname)