diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 943c3d851e..9f624fc007 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -24,6 +24,24 @@ function(validate_option name values) endif() endfunction(validate_option) +# helper function for getting the most recently modified file or folder from a glob pattern +function(get_newest_file path variable) + file(GLOB _dirs ${path}) + set(_besttime 2000-01-01T00:00:00) + set(_bestfile "") + foreach(_dir ${_dirs}) + file(TIMESTAMP ${_dir} _newtime) + if(_newtime IS_NEWER_THAN _besttime) + set(_bestfile ${_dir}) + set(_besttime ${_newtime}) + endif() + endforeach() + if(_bestfile STREQUAL "") + message(FATAL_ERROR "Could not find valid path at: ${path}") + endif() + set(${variable} ${_bestfile} PARENT_SCOPE) +endfunction() + function(get_lammps_version version_header variable) file(STRINGS ${version_header} line REGEX LAMMPS_VERSION) set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) diff --git a/cmake/Modules/Packages/ML-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake index adfdd8ebf8..c647c8873a 100644 --- a/cmake/Modules/Packages/ML-PACE.cmake +++ b/cmake/Modules/Packages/ML-PACE.cmake @@ -13,8 +13,8 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf libpace.tar.gz WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) +get_newest_file(${CMAKE_BINARY_DIR}/lammps-user-pace-* lib-pace) -file(GLOB lib-pace ${CMAKE_BINARY_DIR}/lammps-user-pace-*) # enforce building libyaml-cpp as static library and turn off optional features set(YAML_BUILD_SHARED_LIBS OFF) set(YAML_CPP_BUILD_CONTRIB OFF)