Skip to content

Commit c5b6743

Browse files
committed
[CMakeMake] Remove build directory if it exists
without also ensuring that the directories that are used for that build are also unique there are build problems with bundles that contain more than one CMake package and didn’t explicitly set separate_build_dir to false This also applies partially to multiple iterations of the same software build (e.g. configopts) As the build directory is unique to EasyBuild it is save to remove
1 parent 54ec461 commit c5b6743

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

easybuild/easyblocks/generic/cmakemake.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from easybuild.framework.easyconfig import CUSTOM
4040
from easybuild.tools.build_log import print_warning
4141
from easybuild.tools.config import build_option
42-
from easybuild.tools.filetools import change_dir, mkdir, which
42+
from easybuild.tools.filetools import change_dir, mkdir, which, remove_dir
4343
from easybuild.tools.environment import setvar
4444
from easybuild.tools.modules import get_software_root
4545
from easybuild.tools.run import run_cmd
@@ -120,6 +120,12 @@ def configure_step(self, srcdir=None, builddir=None):
120120

121121
if builddir is None and self.cfg.get('separate_build_dir', True):
122122
builddir = os.path.join(self.builddir, 'easybuild_obj')
123+
# For separate_build_dir we want a clean folder. So remove if it exists
124+
# This can happen when multiple iterations are done (e.g. shared, static, ...)
125+
if os.path.exists(builddir):
126+
self.log.warning('Build directory %s already exists (from previous iterations?). Removing...',
127+
builddir)
128+
remove_dir(builddir)
123129

124130
if builddir:
125131
mkdir(builddir, parents=True)

0 commit comments

Comments
 (0)