Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify various CMakeMake-based easyblocks by enhancing CMakeMake (w.r.t. CMAKE_BUILD_TYPE, shared vs static libs, fPIC) #1929

Merged
merged 24 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7289d42
Use CMakeMakes new buildtype property in other EBs
Flamefire Jan 14, 2020
9494d12
Set the defaults for out-of-source builds in extra_options for some C…
Flamefire Jan 15, 2020
930b409
[CMake] Honor pic in toolchainopts
Flamefire Jan 16, 2020
16ecc27
[CMake] Add build_shared_libs option
Flamefire Jan 16, 2020
e690596
[Dolfin] Remove superflous setting of compiler done in CMake EB
Flamefire Jan 16, 2020
b21f8cf
[CMakeMake] Default CMAKE_BUILD_TYPE based on toolchainopts[debug]
Flamefire Feb 27, 2020
97ef461
Make use of the new default for build_type in CMakeMake
Flamefire Feb 27, 2020
5c5ec8c
set self.lib_ext in CMakeMake constructor + fix ELSI & SuperLU easybl…
boegel Mar 30, 2020
da2ff2c
don't hard set build_type to 'Release' in Clang easyblock, leave that…
boegel Mar 30, 2020
46abdac
don't use 'if False' in DOLFIN easyblock, just comment out the code t…
boegel Mar 30, 2020
3d342e8
only let CMakeMake set -DCMAKE_BUILD_TYPE if it's not set in configop…
boegel Mar 30, 2020
411ae72
only set -DBUILD_SHARED_LIBS (via build_shared_libs easyconfig parame…
boegel Mar 30, 2020
8437552
remove debug print in ELSI easyblock
boegel Mar 30, 2020
0543481
use stricter pattern for checking for -DCMAKE_BUILD_TYPE= in configop…
boegel Mar 30, 2020
462e557
use stricter patterns for -DDBUILD_SHARED_LIBS= in LAMMPS easyblock
boegel Mar 30, 2020
2dee8a6
fix enabling build_shared_libs by default in ELSI easyblock
boegel Mar 30, 2020
5cb5cce
Merge pull request #2 from boegel/cmake_build_folder
Flamefire Mar 30, 2020
c69df05
Add warning if CMAKE_BUILD_TYPE and build_type is set
Flamefire Mar 30, 2020
d608b64
Warn about BUILD_SHARED_LIBS and build_shared_libs being both set
Flamefire Mar 30, 2020
8d170cc
[Clang] Set build type for stage N>0
Flamefire Mar 30, 2020
949e0dd
[Lammps] Use correct default for separate_build_dir
Flamefire Mar 30, 2020
777eb2e
[OpenBabel] remove empty newline after method
Flamefire Mar 30, 2020
d8efcc5
[Trilinos] Set build_shared_libs in ctor
Flamefire Mar 30, 2020
f4df495
Make lib_ext a property of CMakeMake
Flamefire Mar 30, 2020
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
7 changes: 7 additions & 0 deletions easybuild/easyblocks/a/armadillo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
class EB_Armadillo(CMakeMake):
"""Support for building Armadillo."""

@staticmethod
def extra_options():
"""Extra easyconfig parameters for Armadillo."""
extra_vars = CMakeMake.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def configure_step(self):
"""Set some extra environment variables before configuring."""

Expand Down
18 changes: 5 additions & 13 deletions easybuild/easyblocks/b/bamtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
@author: Andreas Panteli (The Cyprus Institute)
@author: Kenneth Hoste (Ghent University)
"""
import os
from distutils.version import LooseVersion
from easybuild.easyblocks.generic.cmakemake import CMakeMake
from easybuild.easyblocks.generic.makecp import MakeCp
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import mkdir
from easybuild.tools.systemtools import get_shared_lib_ext


Expand All @@ -45,23 +42,18 @@ class EB_BamTools(MakeCp, CMakeMake):
def extra_options(extra_vars=None):
"""Extra easyconfig parameters for BamTools."""
extra_vars = MakeCp.extra_options()
extra_vars.update(CMakeMake.extra_options())

# files_to_copy is not mandatory here, since we overwrite it in install_step
extra_vars['files_to_copy'][2] = CUSTOM
# BamTools requires an out of source build
extra_vars['separate_build_dir'][0] = True

return CMakeMake.extra_options(extra_vars=extra_vars)
return extra_vars

def configure_step(self):
"""Configure BamTools build."""
# BamTools requires an out of source build.
builddir = os.path.join(self.cfg['start_dir'], 'build')
try:
mkdir(builddir)
os.chdir(builddir)
except OSError as err:
raise EasyBuildError("Failed to move to %s: %s", builddir, err)

CMakeMake.configure_step(self, srcdir='..')
CMakeMake.configure_step(self)

def install_step(self):
"""Custom installation procedure for BamTools."""
Expand Down
9 changes: 6 additions & 3 deletions easybuild/easyblocks/b/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
class EB_Blender(CMakeMake):
"""Support for building Blender."""

@staticmethod
def extra_options():
extra_vars = CMakeMake.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def find_glob_pattern(self, glob_pattern):
"""Find unique file/dir matching glob_pattern (raises error if more than one match is found)"""
if self.dry_run:
Expand All @@ -50,11 +56,8 @@ def find_glob_pattern(self, glob_pattern):

def configure_step(self):
"""Set CMake options for Blender"""
self.cfg['separate_build_dir'] = True

default_config_opts = {
'CMAKE_CXX_FLAGS_RELEASE': '-DNDEBUG',
'CMAKE_C_FLAGS_RELEASE': '-DNDEBUG',
'WITH_BUILDINFO': 'OFF',
# disable SSE detection to give EasyBuild full control over optimization compiler flags being used
'WITH_CPU_SSE': 'OFF',
Expand Down
6 changes: 6 additions & 0 deletions easybuild/easyblocks/c/cgal.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
class EB_CGAL(CMakeMake):
"""Support for building CGAL."""

@staticmethod
def extra_options():
extra_vars = CMakeMake.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def configure_step(self):
"""Set some extra environment variables before configuring."""

Expand Down
12 changes: 7 additions & 5 deletions easybuild/easyblocks/c/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class EB_Clang(CMakeMake):

@staticmethod
def extra_options():
extra_vars = {
extra_vars = CMakeMake.extra_options()
extra_vars.update({
'assertions': [True, "Enable assertions. Helps to catch bugs in Clang.", CUSTOM],
'build_targets': [None, "Build targets for LLVM (host architecture if None). Possible values: " +
', '.join(CLANG_TARGETS), CUSTOM],
Expand All @@ -84,9 +85,10 @@ def extra_options():
'skip_all_tests': [False, "Skip running of tests", CUSTOM],
# The sanitizer tests often fail on HPC systems due to the 'weird' environment.
'skip_sanitizer_tests': [True, "Do not run the sanitizer tests", CUSTOM],
}

return CMakeMake.extra_options(extra_vars)
})
# disable regular out-of-source build, too simplistic for Clang to work
extra_vars['separate_build_dir'][0] = False
return extra_vars

def __init__(self, *args, **kwargs):
"""Initialize custom class variables for Clang."""
Expand Down Expand Up @@ -226,7 +228,6 @@ def configure_step(self):
self.log.debug("Using %s as GCC_INSTALL_PREFIX", gcc_prefix)

# Configure some default options
self.cfg.update('configopts', "-DCMAKE_BUILD_TYPE=Release")
if self.cfg["enable_rtti"]:
self.cfg.update('configopts', '-DLLVM_REQUIRES_RTTI=ON')
self.cfg.update('configopts', '-DLLVM_ENABLE_RTTI=ON')
Expand Down Expand Up @@ -332,6 +333,7 @@ def build_with_prev_stage(self, prev_obj, next_obj):
options += "-DCMAKE_C_COMPILER='%s' " % CC
options += "-DCMAKE_CXX_COMPILER='%s' " % CXX
options += self.cfg['configopts']
options += "-DCMAKE_BUILD_TYPE=%s" % self.build_type

self.log.info("Configuring")
run_cmd("cmake %s %s" % (options, self.llvm_src_dir), log_all=True)
Expand Down
11 changes: 7 additions & 4 deletions easybuild/easyblocks/d/dirac.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import tempfile

import easybuild.tools.environment as env
import easybuild.tools.toolchain as toolchain
from easybuild.easyblocks.generic.cmakemake import CMakeMake
from easybuild.framework.easyconfig import CUSTOM, MANDATORY
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import build_option
from easybuild.tools.run import run_cmd
Expand All @@ -42,6 +40,12 @@
class EB_DIRAC(CMakeMake):
"""Support for building/installing DIRAC."""

@staticmethod
def extra_options():
extra_vars = CMakeMake.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def configure_step(self):
"""Custom configuration procedure for DIRAC."""

Expand All @@ -53,8 +57,7 @@ def configure_step(self):
except OSError as err:
raise EasyBuildError("Failed to remove existing install directory %s: %s", self.installdir, err)

self.cfg['separate_build_dir'] = True
self.cfg.update('configopts', "-DENABLE_MPI=ON -DCMAKE_BUILD_TYPE=release")
self.cfg.update('configopts', "-DENABLE_MPI=ON")

# complete configuration with configure_method of parent
super(EB_DIRAC, self).configure_step()
Expand Down
31 changes: 14 additions & 17 deletions easybuild/easyblocks/d/dolfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@
class EB_DOLFIN(CMakePythonPackage):
"""Support for building and installing DOLFIN."""

@staticmethod
def extra_options():
extra_vars = CMakePythonPackage.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def __init__(self, *args, **kwargs):
"""Initialize class variables."""
super(EB_DOLFIN, self).__init__(*args, **kwargs)

self.boost_dir = None
self.saved_configopts = None
self.cfg['separate_build_dir'] = True

def configure_step(self):
"""Set DOLFIN-specific configure options and configure with CMake."""

shlib_ext = get_shared_lib_ext()

# compilers
self.cfg.update('configopts', "-DCMAKE_C_COMPILER='%s' " % os.getenv('CC'))
self.cfg.update('configopts', "-DCMAKE_CXX_COMPILER='%s' " % os.getenv('CXX'))
self.cfg.update('configopts', "-DCMAKE_Fortran_COMPILER='%s' " % os.getenv('F90'))

# compiler flags
cflags = os.getenv('CFLAGS')
cxxflags = os.getenv('CXXFLAGS')
Expand All @@ -80,17 +80,14 @@ def configure_step(self):
self.cfg.update('configopts', '-DCMAKE_CXX_FLAGS="%s"' % cxxflags)
self.cfg.update('configopts', '-DCMAKE_Fortran_FLAGS="%s"' % fflags)

# run cmake in debug mode
self.cfg.update('configopts', '-DCMAKE_BUILD_TYPE=Debug')

# set correct compilers to be used at runtime
self.cfg.update('configopts', '-DMPI_C_COMPILER="$MPICC"')
self.cfg.update('configopts', '-DMPI_CXX_COMPILER="$MPICXX"')

# specify MPI library
self.cfg.update('configopts', '-DMPI_COMPILER="%s"' % os.getenv('MPICC'))

if os.getenv('MPI_LIB_SHARED') and os.getenv('MPI_INC_DIR'):
if os.getenv('MPI_LIB_SHARED') and os.getenv('MPI_INC_DIR'):
self.cfg.update('configopts', '-DMPI_LIBRARY="%s"' % os.getenv('MPI_LIB_SHARED'))
self.cfg.update('configopts', '-DMPI_INCLUDE_PATH="%s"' % os.getenv('MPI_INC_DIR'))
else:
Expand Down Expand Up @@ -126,7 +123,7 @@ def configure_step(self):
if not deproot:
raise EasyBuildError("Dependency %s not available.", dep)
else:
depsdict.update({dep:deproot})
depsdict.update({dep: deproot})

# zlib
self.cfg.update('configopts', '-DZLIB_INCLUDE_DIR=%s' % os.path.join(depsdict['zlib'], "include"))
Expand Down Expand Up @@ -173,7 +170,7 @@ def configure_step(self):
'-DCOLAMD_LIBRARY:PATH="%(sp)s/COLAMD/lib/libcolamd.a"'
]

self.cfg.update('configopts', ' '.join(umfpack_params) % {'sp':suitesparse})
self.cfg.update('configopts', ' '.join(umfpack_params) % {'sp': suitesparse})

# ParMETIS and SCOTCH
self.cfg.update('configopts', '-DPARMETIS_DIR="%s"' % depsdict['ParMETIS'])
Expand Down Expand Up @@ -272,13 +269,13 @@ def test_step(self):
# exclude Python tests for now, because they 'hang' sometimes (unclear why)
# they can be reinstated once run_cmd (or its equivalent) has support for timeouts
# see https://github.com/easybuilders/easybuild-framework/issues/581
#for (tmpl, subdir) in [(cmd_template_python, 'python'), (cmd_template_cpp, 'cpp')]]
# for (tmpl, subdir) in [(cmd_template_python, 'python'), (cmd_template_cpp, 'cpp')]

# subdomains-poisson has no C++ get_version, only Python
# Python tests excluded, see above
#name = 'subdomains-poisson'
#path = os.path.join('demo', 'pde', name, 'python')
#cmds += [cmd_template_python % {'dir': path, 'name': name}]
# name = 'subdomains-poisson'
# path = os.path.join('demo', 'pde', name, 'python')
# cmds += [cmd_template_python % {'dir': path, 'name': name}]

# supply empty argument to each command
for cmd in cmds:
Expand Down Expand Up @@ -351,7 +348,7 @@ def sanity_check_step(self):
# custom sanity check paths
custom_paths = {
'files': ['bin/dolfin-%s' % x for x in ['version', 'convert', 'order', 'plot']] + ['include/dolfin.h'],
'dirs':['%s/dolfin' % self.pylibdir],
'dirs': ['%s/dolfin' % self.pylibdir],
}

super(EB_DOLFIN, self).sanity_check_step(custom_paths=custom_paths)
7 changes: 6 additions & 1 deletion easybuild/easyblocks/e/eigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ class EB_Eigen(CMakeMake):
Support for building Eigen.
"""

@staticmethod
def extra_options():
extra_vars = CMakeMake.extra_options()
extra_vars['separate_build_dir'][0] = True
return extra_vars

def configure_step(self):
"""Custom configuration procedure for Eigen."""
# start using CMake for Eigen 3.3.4 and newer versions
# not done for older versions, since this implies using CMake as a build dependency,
# which is a bit strange for a header-only library like Eigen...
if LooseVersion(self.version) >= LooseVersion('3.3.4'):
self.cfg['separate_build_dir'] = True
# avoid that include files are installed into include/eigen3/Eigen, should be include/Eigen
self.cfg.update('configopts', "-DINCLUDE_INSTALL_DIR=%s" % os.path.join(self.installdir, 'include'))
CMakeMake.configure_step(self)
Expand Down
21 changes: 9 additions & 12 deletions easybuild/easyblocks/e/elsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,16 @@ def __init__(self, *args, **kwargs):
@staticmethod
def extra_options():
"""Define custom easyconfig parameters for ELSI."""
extra_vars = {
extra_vars = CMakeMake.extra_options()
extra_vars.update({
'build_internal_pexsi': [None, "Build internal PEXSI solver", CUSTOM],
'build_shared_libs': [True, "Build shared libraries instead of static", CUSTOM],
}
return CMakeMake.extra_options(extra_vars)
})
extra_vars['separate_build_dir'][0] = True
extra_vars['build_shared_libs'][0] = True
return extra_vars

def configure_step(self):
"""Custom configure procedure for ELSI."""

self.cfg['separate_build_dir'] = True

if self.cfg['build_shared_libs']:
self.cfg.update('configopts', "-DBUILD_SHARED_LIBS=ON")

if self.cfg['runtest']:
self.cfg.update('configopts', "-DENABLE_TESTS=ON")
self.cfg.update('configopts', "-DENABLE_C_TESTS=ON")
Expand Down Expand Up @@ -149,10 +145,11 @@ def sanity_check_step(self):
modules.append('elsi_sips')
libs.append('sips')

libext = get_shared_lib_ext() if self.cfg['build_shared_libs'] else 'a'
Flamefire marked this conversation as resolved.
Show resolved Hide resolved
# follow self.lib_ext set by CMakeMake (based on build_shared_libs), fall back to .a (static libs by default)
lib_ext = self.lib_ext or 'a'

module_paths = [os.path.join('include', '%s.mod' % mod) for mod in modules]
lib_paths = [os.path.join('lib', 'lib%s.%s' % (lib, libext)) for lib in libs]
lib_paths = [os.path.join('lib', 'lib%s.%s' % (lib, lib_ext)) for lib in libs]

custom_paths = {
'files': module_paths + lib_paths,
Expand Down
9 changes: 6 additions & 3 deletions easybuild/easyblocks/g/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ class EB_GATE(CMakeMake):

@staticmethod
def extra_options():
extra_vars = {
extra_vars = CMakeMake.extra_options()
extra_vars.update({
'default_platform': ['openPBS', "Default cluster platform to set", CUSTOM],
}
return CMakeMake.extra_options(extra_vars)
})
# Out of source build doesn't work due to sub tools beeing 'make'd
extra_vars['separate_build_dir'][0] = False
return extra_vars

def __init__(self, *args, **kwargs):
"""Initialise class variables."""
Expand Down
13 changes: 7 additions & 6 deletions easybuild/easyblocks/g/geant4.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ def extra_options():
"""
Define extra options needed by Geant4
"""
extra_vars = {
extra_vars = CMakeMake.extra_options()
extra_vars.update({
'G4ABLAVersion': [None, "G4ABLA version", CUSTOM],
'G4NDLVersion': [None, "G4NDL version", CUSTOM],
'G4EMLOWVersion': [None, "G4EMLOW version", CUSTOM],
'PhotonEvaporationVersion': [None, "PhotonEvaporation version", CUSTOM],
'G4RadioactiveDecayVersion': [None, "G4RadioactiveDecay version", CUSTOM],
}
return CMakeMake.extra_options(extra_vars)
})
# Requires out-of-source build
extra_vars['separate_build_dir'][0] = True
return extra_vars

def __init__(self, *args, **kwargs):
"""Initialisation of custom class variables for Geant4."""
Expand All @@ -80,9 +83,7 @@ def configure_step(self):

# Geant4 switched to a CMake build system in version 9.4
if LooseVersion(self.version) >= LooseVersion("9.4"):
mkdir('configdir')
os.chdir('configdir')
super(EB_Geant4, self).configure_step(srcdir="..")
super(EB_Geant4, self).configure_step()

else:
pwd = self.cfg['start_dir']
Expand Down
Loading