# IT4Innovations
# LK 2023

easyblock = "CMakeMake"

name = 'OpenBabel'
version = '3.1.1'

homepage = 'https://openbabel.org'
description = """Open Babel is a chemical toolbox designed to speak the many
 languages of chemical data. It's an open, collaborative project allowing anyone
 to search, convert, analyze, or store data from molecular modeling, chemistry,
 solid-state materials, biochemistry, or related areas."""

toolchain = {'name': 'gompi', 'version': '2022b'}
import os
if os.environ.get("CLUSTERNAME") in ["KAROLINA"]:
	toolchainopts = {'optarch': 'march=core-avx2'}
else:
	toolchainopts = {'optarch': False}

source_urls = [GITHUB_LOWER_SOURCE]
sources = ['%%(namelower)s-%s.tar.gz' % version.replace('.', '-')]
checksums = ['c97023ac6300d26176c97d4ef39957f06e68848d64f1a04b0b284ccff2744f02']

builddependencies = [
    ('CMake', '3.24.3'),
]
dependencies = [
    ('zlib', '1.2.12'),
    ('libxml2', '2.10.3'),
    ('Eigen', '3.4.0'),
    ('RapidJSON', '1.1.0'),
    ('cairo', '1.17.4'),  # optional: for .png output
    ('Boost', '1.81.0'),
    ('maeparser', '1.3.0'),
    ('CoordgenLibs', '3.0.1'),
]

configopts = '-DBoost_INCLUDE_DIR=$EBROOTBOOST/include -DBoost_LIBRARY_DIR_RELEASE=$EBROOTBOOST/lib '
configopts += '-DENABLE_OPENMP=ON '

# OpenBabel-3.1.1 creates directories named 3.1.0, which leads to BABEL_LIBDIR and BABEL_DATDIR
# (set in the easyblock) having invalid values.  Work around this with some symlinks.
postinstallcmds = [
    'ln -s %(installdir)s/lib/openbabel/3.1.0 %(installdir)s/lib/openbabel/%(version)s',
    'ln -s %(installdir)s/share/openbabel/3.1.0 %(installdir)s/share/openbabel/%(version)s',
]

runtest = 'test'

moduleclass = 'chem'