@@ -38,30 +38,51 @@ 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- # Since May 15, 2025, the output of get_lammps_version is changed.
43- # We vendor the old get_lammps_version
41+ # include(${LAMMPS_SOURCE_ROOT}/cmake/Modules/LAMMPSUtils.cmake) Since May 15,
42+ # 2025, the output of get_lammps_version is changed. We vendor the old
43+ # get_lammps_version
4444 # https://github.com/lammps/lammps/commit/b3e7121535863df3db487cd3e6a68c080bf2a6b4#diff-1214db0d1c015a50103f61f8ff7896053dec7ebc1edb930d6ef8bb07282f52abR75
4545
4646 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 )
47+ file (STRINGS ${version_header} line REGEX LAMMPS_VERSION )
48+ set (MONTHS
49+ x
50+ Jan
51+ Feb
52+ Mar
53+ Apr
54+ May
55+ Jun
56+ Jul
57+ Aug
58+ Sep
59+ Oct
60+ Nov
61+ Dec)
62+ string (REGEX
63+ REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" "
64+ "\\ 1" day "${line} " )
65+ string (REGEX
66+ REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" "
67+ "\\ 2" month "${line} " )
68+ string (REGEX
69+ REPLACE "#define LAMMPS_VERSION \" ([0-9]+) ([A-Za-z]+) ([0-9]+)\" "
70+ "\\ 3" year "${line} " )
71+ string (STRIP ${day} day)
72+ string (STRIP ${month} month)
73+ string (STRIP ${year} year)
74+ list (FIND MONTHS "${month} " month)
75+ string (LENGTH ${day} day_length)
76+ string (LENGTH ${month} month_length)
77+ if (day_length EQUAL 1)
78+ set (day "0${day} " )
79+ endif ()
80+ if (month_length EQUAL 1)
81+ set (month "0${month} " )
82+ endif ()
83+ set (${variable}
84+ "${year}${month}${day} "
85+ PARENT_SCOPE )
6586 endfunction ()
6687
6788 _get_lammps_version_old (${LAMMPS_HEADER_DIR} /version.h LAMMPS_VERSION_NUMBER )
0 commit comments