Skip to content

Commit

Permalink
Merge branch 'openfoam_cgal' of github.com:bedroge/easybuild-easybloc…
Browse files Browse the repository at this point in the history
…ks into openfoam_cgal
  • Loading branch information
bedroge committed Jun 18, 2024
2 parents 0a1a5ce + 32d584a commit b94bc6e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion easybuild/easyblocks/o/openfoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
import shutil
import stat
import tempfile
import textwrap
from easybuild.tools import LooseVersion

import easybuild.tools.environment as env
import easybuild.tools.toolchain as toolchain
from easybuild.easyblocks.generic.cmakemake import setup_cmake_env
from easybuild.framework.easyblock import EasyBlock
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import adjust_permissions, apply_regex_substitutions, mkdir
from easybuild.tools.filetools import adjust_permissions, apply_regex_substitutions, mkdir, write_file
from easybuild.tools.modules import get_software_root, get_software_version
from easybuild.tools.run import run_cmd, run_cmd_qa
from easybuild.tools.systemtools import get_shared_lib_ext, get_cpu_architecture, AARCH64, POWER
Expand Down Expand Up @@ -293,6 +294,23 @@ def configure_step(self):
else:
env.setvar("%s_ROOT" % depend.upper(), dependloc)

if get_software_root('CGAL') and LooseVersion(get_software_version('CGAL')) >= LooseVersion('5.0'):
# CGAL >= 5.x is header-only, but when using it OpenFOAM still needs MPFR.
# It may fail to find it, so inject the right settings and paths into the "have_cgal" script.
have_cgal_script = os.path.join(self.builddir, self.openfoamdir, 'wmake', 'scripts', 'have_cgal')
if get_software_root('MPFR') and os.path.exists(have_cgal_script):
eb_cgal_config = textwrap.dedent('''
# Injected by EasyBuild
HAVE_CGAL=true
HAVE_MPFR=true
CGAL_FLAVOUR=header
CGAL_INC_DIR=${EBROOTCGAL}/include
CGAL_LIB_DIR=${EBROOTCGAL}/lib
MPFR_INC_DIR=${EBROOTMPFR}/include
MPFR_LIB_DIR=${EBROOTMPFR}/lib
''')
write_file(have_cgal_script, eb_cgal_config, append=True)

def build_step(self):
"""Build OpenFOAM using make after sourcing script to set environment."""

Expand Down

0 comments on commit b94bc6e

Please sign in to comment.