summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_systems/cmake.py23
1 files changed, 8 insertions, 15 deletions
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),