|
41 | 41 | import shutil |
42 | 42 | import stat |
43 | 43 | import tempfile |
| 44 | +import textwrap |
44 | 45 | from easybuild.tools import LooseVersion |
45 | 46 |
|
46 | 47 | import easybuild.tools.environment as env |
47 | 48 | import easybuild.tools.toolchain as toolchain |
48 | 49 | from easybuild.easyblocks.generic.cmakemake import setup_cmake_env |
49 | 50 | from easybuild.framework.easyblock import EasyBlock |
50 | 51 | from easybuild.tools.build_log import EasyBuildError |
51 | | -from easybuild.tools.filetools import adjust_permissions, apply_regex_substitutions, mkdir |
| 52 | +from easybuild.tools.filetools import adjust_permissions, apply_regex_substitutions, mkdir, write_file |
52 | 53 | from easybuild.tools.modules import get_software_root, get_software_version |
53 | 54 | from easybuild.tools.run import run_cmd, run_cmd_qa |
54 | 55 | from easybuild.tools.systemtools import get_shared_lib_ext, get_cpu_architecture, AARCH64, POWER |
@@ -293,6 +294,23 @@ def configure_step(self): |
293 | 294 | else: |
294 | 295 | env.setvar("%s_ROOT" % depend.upper(), dependloc) |
295 | 296 |
|
| 297 | + if get_software_root('CGAL') and LooseVersion(get_software_version('CGAL')) >= LooseVersion('5.0'): |
| 298 | + # CGAL >= 5.x is header-only, but when using it OpenFOAM still needs MPFR. |
| 299 | + # It may fail to find it, so inject the right settings and paths into the "have_cgal" script. |
| 300 | + have_cgal_script = os.path.join(self.builddir, self.openfoamdir, 'wmake', 'scripts', 'have_cgal') |
| 301 | + if get_software_root('MPFR') and os.path.exists(have_cgal_script): |
| 302 | + eb_cgal_config = textwrap.dedent(''' |
| 303 | + # Injected by EasyBuild |
| 304 | + HAVE_CGAL=true |
| 305 | + HAVE_MPFR=true |
| 306 | + CGAL_FLAVOUR=header |
| 307 | + CGAL_INC_DIR=${EBROOTCGAL}/include |
| 308 | + CGAL_LIB_DIR=${EBROOTCGAL}/lib |
| 309 | + MPFR_INC_DIR=${EBROOTMPFR}/include |
| 310 | + MPFR_LIB_DIR=${EBROOTMPFR}/lib |
| 311 | + ''') |
| 312 | + write_file(have_cgal_script, eb_cgal_config, append=True) |
| 313 | + |
296 | 314 | def build_step(self): |
297 | 315 | """Build OpenFOAM using make after sourcing script to set environment.""" |
298 | 316 |
|
|
0 commit comments