Skip to content

Commit 2742eaa

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3cb979d commit 2742eaa

2 files changed

Lines changed: 83 additions & 41 deletions

File tree

source/lmp/builtin.cmake

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,49 @@
55
# assume LAMMPS CMake file has been executed, so these target/variables exist:
66
# lammps LAMMPS_SOURCE_DIR get_lammps_version
77

8-
# Since May 15, 2025, the output of get_lammps_version is changed.
9-
# We vendor the old get_lammps_version
8+
# Since May 15, 2025, the output of get_lammps_version is changed. We vendor the
9+
# old get_lammps_version
1010
# https://github.com/lammps/lammps/commit/b3e7121535863df3db487cd3e6a68c080bf2a6b4#diff-1214db0d1c015a50103f61f8ff7896053dec7ebc1edb930d6ef8bb07282f52abR75
1111
function(_get_lammps_version version_header variable)
12-
file(STRINGS ${version_header} line REGEX LAMMPS_VERSION)
13-
set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
14-
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1" day "${line}")
15-
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\2" month "${line}")
16-
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\3" year "${line}")
17-
string(STRIP ${day} day)
18-
string(STRIP ${month} month)
19-
string(STRIP ${year} year)
20-
list(FIND MONTHS "${month}" month)
21-
string(LENGTH ${day} day_length)
22-
string(LENGTH ${month} month_length)
23-
if(day_length EQUAL 1)
24-
set(day "0${day}")
25-
endif()
26-
if(month_length EQUAL 1)
27-
set(month "0${month}")
28-
endif()
29-
set(${variable} "${year}${month}${day}" PARENT_SCOPE)
12+
file(STRINGS ${version_header} line REGEX LAMMPS_VERSION)
13+
set(MONTHS
14+
x
15+
Jan
16+
Feb
17+
Mar
18+
Apr
19+
May
20+
Jun
21+
Jul
22+
Aug
23+
Sep
24+
Oct
25+
Nov
26+
Dec)
27+
string(REGEX
28+
REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\""
29+
"\\1" day "${line}")
30+
string(REGEX
31+
REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\""
32+
"\\2" month "${line}")
33+
string(REGEX
34+
REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\""
35+
"\\3" year "${line}")
36+
string(STRIP ${day} day)
37+
string(STRIP ${month} month)
38+
string(STRIP ${year} year)
39+
list(FIND MONTHS "${month}" month)
40+
string(LENGTH ${day} day_length)
41+
string(LENGTH ${month} month_length)
42+
if(day_length EQUAL 1)
43+
set(day "0${day}")
44+
endif()
45+
if(month_length EQUAL 1)
46+
set(month "0${month}")
47+
endif()
48+
set(${variable}
49+
"${year}${month}${day}"
50+
PARENT_SCOPE)
3051
endfunction()
3152

3253
_get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION_NUMBER)

source/lmp/plugin/CMakeLists.txt

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)