Skip to content

Commit cd668e0

Browse files
authored
Merge pull request ZimmermanGroup#48 from ZimmermanGroup/47-qchem-pixi-backend
Enable backend selection via environment variables for pixi builds
2 parents fbf4318 + 422a616 commit cd668e0

File tree

4 files changed

+69
-22
lines changed

4 files changed

+69
-22
lines changed

GSM/CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,66 @@
22
file(GLOB GSM_SRC "*.h" "*.cpp")
33
add_executable(gsm ${GSM_SRC})
44

5-
if(NOT DEFINED GSM_ENABLE_QCHEM)
5+
# Helper macro to check environment variable and set cmake variable
6+
# This allows setting backends via pixi.toml [package.build.config] env = { GSM_ENABLE_X = "1" }
7+
macro(check_env_backend VAR_NAME)
8+
if(DEFINED ENV{${VAR_NAME}} AND "$ENV{${VAR_NAME}}" STREQUAL "1")
9+
set(${VAR_NAME} 1)
10+
endif()
11+
endmacro()
12+
13+
# Check environment variables for backend selection (supports pixi-build-cmake env config)
14+
check_env_backend(GSM_ENABLE_QCHEM)
15+
check_env_backend(GSM_ENABLE_QCHEM_SF)
16+
check_env_backend(GSM_ENABLE_MOLPRO)
17+
check_env_backend(GSM_ENABLE_ASE)
18+
check_env_backend(GSM_ENABLE_GAUSSIAN)
19+
check_env_backend(GSM_ENABLE_ORCA)
20+
check_env_backend(GSM_ENABLE_TURBOMOLE)
21+
22+
if(NOT DEFINED GSM_ENABLE_QCHEM OR NOT GSM_ENABLE_QCHEM)
623
SET(GSM_ENABLE_QCHEM 0)
724
else()
825
set(CALCULATOR "qchem" CACHE STRING "Calculator")
926
set(CALCULATOR_FLAG "-DGSM_ENABLE_QCHEM=1 -DQCHEM=1")
10-
1127
endif()
1228

13-
if(NOT DEFINED GSM_ENABLE_QCHEM_SF)
29+
if(NOT DEFINED GSM_ENABLE_QCHEM_SF OR NOT GSM_ENABLE_QCHEM_SF)
1430
SET(GSM_ENABLE_QCHEM_SF 0)
1531
else()
1632
set(CALCULATOR "qchem_sf" CACHE STRING "Calculator")
1733
set(CALCULATOR_FLAG "-DGSM_ENABLE_QCHEM_SF=1 -DQCHEMSF=1")
1834
endif()
1935

20-
if(NOT DEFINED GSM_ENABLE_MOLPRO)
36+
if(NOT DEFINED GSM_ENABLE_MOLPRO OR NOT GSM_ENABLE_MOLPRO)
2137
SET(GSM_ENABLE_MOLPRO 0)
2238
else()
2339
set(CALCULATOR "molpro" CACHE STRING "Calculator")
2440
set(CALCULATOR_FLAG "-DGSM_ENABLE_MOLPRO=1 -DUSE_MOLPRO=1")
2541
endif()
2642

27-
if(NOT DEFINED GSM_ENABLE_ASE)
43+
if(NOT DEFINED GSM_ENABLE_ASE OR NOT GSM_ENABLE_ASE)
2844
SET(GSM_ENABLE_ASE 0)
2945
else()
3046
set(CALCULATOR "ase" CACHE STRING "Calculator")
3147
set(CALCULATOR_FLAG "-DGSM_ENABLE_ASE=1 -DUSE_ASE=1")
3248
endif()
3349

34-
if(NOT DEFINED GSM_ENABLE_GAUSSIAN)
50+
if(NOT DEFINED GSM_ENABLE_GAUSSIAN OR NOT GSM_ENABLE_GAUSSIAN)
3551
SET(GSM_ENABLE_GAUSSIAN 0)
3652
else()
3753
set(CALCULATOR "gaussian" CACHE STRING "Calculator")
3854
set(CALCULATOR_FLAG "-DGSM_ENABLE_GAUSSIAN=1 -DUSE_GAUSSIAN")
3955
endif()
4056

41-
if(NOT DEFINED GSM_ENABLE_ORCA)
57+
if(NOT DEFINED GSM_ENABLE_ORCA OR NOT GSM_ENABLE_ORCA)
4258
SET(GSM_ENABLE_ORCA 0)
4359
else()
4460
set(CALCULATOR "orca" CACHE STRING "Calculator")
4561
set(CALCULATOR_FLAG "-DGSM_ENABLE_ORCA=1 -DUSE_ORCA=1")
4662
endif()
4763

48-
if(NOT DEFINED GSM_ENABLE_TURBOMOLE)
64+
if(NOT DEFINED GSM_ENABLE_TURBOMOLE OR NOT GSM_ENABLE_TURBOMOLE)
4965
SET(GSM_ENABLE_TURBOMOLE 0)
5066
else()
5167
set(CALCULATOR "turbomole" CACHE STRING "Calculator")

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,56 @@ https://github.com/grimme-lab/xtb_docs/blob/master/source/gsm.rst
1717

1818
### Using Pixi (Recommended)
1919

20-
The easiest way to build and use GSM is with [Pixi](https://pixi.sh/), which handles core dependencies automatically:
20+
The easiest way to install GSM is with [Pixi](https://pixi.sh/), which handles all dependencies automatically.
2121

2222
1. [Install Pixi](https://pixi.sh/latest/#installation) if you haven't already
23-
2. Clone this repository:
23+
2. Install GSM globally:
2424
```bash
25-
git clone https://github.com/ZimmermanGroup/molecularGSM.git
26-
cd molecularGSM
25+
pixi global install \
26+
--git https://github.com/ZimmermanGroup/molecularGSM.git
27+
```
28+
29+
This builds GSM with MOPAC support (default) and makes `gsm` available in your PATH.
30+
31+
#### Building with Different Backends
32+
33+
To build with a different energy calculator backend, set the appropriate environment variable:
34+
35+
| Backend | Command |
36+
|---------|---------|
37+
| Q-Chem | `GSM_ENABLE_QCHEM=1 pixi global install --git ...` |
38+
| Q-Chem SF | `GSM_ENABLE_QCHEM_SF=1 pixi global install --git ...` |
39+
| ORCA | `GSM_ENABLE_ORCA=1 pixi global install --git ...` |
40+
| Gaussian | `GSM_ENABLE_GAUSSIAN=1 pixi global install --git ...` |
41+
| Molpro | `GSM_ENABLE_MOLPRO=1 pixi global install --git ...` |
42+
| ASE | `GSM_ENABLE_ASE=1 pixi global install --git ...` |
43+
| Turbomole | `GSM_ENABLE_TURBOMOLE=1 pixi global install --git ...` |
44+
45+
For example, to install with Q-Chem:
46+
```bash
47+
GSM_ENABLE_QCHEM=1 pixi global install \
48+
--git https://github.com/ZimmermanGroup/molecularGSM.git
2749
```
28-
3. Build and install GSM:
50+
51+
#### Development Setup
52+
53+
For development or to install from a local clone:
54+
2955
```bash
56+
git clone https://github.com/ZimmermanGroup/molecularGSM.git
57+
cd molecularGSM
3058
pixi install
3159
```
3260

33-
This will build GSM with MOPAC support and make the `gsm` executable available in the pixi environment. To run GSM:
61+
This makes the `gsm` executable available in the pixi environment:
3462
```bash
3563
pixi run gsm <input_number>
64+
pixi run test # run included test
3665
```
3766

38-
To run the included test:
67+
You can also install globally from the local path:
3968
```bash
40-
pixi run test
69+
pixi global install --path .
4170
```
4271

4372
### Using CMake (Manual Build)

pixi.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ libstdcxx-ng = "*"
2727
mkl = "*"
2828
mkl-include = "*"
2929

30+
[package.target.linux-64.run-dependencies]
31+
mkl = "*"
32+
3033
[package.target.osx-arm64.host-dependencies]
3134
openblas = "*"
3235

36+
[package.target.osx-arm64.run-dependencies]
37+
libopenblas = "*"
38+
3339
[dependencies]
3440
mopac = "*"
3541
gsm = {path = "."}
36-
37-
[target.linux-64.dependencies]
38-
mkl = "*"
39-
40-
[target.osx-arm64.dependencies]
41-
libopenblas = "*"

0 commit comments

Comments
 (0)