libmolsymm 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libmolsymm-1.0.0/.clang-format +16 -0
- libmolsymm-1.0.0/.clang-tidy +62 -0
- libmolsymm-1.0.0/.github/workflows/ci.yml +181 -0
- libmolsymm-1.0.0/.github/workflows/publish-pypi.yml +106 -0
- libmolsymm-1.0.0/.gitignore +16 -0
- libmolsymm-1.0.0/CMakeLists.txt +197 -0
- libmolsymm-1.0.0/LICENSE +21 -0
- libmolsymm-1.0.0/PKG-INFO +128 -0
- libmolsymm-1.0.0/README.md +102 -0
- libmolsymm-1.0.0/cmake/MolsymmConfig.cmake.in +3 -0
- libmolsymm-1.0.0/cmake/molsymm.pc.in +9 -0
- libmolsymm-1.0.0/examples/analyze_xyz.cpp +63 -0
- libmolsymm-1.0.0/fortran/molsymm.f90 +220 -0
- libmolsymm-1.0.0/include/molsymm/analysis.hpp +42 -0
- libmolsymm-1.0.0/include/molsymm/displacement.hpp +50 -0
- libmolsymm-1.0.0/include/molsymm/error.hpp +13 -0
- libmolsymm-1.0.0/include/molsymm/masses.hpp +8 -0
- libmolsymm-1.0.0/include/molsymm/molecule.hpp +25 -0
- libmolsymm-1.0.0/include/molsymm/molsymm.h +63 -0
- libmolsymm-1.0.0/include/molsymm/molsymm.hpp +8 -0
- libmolsymm-1.0.0/include/molsymm/types.hpp +61 -0
- libmolsymm-1.0.0/pyproject.toml +68 -0
- libmolsymm-1.0.0/python/molsymm.cpp +110 -0
- libmolsymm-1.0.0/src/c_api.cpp +349 -0
- libmolsymm-1.0.0/src/character_table.cpp +744 -0
- libmolsymm-1.0.0/src/detect.cpp +652 -0
- libmolsymm-1.0.0/src/displacements.cpp +567 -0
- libmolsymm-1.0.0/src/equivalence.cpp +85 -0
- libmolsymm-1.0.0/src/internal.hpp +151 -0
- libmolsymm-1.0.0/src/masses.cpp +36 -0
- libmolsymm-1.0.0/src/molecule.cpp +66 -0
- libmolsymm-1.0.0/src/operations.cpp +222 -0
- libmolsymm-1.0.0/src/subgroups.cpp +307 -0
- libmolsymm-1.0.0/src/symmetrize.cpp +115 -0
- libmolsymm-1.0.0/tests/data/22paracyclophane.xyz +34 -0
- libmolsymm-1.0.0/tests/data/E_2butene.xyz +14 -0
- libmolsymm-1.0.0/tests/data/NOTICE +39 -0
- libmolsymm-1.0.0/tests/data/adamantane.xyz +28 -0
- libmolsymm-1.0.0/tests/data/anion-pi.xyz +15 -0
- libmolsymm-1.0.0/tests/data/c60.xyz +62 -0
- libmolsymm-1.0.0/tests/data/corannulene.xyz +32 -0
- libmolsymm-1.0.0/tests/data/coronene.xyz +38 -0
- libmolsymm-1.0.0/tests/data/cubane.xyz +18 -0
- libmolsymm-1.0.0/tests/data/cyclopropane.xyz +11 -0
- libmolsymm-1.0.0/tests/data/ferrocene.xyz +23 -0
- libmolsymm-1.0.0/tests/data/octahedral.xyz +9 -0
- libmolsymm-1.0.0/tests/data/pt_complex.xyz +12 -0
- libmolsymm-1.0.0/tests/data/water.xyz +5 -0
- libmolsymm-1.0.0/tests/test_fortran.f90 +33 -0
- libmolsymm-1.0.0/tests/test_main.cpp +522 -0
- libmolsymm-1.0.0/tests/test_python.py +101 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
BasedOnStyle: LLVM
|
|
2
|
+
IndentWidth: 2
|
|
3
|
+
ColumnLimit: 100
|
|
4
|
+
PointerAlignment: Left
|
|
5
|
+
DerivePointerAlignment: false
|
|
6
|
+
AllowShortFunctionsOnASingleLine: Inline
|
|
7
|
+
AllowShortIfStatementsOnASingleLine: Never
|
|
8
|
+
AllowShortLoopsOnASingleLine: false
|
|
9
|
+
BinPackArguments: false
|
|
10
|
+
BinPackParameters: false
|
|
11
|
+
AlwaysBreakTemplateDeclarations: Yes
|
|
12
|
+
SortIncludes: true
|
|
13
|
+
IncludeBlocks: Preserve
|
|
14
|
+
NamespaceIndentation: None
|
|
15
|
+
AccessModifierOffset: -2
|
|
16
|
+
Standard: c++20
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
Checks: >
|
|
3
|
+
bugprone-*,
|
|
4
|
+
cert-*,
|
|
5
|
+
clang-analyzer-*,
|
|
6
|
+
cppcoreguidelines-*,
|
|
7
|
+
misc-*,
|
|
8
|
+
modernize-*,
|
|
9
|
+
performance-*,
|
|
10
|
+
portability-*,
|
|
11
|
+
readability-*,
|
|
12
|
+
-cppcoreguidelines-avoid-magic-numbers,
|
|
13
|
+
-readability-magic-numbers,
|
|
14
|
+
-readability-identifier-length,
|
|
15
|
+
-modernize-use-trailing-return-type,
|
|
16
|
+
-cppcoreguidelines-pro-bounds-*,
|
|
17
|
+
-cppcoreguidelines-owning-memory,
|
|
18
|
+
-cppcoreguidelines-pro-type-reinterpret-cast,
|
|
19
|
+
-cppcoreguidelines-pro-type-vararg,
|
|
20
|
+
-cppcoreguidelines-avoid-non-const-global-variables,
|
|
21
|
+
-cppcoreguidelines-init-variables,
|
|
22
|
+
-cppcoreguidelines-avoid-c-arrays,
|
|
23
|
+
-cppcoreguidelines-missing-std-forward,
|
|
24
|
+
-cppcoreguidelines-narrowing-conversions,
|
|
25
|
+
-modernize-avoid-c-arrays,
|
|
26
|
+
-modernize-use-using,
|
|
27
|
+
-modernize-use-std-numbers,
|
|
28
|
+
-modernize-return-braced-init-list,
|
|
29
|
+
-modernize-use-integer-sign-comparison,
|
|
30
|
+
-modernize-use-ranges,
|
|
31
|
+
-modernize-use-designated-initializers,
|
|
32
|
+
-readability-function-cognitive-complexity,
|
|
33
|
+
-readability-implicit-bool-conversion,
|
|
34
|
+
-readability-redundant-member-init,
|
|
35
|
+
-readability-math-missing-parentheses,
|
|
36
|
+
-readability-qualified-auto,
|
|
37
|
+
-readability-trailing-comma,
|
|
38
|
+
-readability-redundant-nested-if,
|
|
39
|
+
-misc-include-cleaner,
|
|
40
|
+
-misc-const-correctness,
|
|
41
|
+
-misc-use-anonymous-namespace,
|
|
42
|
+
-bugprone-narrowing-conversions,
|
|
43
|
+
-bugprone-implicit-widening-of-multiplication-result,
|
|
44
|
+
-bugprone-easily-swappable-parameters,
|
|
45
|
+
-portability-avoid-pragma-once,
|
|
46
|
+
-cert-err33-c,
|
|
47
|
+
-cert-err34-c
|
|
48
|
+
WarningsAsErrors: '*'
|
|
49
|
+
HeaderFilterRegex: '.*/(include/molsymm|src|tests|examples|python)/.*\.(hpp|cpp)$'
|
|
50
|
+
FormatStyle: none
|
|
51
|
+
CheckOptions:
|
|
52
|
+
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
|
53
|
+
value: '1'
|
|
54
|
+
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
|
55
|
+
value: '1'
|
|
56
|
+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
|
|
57
|
+
value: '1'
|
|
58
|
+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
|
|
59
|
+
value: '1'
|
|
60
|
+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
|
|
61
|
+
value: '1'
|
|
62
|
+
...
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
lint:
|
|
19
|
+
name: lint
|
|
20
|
+
runs-on: ubuntu-24.04
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v5
|
|
23
|
+
|
|
24
|
+
- name: Install lint tools
|
|
25
|
+
run: |
|
|
26
|
+
sudo apt-get update
|
|
27
|
+
sudo apt-get install -y \
|
|
28
|
+
clang-tidy clang-tools cppcheck \
|
|
29
|
+
python3-pip ninja-build cmake g++ libeigen3-dev
|
|
30
|
+
python3 -m pip install --user ruff 'clang-format==23.1.3'
|
|
31
|
+
|
|
32
|
+
- name: clang-format
|
|
33
|
+
run: |
|
|
34
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
35
|
+
mapfile -t FILES < <(find include src tests examples python -type f \
|
|
36
|
+
\( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' \) | sort)
|
|
37
|
+
clang-format --dry-run --Werror "${FILES[@]}"
|
|
38
|
+
|
|
39
|
+
- name: Configure for compile_commands
|
|
40
|
+
run: |
|
|
41
|
+
cmake -S . -B build-lint -G Ninja \
|
|
42
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
43
|
+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
|
44
|
+
-DCMAKE_CXX_COMPILER=g++ \
|
|
45
|
+
-DMOLSYMM_BUILD_PYTHON=OFF \
|
|
46
|
+
-DMOLSYMM_BUILD_FORTRAN=OFF \
|
|
47
|
+
-DMOLSYMM_BUILD_TESTS=ON
|
|
48
|
+
|
|
49
|
+
- name: clang-tidy
|
|
50
|
+
run: |
|
|
51
|
+
mapfile -t TUS < <(find src tests examples -name '*.cpp' | sort)
|
|
52
|
+
run-clang-tidy -p build-lint -quiet "${TUS[@]}"
|
|
53
|
+
|
|
54
|
+
- name: cppcheck
|
|
55
|
+
run: |
|
|
56
|
+
mapfile -t FILES < <(find include src tests examples python -type f \
|
|
57
|
+
\( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' \) | sort)
|
|
58
|
+
cppcheck --enable=all --error-exitcode=1 --inline-suppr \
|
|
59
|
+
--std=c++20 --force \
|
|
60
|
+
-I include \
|
|
61
|
+
-DMOLSYMM_TEST_DATA_DIR=\"tests/data\" \
|
|
62
|
+
--suppress=missingIncludeSystem \
|
|
63
|
+
--suppress=unusedFunction \
|
|
64
|
+
--suppress=unmatchedSuppression \
|
|
65
|
+
--suppress=useStlAlgorithm \
|
|
66
|
+
--suppress=ConfigurationNotChecked \
|
|
67
|
+
--suppress=unusedStructMember \
|
|
68
|
+
--suppress=checkersReport \
|
|
69
|
+
"${FILES[@]}"
|
|
70
|
+
|
|
71
|
+
- name: ruff
|
|
72
|
+
run: |
|
|
73
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
74
|
+
ruff check tests/test_python.py
|
|
75
|
+
|
|
76
|
+
test:
|
|
77
|
+
name: test (${{ matrix.compiler }}, ${{ matrix.build_type }})
|
|
78
|
+
runs-on: ubuntu-24.04
|
|
79
|
+
strategy:
|
|
80
|
+
fail-fast: false
|
|
81
|
+
matrix:
|
|
82
|
+
include:
|
|
83
|
+
- compiler: g++
|
|
84
|
+
cc: gcc
|
|
85
|
+
cxx: g++
|
|
86
|
+
fc: gfortran
|
|
87
|
+
build_type: Release
|
|
88
|
+
- compiler: g++
|
|
89
|
+
cc: gcc
|
|
90
|
+
cxx: g++
|
|
91
|
+
fc: gfortran
|
|
92
|
+
build_type: Debug
|
|
93
|
+
- compiler: clang++
|
|
94
|
+
cc: clang
|
|
95
|
+
cxx: clang++
|
|
96
|
+
fc: gfortran
|
|
97
|
+
build_type: Release
|
|
98
|
+
- compiler: clang++
|
|
99
|
+
cc: clang
|
|
100
|
+
cxx: clang++
|
|
101
|
+
fc: gfortran
|
|
102
|
+
build_type: Debug
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@v5
|
|
105
|
+
|
|
106
|
+
- name: Install build dependencies
|
|
107
|
+
run: |
|
|
108
|
+
sudo apt-get update
|
|
109
|
+
pkgs=(build-essential cmake ninja-build gfortran
|
|
110
|
+
python3-dev python3-numpy libeigen3-dev)
|
|
111
|
+
if [ "${{ matrix.compiler }}" = "clang++" ]; then
|
|
112
|
+
pkgs+=(clang)
|
|
113
|
+
fi
|
|
114
|
+
sudo apt-get install -y "${pkgs[@]}"
|
|
115
|
+
- name: Configure
|
|
116
|
+
env:
|
|
117
|
+
CC: ${{ matrix.cc }}
|
|
118
|
+
CXX: ${{ matrix.cxx }}
|
|
119
|
+
FC: ${{ matrix.fc }}
|
|
120
|
+
run: |
|
|
121
|
+
cmake -S . -B build -G Ninja \
|
|
122
|
+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
|
123
|
+
-DMOLSYMM_BUILD_PYTHON=ON \
|
|
124
|
+
-DMOLSYMM_BUILD_FORTRAN=ON \
|
|
125
|
+
-DMOLSYMM_BUILD_TESTS=ON
|
|
126
|
+
|
|
127
|
+
- name: Build
|
|
128
|
+
run: cmake --build build -j
|
|
129
|
+
|
|
130
|
+
- name: Test
|
|
131
|
+
run: ctest --test-dir build --output-on-failure --timeout 120
|
|
132
|
+
|
|
133
|
+
sanitize:
|
|
134
|
+
name: sanitize (clang++ ASan+UBSan)
|
|
135
|
+
runs-on: ubuntu-24.04
|
|
136
|
+
steps:
|
|
137
|
+
- uses: actions/checkout@v5
|
|
138
|
+
|
|
139
|
+
- name: Install build dependencies
|
|
140
|
+
run: |
|
|
141
|
+
sudo apt-get update
|
|
142
|
+
sudo apt-get install -y \
|
|
143
|
+
clang cmake ninja-build libeigen3-dev
|
|
144
|
+
|
|
145
|
+
- name: Configure (C++ tests only, sanitized)
|
|
146
|
+
env:
|
|
147
|
+
CC: clang
|
|
148
|
+
CXX: clang++
|
|
149
|
+
run: |
|
|
150
|
+
cmake -S . -B build -G Ninja \
|
|
151
|
+
-DCMAKE_BUILD_TYPE=Debug \
|
|
152
|
+
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" \
|
|
153
|
+
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined" \
|
|
154
|
+
-DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address,undefined" \
|
|
155
|
+
-DMOLSYMM_BUILD_PYTHON=OFF \
|
|
156
|
+
-DMOLSYMM_BUILD_FORTRAN=OFF \
|
|
157
|
+
-DMOLSYMM_BUILD_TESTS=ON
|
|
158
|
+
|
|
159
|
+
- name: Build
|
|
160
|
+
run: cmake --build build -j
|
|
161
|
+
|
|
162
|
+
- name: Test
|
|
163
|
+
env:
|
|
164
|
+
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
|
|
165
|
+
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
|
|
166
|
+
run: ctest --test-dir build --output-on-failure --timeout 180
|
|
167
|
+
|
|
168
|
+
ci:
|
|
169
|
+
name: CI gate
|
|
170
|
+
runs-on: ubuntu-24.04
|
|
171
|
+
needs: [lint, test, sanitize]
|
|
172
|
+
if: always()
|
|
173
|
+
steps:
|
|
174
|
+
- name: Require all jobs succeeded
|
|
175
|
+
run: |
|
|
176
|
+
echo "lint=${{ needs.lint.result }}"
|
|
177
|
+
echo "test=${{ needs.test.result }}"
|
|
178
|
+
echo "sanitize=${{ needs.sanitize.result }}"
|
|
179
|
+
test "${{ needs.lint.result }}" = "success"
|
|
180
|
+
test "${{ needs.test.result }}" = "success"
|
|
181
|
+
test "${{ needs.sanitize.result }}" = "success"
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
target:
|
|
7
|
+
description: Upload target
|
|
8
|
+
required: true
|
|
9
|
+
default: pypi
|
|
10
|
+
type: choice
|
|
11
|
+
options:
|
|
12
|
+
- pypi
|
|
13
|
+
- testpypi
|
|
14
|
+
confirm:
|
|
15
|
+
description: Type "publish" to confirm upload
|
|
16
|
+
required: true
|
|
17
|
+
type: string
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
contents: read
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
test:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.12"
|
|
31
|
+
|
|
32
|
+
- name: Install build dependencies
|
|
33
|
+
run: |
|
|
34
|
+
sudo apt-get update
|
|
35
|
+
sudo apt-get install -y cmake g++
|
|
36
|
+
|
|
37
|
+
- name: Install package
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
python -m pip install ".[test]"
|
|
41
|
+
|
|
42
|
+
- name: Run Python tests
|
|
43
|
+
env:
|
|
44
|
+
MOLSYMM_TEST_DATA_DIR: ${{ github.workspace }}/tests/data
|
|
45
|
+
run: python -m pytest tests/test_python.py -q
|
|
46
|
+
|
|
47
|
+
build:
|
|
48
|
+
needs: test
|
|
49
|
+
if: github.event.inputs.confirm == 'publish'
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- uses: actions/setup-python@v5
|
|
55
|
+
with:
|
|
56
|
+
python-version: "3.12"
|
|
57
|
+
|
|
58
|
+
- name: Install build dependencies
|
|
59
|
+
run: |
|
|
60
|
+
sudo apt-get update
|
|
61
|
+
sudo apt-get install -y cmake g++
|
|
62
|
+
python -m pip install --upgrade pip build twine cibuildwheel
|
|
63
|
+
|
|
64
|
+
- name: Read package version
|
|
65
|
+
id: version
|
|
66
|
+
run: |
|
|
67
|
+
VERSION=$(python -c "import pathlib, re; print(re.search(r'^version = \"([^\"]+)\"', pathlib.Path('pyproject.toml').read_text(), re.M).group(1))")
|
|
68
|
+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
69
|
+
echo "Publishing libmolsymm $VERSION to ${{ github.event.inputs.target }}"
|
|
70
|
+
|
|
71
|
+
- name: Build sdist
|
|
72
|
+
run: python -m build --sdist
|
|
73
|
+
|
|
74
|
+
- name: Build manylinux wheels
|
|
75
|
+
run: python -m cibuildwheel --output-dir dist
|
|
76
|
+
|
|
77
|
+
- name: Verify distributions
|
|
78
|
+
run: twine check dist/*
|
|
79
|
+
|
|
80
|
+
- uses: actions/upload-artifact@v4
|
|
81
|
+
with:
|
|
82
|
+
name: python-dist
|
|
83
|
+
path: dist/*
|
|
84
|
+
|
|
85
|
+
publish:
|
|
86
|
+
needs: build
|
|
87
|
+
if: github.event.inputs.confirm == 'publish'
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
environment: ${{ github.event.inputs.target }}
|
|
90
|
+
permissions:
|
|
91
|
+
id-token: write
|
|
92
|
+
steps:
|
|
93
|
+
- uses: actions/download-artifact@v4
|
|
94
|
+
with:
|
|
95
|
+
name: python-dist
|
|
96
|
+
path: dist
|
|
97
|
+
|
|
98
|
+
- name: Publish to PyPI
|
|
99
|
+
if: github.event.inputs.target == 'pypi'
|
|
100
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33
|
|
101
|
+
|
|
102
|
+
- name: Publish to TestPyPI
|
|
103
|
+
if: github.event.inputs.target == 'testpypi'
|
|
104
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33
|
|
105
|
+
with:
|
|
106
|
+
repository-url: https://test.pypi.org/legacy/
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(molsymm VERSION 1.0.0 LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
8
|
+
|
|
9
|
+
option(MOLSYMM_BUILD_PYTHON "Build nanobind Python module" OFF)
|
|
10
|
+
option(MOLSYMM_BUILD_FORTRAN "Build Fortran module" OFF)
|
|
11
|
+
option(MOLSYMM_BUILD_TESTS "Build tests" ON)
|
|
12
|
+
option(MOLSYMM_BUILD_SHARED "Build shared library" ON)
|
|
13
|
+
|
|
14
|
+
# scikit-build-core: ship a single extension module with a static core.
|
|
15
|
+
if(DEFINED SKBUILD)
|
|
16
|
+
set(MOLSYMM_BUILD_PYTHON ON CACHE BOOL "" FORCE)
|
|
17
|
+
set(MOLSYMM_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
18
|
+
set(MOLSYMM_BUILD_FORTRAN OFF CACHE BOOL "" FORCE)
|
|
19
|
+
set(MOLSYMM_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
|
20
|
+
endif()
|
|
21
|
+
|
|
22
|
+
include(FetchContent)
|
|
23
|
+
find_package(Eigen3 3.4 QUIET NO_MODULE)
|
|
24
|
+
if(NOT Eigen3_FOUND)
|
|
25
|
+
# Tarball avoids flaky git clones against gitlab.com under CI load.
|
|
26
|
+
FetchContent_Declare(
|
|
27
|
+
Eigen
|
|
28
|
+
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2
|
|
29
|
+
URL_HASH SHA256=b4c198460eba6f28d34894e3a5710998818515104d6e74e5cc331ce31e46e626
|
|
30
|
+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
31
|
+
)
|
|
32
|
+
set(EIGEN_BUILD_DOC OFF CACHE BOOL "" FORCE)
|
|
33
|
+
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
|
34
|
+
FetchContent_MakeAvailable(Eigen)
|
|
35
|
+
endif()
|
|
36
|
+
|
|
37
|
+
set(MOLSYMM_SOURCES
|
|
38
|
+
src/masses.cpp
|
|
39
|
+
src/molecule.cpp
|
|
40
|
+
src/operations.cpp
|
|
41
|
+
src/equivalence.cpp
|
|
42
|
+
src/detect.cpp
|
|
43
|
+
src/character_table.cpp
|
|
44
|
+
src/subgroups.cpp
|
|
45
|
+
src/symmetrize.cpp
|
|
46
|
+
src/displacements.cpp
|
|
47
|
+
src/c_api.cpp
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if(MOLSYMM_BUILD_SHARED)
|
|
51
|
+
add_library(molsymm SHARED ${MOLSYMM_SOURCES})
|
|
52
|
+
else()
|
|
53
|
+
add_library(molsymm STATIC ${MOLSYMM_SOURCES})
|
|
54
|
+
endif()
|
|
55
|
+
|
|
56
|
+
add_library(molsymm::molsymm ALIAS molsymm)
|
|
57
|
+
|
|
58
|
+
target_include_directories(molsymm
|
|
59
|
+
PUBLIC
|
|
60
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
61
|
+
$<INSTALL_INTERFACE:include>
|
|
62
|
+
)
|
|
63
|
+
target_link_libraries(molsymm PUBLIC Eigen3::Eigen)
|
|
64
|
+
# Treat Eigen headers as system includes so -Werror does not fire inside them.
|
|
65
|
+
get_target_property(_molsymm_eigen_inc Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
|
|
66
|
+
if(_molsymm_eigen_inc)
|
|
67
|
+
target_include_directories(molsymm SYSTEM PUBLIC ${_molsymm_eigen_inc})
|
|
68
|
+
endif()
|
|
69
|
+
target_compile_features(molsymm PUBLIC cxx_std_20)
|
|
70
|
+
# Needed when a static core is linked into the Python extension module.
|
|
71
|
+
set_target_properties(molsymm PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
72
|
+
|
|
73
|
+
function(molsymm_set_warnings target)
|
|
74
|
+
if(MSVC)
|
|
75
|
+
target_compile_options(${target} PRIVATE /W4 /WX)
|
|
76
|
+
else()
|
|
77
|
+
target_compile_options(${target} PRIVATE
|
|
78
|
+
-Wall -Wextra -Wpedantic -Wshadow -Werror
|
|
79
|
+
)
|
|
80
|
+
endif()
|
|
81
|
+
endfunction()
|
|
82
|
+
|
|
83
|
+
molsymm_set_warnings(molsymm)
|
|
84
|
+
|
|
85
|
+
if(NOT DEFINED SKBUILD)
|
|
86
|
+
include(GNUInstallDirs)
|
|
87
|
+
install(TARGETS molsymm
|
|
88
|
+
EXPORT MolsymmTargets
|
|
89
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
90
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
91
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
92
|
+
)
|
|
93
|
+
install(DIRECTORY include/molsymm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
94
|
+
install(EXPORT MolsymmTargets
|
|
95
|
+
FILE MolsymmTargets.cmake
|
|
96
|
+
NAMESPACE molsymm::
|
|
97
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Molsymm
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
include(CMakePackageConfigHelpers)
|
|
101
|
+
write_basic_package_version_file(
|
|
102
|
+
"${CMAKE_CURRENT_BINARY_DIR}/MolsymmConfigVersion.cmake"
|
|
103
|
+
VERSION ${PROJECT_VERSION}
|
|
104
|
+
COMPATIBILITY SameMajorVersion
|
|
105
|
+
)
|
|
106
|
+
configure_file(
|
|
107
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/MolsymmConfig.cmake.in"
|
|
108
|
+
"${CMAKE_CURRENT_BINARY_DIR}/MolsymmConfig.cmake"
|
|
109
|
+
@ONLY
|
|
110
|
+
)
|
|
111
|
+
install(FILES
|
|
112
|
+
"${CMAKE_CURRENT_BINARY_DIR}/MolsymmConfig.cmake"
|
|
113
|
+
"${CMAKE_CURRENT_BINARY_DIR}/MolsymmConfigVersion.cmake"
|
|
114
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Molsymm
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
configure_file(
|
|
118
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/molsymm.pc.in"
|
|
119
|
+
"${CMAKE_CURRENT_BINARY_DIR}/molsymm.pc"
|
|
120
|
+
@ONLY
|
|
121
|
+
)
|
|
122
|
+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/molsymm.pc"
|
|
123
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
|
124
|
+
)
|
|
125
|
+
endif()
|
|
126
|
+
|
|
127
|
+
if(MOLSYMM_BUILD_TESTS)
|
|
128
|
+
enable_testing()
|
|
129
|
+
add_executable(molsymm_tests tests/test_main.cpp)
|
|
130
|
+
target_link_libraries(molsymm_tests PRIVATE molsymm)
|
|
131
|
+
molsymm_set_warnings(molsymm_tests)
|
|
132
|
+
target_compile_definitions(molsymm_tests PRIVATE
|
|
133
|
+
MOLSYMM_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/data"
|
|
134
|
+
)
|
|
135
|
+
add_test(NAME molsymm_tests COMMAND molsymm_tests)
|
|
136
|
+
endif()
|
|
137
|
+
|
|
138
|
+
if(NOT DEFINED SKBUILD)
|
|
139
|
+
add_executable(analyze_xyz examples/analyze_xyz.cpp)
|
|
140
|
+
target_link_libraries(analyze_xyz PRIVATE molsymm)
|
|
141
|
+
molsymm_set_warnings(analyze_xyz)
|
|
142
|
+
endif()
|
|
143
|
+
|
|
144
|
+
if(MOLSYMM_BUILD_PYTHON)
|
|
145
|
+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
|
|
146
|
+
find_package(nanobind CONFIG QUIET)
|
|
147
|
+
if(NOT nanobind_FOUND)
|
|
148
|
+
FetchContent_Declare(
|
|
149
|
+
nanobind
|
|
150
|
+
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
|
|
151
|
+
GIT_TAG v2.2.0
|
|
152
|
+
GIT_SHALLOW TRUE
|
|
153
|
+
)
|
|
154
|
+
FetchContent_MakeAvailable(nanobind)
|
|
155
|
+
endif()
|
|
156
|
+
nanobind_add_module(molsymm_py python/molsymm.cpp)
|
|
157
|
+
target_link_libraries(molsymm_py PRIVATE molsymm)
|
|
158
|
+
set_target_properties(molsymm_py PROPERTIES OUTPUT_NAME molsymm)
|
|
159
|
+
# Nanobind headers trip -Wshadow/-Wpedantic; keep first-party warning set on C++ targets only.
|
|
160
|
+
if(MOLSYMM_BUILD_TESTS)
|
|
161
|
+
# Some interpreters (e.g. conda) ship an older libstdc++ via RPATH that cannot
|
|
162
|
+
# load a library built with the system g++. Preload the compiler's libstdc++.
|
|
163
|
+
execute_process(
|
|
164
|
+
COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.so.6
|
|
165
|
+
OUTPUT_VARIABLE _molsymm_libstdcxx
|
|
166
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
167
|
+
)
|
|
168
|
+
get_filename_component(_molsymm_libstdcxx_real "${_molsymm_libstdcxx}" REALPATH)
|
|
169
|
+
add_test(
|
|
170
|
+
NAME molsymm_python_test
|
|
171
|
+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_python.py
|
|
172
|
+
)
|
|
173
|
+
set_tests_properties(molsymm_python_test PROPERTIES
|
|
174
|
+
ENVIRONMENT "PYTHONPATH=$<TARGET_FILE_DIR:molsymm_py>;MOLSYMM_TEST_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/data;LD_PRELOAD=${_molsymm_libstdcxx_real}"
|
|
175
|
+
)
|
|
176
|
+
endif()
|
|
177
|
+
if(DEFINED SKBUILD)
|
|
178
|
+
install(TARGETS molsymm_py LIBRARY DESTINATION . RUNTIME DESTINATION . ARCHIVE DESTINATION .)
|
|
179
|
+
endif()
|
|
180
|
+
endif()
|
|
181
|
+
|
|
182
|
+
if(MOLSYMM_BUILD_FORTRAN)
|
|
183
|
+
enable_language(Fortran)
|
|
184
|
+
add_library(molsymm_fortran STATIC fortran/molsymm.f90)
|
|
185
|
+
target_link_libraries(molsymm_fortran PUBLIC molsymm)
|
|
186
|
+
set_target_properties(molsymm_fortran PROPERTIES
|
|
187
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fortran_mod
|
|
188
|
+
)
|
|
189
|
+
target_include_directories(molsymm_fortran
|
|
190
|
+
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/fortran_mod
|
|
191
|
+
)
|
|
192
|
+
if(MOLSYMM_BUILD_TESTS)
|
|
193
|
+
add_executable(molsymm_fortran_test tests/test_fortran.f90)
|
|
194
|
+
target_link_libraries(molsymm_fortran_test PRIVATE molsymm_fortran)
|
|
195
|
+
add_test(NAME molsymm_fortran_test COMMAND molsymm_fortran_test)
|
|
196
|
+
endif()
|
|
197
|
+
endif()
|
libmolsymm-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 libmolsymm contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|