diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/boost/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/boost/package.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index 5666df8baa..db72c06212 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -126,6 +126,11 @@ class Boost(Package): variant(lib, default=(lib not in default_noinstall_libs), description="Compile with {0} library".format(lib)) + variant('cxxstd', + default='default', + values=('default', '98', '11', '14', '17'), + multi=False, + description='Use the specified C++ standard when building.') variant('debug', default=False, description='Switch to the debug version of Boost') variant('shared', default=True, @@ -250,6 +255,26 @@ class Boost(Package): if '+python' in spec: f.write(self.bjam_python_line(spec)) + def cxxstd_to_flag(self, std): + flag = '' + if self.spec.variants['cxxstd'].value == '98': + flag = self.compiler.cxx98_flag + elif self.spec.variants['cxxstd'].value == '11': + flag = self.compiler.cxx11_flag + elif self.spec.variants['cxxstd'].value == '14': + flag = self.compiler.cxx14_flag + elif self.spec.variants['cxxstd'].value == '17': + flag = self.compiler.cxx17_flag + elif self.spec.variants['cxxstd'].value == 'default': + # Let the compiler do what it usually does. + pass + else: + # The user has selected a (new?) legal value that we've + # forgotten to deal with here. + tty.die("INTERNAL ERROR: cannot accommodate unexpected variant ", + "cxxstd={0}".format(spec.variants['cxxstd'].value)) + return flag + def determine_b2_options(self, spec, options): if '+debug' in spec: options.append('variant=debug') @@ -299,6 +324,17 @@ class Boost(Package): 'toolset=%s' % self.determine_toolset(spec) ]) + # Other C++ flags. + cxxflags = [] + + # Deal with C++ standard. + if spec.satisfies('@1.66:'): + options.append('cxxstd={0}'.format(spec.variants['cxxstd'].value)) + else: # Add to cxxflags for older Boost. + flag = self.cxxstd_to_flag(spec.variants['cxxstd'].value) + if flag: + cxxflags.append(flag) + # clang is not officially supported for pre-compiled headers # and at least in clang 3.9 still fails to build # http://www.boost.org/build/doc/html/bbv2/reference/precompiled_headers.html @@ -306,10 +342,13 @@ class Boost(Package): if spec.satisfies('%clang'): options.extend(['pch=off']) if '+clanglibcpp' in spec: + cxxflags.append('-stdlib=libc++') options.extend(['toolset=clang', - 'cxxflags="-stdlib=libc++"', 'linkflags="-stdlib=libc++"']) + if cxxflags: + options.append('cxxflags="{0}"'.format(' '.join(cxxflags))) + return threadingOpts def add_buildopt_symlinks(self, prefix): |