@@ -38,8 +38,33 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION)
3838
3939 # get_lammps_version
4040 # https://github.com/lammps/lammps/blob/c2a12f97c5f665852fb38fdd4922f7dd2e77a0a1/cmake/Modules/LAMMPSUtils.cmake#L27-L46
41- include (${LAMMPS_SOURCE_ROOT} /cmake/Modules/LAMMPSUtils.cmake )
42- get_lammps_version (${LAMMPS_HEADER_DIR} /version.h LAMMPS_VERSION_NUMBER )
41+ # include(${LAMMPS_SOURCE_ROOT}/cmake/Modules/LAMMPSUtils.cmake)
42+ # Since May 15, 2025, the output of get_lammps_version is changed.
43+ # We vendor the old get_lammps_version
44+ # https://github.com/lammps/lammps/commit/b3e7121535863df3db487cd3e6a68c080bf2a6b4#diff-1214db0d1c015a50103f61f8ff7896053dec7ebc1edb930d6ef8bb07282f52abR75
45+
46+ function (_get_lammps_version version_header variable )
47+ file (STRINGS ${version_header} line REGEX LAMMPS_VERSION )
48+ set (MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
49+ string (REGEX REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" " "\\ 1" day "${line} " )
50+ string (REGEX REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" " "\\ 2" month "${line} " )
51+ string (REGEX REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" " "\\ 3" year "${line} " )
52+ string (STRIP ${day} day)
53+ string (STRIP ${month} month)
54+ string (STRIP ${year} year)
55+ list (FIND MONTHS "${month} " month)
56+ string (LENGTH ${day} day_length)
57+ string (LENGTH ${month} month_length)
58+ if (day_length EQUAL 1)
59+ set (day "0${day} " )
60+ endif ()
61+ if (month_length EQUAL 1)
62+ set (month "0${month} " )
63+ endif ()
64+ set (${variable} "${year}${month}${day} " PARENT_SCOPE )
65+ endfunction ()
66+
67+ _get_lammps_version_old (${LAMMPS_HEADER_DIR} /version.h LAMMPS_VERSION_NUMBER )
4368 set (LAMMPS_VERSION_NUMBER
4469 ${LAMMPS_VERSION_NUMBER}
4570 PARENT_SCOPE )
0 commit comments