diff --git a/easybuild/easyblocks/o/openfoam.py b/easybuild/easyblocks/o/openfoam.py index 2cd60f364c..f7f56c4223 100644 --- a/easybuild/easyblocks/o/openfoam.py +++ b/easybuild/easyblocks/o/openfoam.py @@ -292,6 +292,24 @@ def configure_step(self): env.setvar("BOOST_ROOT", get_software_root('Boost')) else: env.setvar("%s_ROOT" % depend.upper(), dependloc) + for dep in self.cfg.dependencies(): + # CGAL >= 5.x is header-only, but when using it OpenFOAM still needs MPFR and GMP. + # It may fail to find them, so inject the right settings and paths into the "have_cgal" script. + if dep['name'] == 'CGAL' and LooseVersion(dep['version']) >= LooseVersion('5.0'): + mpfr_root = get_software_root('MPFR') + gmp_root = get_software_root('GMP') + have_cgal_script = os.path.join(self.builddir, self.openfoamdir, 'wmake', 'scripts', 'have_cgal') + eb_cgal_config = ''' + # 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 + ''' + apply_regex_substitutions(have_cgal_script, [(r"^(esac)$", r"\1\n" + eb_cgal_config)]) def build_step(self): """Build OpenFOAM using make after sourcing script to set environment."""