Skip to content

Commit

Permalink
Merge pull request #2120 from Flamefire/20200814155923_new_pr_QWUvONBFHF
Browse files Browse the repository at this point in the history
automatically add required -G Ninja when using CMakeNinja easyblock + add 'generator' custom easyconfig parameter for CMakeMake
  • Loading branch information
boegel authored Aug 19, 2020
2 parents 6c017b3 + 47f2b2b commit df9d8af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions easybuild/easyblocks/generic/cmakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def extra_options(extra_vars=None):
'build_type': [None, "Build type for CMake, e.g. Release."
"Defaults to 'Release' or 'Debug' depending on toolchainopts[debug]", CUSTOM],
'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM],
'generator': [None, "Build file generator to use. None to use CMakes default", CUSTOM],
'srcdir': [None, "Source directory location to provide to cmake command", CUSTOM],
'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM],
})
Expand Down Expand Up @@ -162,6 +163,9 @@ def configure_step(self, srcdir=None, builddir=None):
if self.toolchain.options['pic']:
options.append('-DCMAKE_POSITION_INDEPENDENT_CODE=ON')

if self.cfg['generator']:
options.append('-G "%s"' % self.cfg['generator'])

# Set flag for shared libs if requested
# Not adding one allows the project to choose a default
build_shared_libs = self.cfg.get('build_shared_libs')
Expand Down
7 changes: 7 additions & 0 deletions easybuild/easyblocks/generic/cmakeninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
class CMakeNinja(CMakeMake, MesonNinja):
"""Support for configuring with CMake, building and installing with MesonNinja."""

@staticmethod
def extra_options(extra_vars=None):
"""Define extra easyconfig parameters specific to CMakeMake."""
extra_vars = CMakeMake.extra_options(extra_vars)
extra_vars['generator'][0] = 'Ninja'
return extra_vars

def configure_step(self, *args, **kwargs):
"""Configure using CMake."""
CMakeMake.configure_step(self, *args, **kwargs)
Expand Down

0 comments on commit df9d8af

Please sign in to comment.