CMake: add a "build_type" variant (#21958)

This permits to use MinSizeRel or other build types
where they are a better fit.
This commit is contained in:
Harmen Stoppels 2021-02-26 09:49:00 +01:00 committed by GitHub
parent b13a506090
commit 27ef9f0e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,10 @@ class Cmake(Package):
version('3.0.2', sha256='6b4ea61eadbbd9bec0ccb383c29d1f4496eacc121ef7acf37c7a24777805693e') version('3.0.2', sha256='6b4ea61eadbbd9bec0ccb383c29d1f4496eacc121ef7acf37c7a24777805693e')
version('2.8.10.2', sha256='ce524fb39da06ee6d47534bbcec6e0b50422e18b62abc4781a4ba72ea2910eb1') version('2.8.10.2', sha256='ce524fb39da06ee6d47534bbcec6e0b50422e18b62abc4781a4ba72ea2910eb1')
variant('build_type', default='Release',
description='CMake build type',
values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel'))
# Revert the change that introduced a regression when parsing mpi link # Revert the change that introduced a regression when parsing mpi link
# flags, see: https://gitlab.kitware.com/cmake/cmake/issues/19516 # flags, see: https://gitlab.kitware.com/cmake/cmake/issues/19516
patch('cmake-revert-findmpi-link-flag-list.patch', when='@3.15.0') patch('cmake-revert-findmpi-link-flag-list.patch', when='@3.15.0')
@ -240,8 +244,8 @@ def bootstrap_args(self):
# Now for CMake arguments to pass after the initial bootstrap # Now for CMake arguments to pass after the initial bootstrap
args.append('--') args.append('--')
# Make sure to create an optimized release build args.append('-DCMAKE_BUILD_TYPE={0}'.format(
args.append('-DCMAKE_BUILD_TYPE=Release') self.spec.variants['build_type'].value))
# Install CMake correctly, even if `spack install` runs # Install CMake correctly, even if `spack install` runs
# inside a ctest environment # inside a ctest environment