From a0f2d6a8b920887adc4528f37ed83ab6d49d08a7 Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Wed, 26 Jun 2019 14:29:09 -0700 Subject: Make yaml-cpp build with libc++ (#10504) - Separate `yaml-cpp` tests into variant - Make conflict between `yaml-cpp` tests and `libc++` explicit --- .../repos/builtin/packages/yaml-cpp/package.py | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/yaml-cpp/package.py b/var/spack/repos/builtin/packages/yaml-cpp/package.py index ea93db09fb..5f47eab9c5 100644 --- a/var/spack/repos/builtin/packages/yaml-cpp/package.py +++ b/var/spack/repos/builtin/packages/yaml-cpp/package.py @@ -3,7 +3,10 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -from spack import * +from spack.spec import ConflictsInSpecError + + +yaml_cpp_tests_libcxx_error_msg = 'yaml-cpp tests incompatible with libc++' class YamlCpp(CMakePackage): @@ -21,6 +24,8 @@ class YamlCpp(CMakePackage): description='Enable build of shared libraries') variant('pic', default=True, description='Build with position independent code') + variant('tests', default=False, + description='Build yaml-cpp tests using internal gtest') depends_on('boost@:1.66.99', when='@:0.5.3') @@ -32,6 +37,25 @@ class YamlCpp(CMakePackage): conflicts('%intel@:11.1', when='@0.6.0:', msg="versions 0.6.0: require c++11 support") conflicts('%xl@:13.1', when='@0.6.0:', msg="versions 0.6.0: require c++11 support") conflicts('%xl_r@:13.1', when='@0.6.0:', msg="versions 0.6.0: require c++11 support") + conflicts('%clang cxxflags="-stdlib=libc++"', when='+tests', + msg=yaml_cpp_tests_libcxx_error_msg) + + def flag_handler(self, name, flags): + # We cannot catch all conflicts with the conflicts directive because + # the user can add arbitrary strings to the flags. Here we can at least + # fail early. + # We'll include cppflags in case users mistakenly put c++ flags there. + spec = self.spec + if name in ('cxxflags', 'cppflags') and spec.satisfies('+tests'): + if '-stdlib=libc++' in flags: + raise ConflictsInSpecError( + spec, + [(spec, + spec.compiler_flags[name], + spec.variants['tests'], + yaml_cpp_tests_libcxx_error_msg)] + ) + return (flags, None, None) def cmake_args(self): spec = self.spec @@ -42,6 +66,8 @@ class YamlCpp(CMakePackage): 'ON' if '+shared' in spec else 'OFF'), '-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=%s' % ( 'ON' if '+pic' in spec else 'OFF'), + '-DYAML_CPP_BUILD_TESTS:BOOL=%s' % ( + 'ON' if '+tests' in spec else 'OFF'), ]) return options -- cgit v1.2.3-70-g09d2