From 07aec4366fa8926ee896fdb2f0c5a68dad3267b5 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 25 Jul 2017 18:34:43 -0500 Subject: Add universal build_type variant to CMakePackage (#4797) * Add universal build_type variant to CMakePackage * Override build_type in some packages with different possible values * Remove reference to no longer existent debug variant * Update CBTF packages with new build_type variant * Keep note on build size of LLVM --- lib/spack/spack/build_systems/cmake.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index b339858348..db3240e8a5 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -29,7 +29,7 @@ import platform import spack.build_environment from llnl.util.filesystem import working_dir, join_path -from spack.directives import depends_on +from spack.directives import depends_on, variant from spack.package import PackageBase, run_after @@ -49,11 +49,6 @@ class CMakePackage(PackageBase): +-----------------------------------------------+--------------------+ | **Method** | **Purpose** | +===============================================+====================+ - | :py:meth:`~.CMakePackage.build_type` | Specify the value | - | | for the | - | | CMAKE_BUILD_TYPE | - | | variable | - +-----------------------------------------------+--------------------+ | :py:meth:`~.CMakePackage.root_cmakelists_dir` | Location of the | | | root CMakeLists.txt| +-----------------------------------------------+--------------------+ @@ -74,14 +69,12 @@ class CMakePackage(PackageBase): build_time_test_callbacks = ['check'] - depends_on('cmake', type='build') - - def build_type(self): - """Returns the correct value for the ``CMAKE_BUILD_TYPE`` variable + # https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html + variant('build_type', default='RelWithDebInfo', + description='The build type to build', + values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel')) - :return: value for ``CMAKE_BUILD_TYPE`` - """ - return 'RelWithDebInfo' + depends_on('cmake', type='build') @property def root_cmakelists_dir(self): @@ -108,8 +101,8 @@ class CMakePackage(PackageBase): def _std_args(pkg): """Computes the standard cmake arguments for a generic package""" try: - build_type = pkg.build_type() - except AttributeError: + build_type = pkg.spec.variants['build_type'].value + except KeyError: build_type = 'RelWithDebInfo' args = ['-DCMAKE_INSTALL_PREFIX:PATH={0}'.format(pkg.prefix), -- cgit v1.2.3-60-g2f50