Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions easybuild/easyblocks/generic/cmakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def extra_options(extra_vars=None):
"Defaults to 'Release' or 'Debug' depending on toolchainopts[debug]", CUSTOM],
'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM],
'srcdir': [None, "Source directory location to provide to cmake command", CUSTOM],
'separate_build_dir': [False, "Perform build in a separate directory", CUSTOM],
'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM],
})
return extra_vars

Expand All @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
def lib_ext(self):
"""Return the extension for libraries build based on `build_shared_libs` or None if that is unset"""
if self._lib_ext is None:
build_shared_libs = self.cfg['build_shared_libs']
build_shared_libs = self.cfg.get('build_shared_libs')
if build_shared_libs:
self._lib_ext = get_shared_lib_ext()
elif build_shared_libs is not None:
Expand All @@ -108,7 +108,7 @@ def lib_ext(self, value):
@property
def build_type(self):
"""Build type set in the EasyConfig with default determined by toolchainopts"""
build_type = self.cfg['build_type']
build_type = self.cfg.get('build_type')
if build_type is None:
build_type = 'Debug' if self.toolchain.options.get('debug', None) else 'Release'
return build_type
Expand All @@ -118,7 +118,7 @@ def configure_step(self, srcdir=None, builddir=None):

setup_cmake_env(self.toolchain)

if builddir is None and self.cfg.get('separate_build_dir', False):
if builddir is None and self.cfg.get('separate_build_dir', True):
builddir = os.path.join(self.builddir, 'easybuild_obj')

if builddir:
Expand All @@ -130,14 +130,15 @@ def configure_step(self, srcdir=None, builddir=None):

if srcdir is None:
if self.cfg.get('srcdir', None) is not None:
srcdir = self.cfg['srcdir']
# Note that the join returns srcdir if it is absolute
srcdir = os.path.join(default_srcdir, self.cfg['srcdir'])
Comment thread
boegel marked this conversation as resolved.
else:
srcdir = default_srcdir

options = ['-DCMAKE_INSTALL_PREFIX=%s' % self.installdir]

if '-DCMAKE_BUILD_TYPE=' in self.cfg['configopts']:
if self.cfg['build_type'] is not None:
if self.cfg.get('build_type') is not None:
self.log.warning('CMAKE_BUILD_TYPE is set in configopts. Ignoring build_type')
else:
options.append('-DCMAKE_BUILD_TYPE=%s' % self.build_type)
Expand All @@ -148,7 +149,7 @@ def configure_step(self, srcdir=None, builddir=None):

# Set flag for shared libs if requested
# Not adding one allows the project to choose a default
build_shared_libs = self.cfg['build_shared_libs']
build_shared_libs = self.cfg.get('build_shared_libs')
if build_shared_libs is not None:
# Contrary to other options build_shared_libs takes precedence over configopts which may be unexpected.
# This is to allow self.lib_ext to be determined correctly.
Expand Down