Repository: spack/spack

Issue:
r-qtl: new package at 1.44-9



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/range-v3/package.py b/var/spack/repos/builtin/packages/range-v3/package.py
--- a/var/spack/repos/builtin/packages/range-v3/package.py
+++ b/var/spack/repos/builtin/packages/range-v3/package.py
@@ -5,6 +5,9 @@
 
 from spack import *
 
+import os
+import shutil
+
 
 class RangeV3(CMakePackage):
     """Range v3 forms the basis of a proposal to add range support to the
@@ -16,6 +19,7 @@ class RangeV3(CMakePackage):
     homepage = "https://github.com/ericniebler/range-v3"
     url      = "https://github.com/ericniebler/range-v3/archive/0.3.6.tar.gz"
     git      = "https://github.com/ericniebler/range-v3.git"
+    maintainers = ['chissg']
 
     version('develop', branch='master')
     version('0.5.0', sha256='32e30b3be042246030f31d40394115b751431d9d2b4e0f6d58834b2fd5594280')
@@ -41,6 +45,18 @@ class RangeV3(CMakePackage):
             multi=False,
             description='Use the specified C++ standard when building.')
 
+    variant('doc',
+            default=True,
+            description='Build and install documentation.')
+
+    variant('examples',
+            default=False,
+            description='Build and install examples.')
+
+    variant('perf',
+            default=False,
+            description='Build performance benchmarks')
+
     # Known compiler conflicts. Your favorite compiler may also conflict
     # depending on its C++ standard support.
     conflicts('%clang@:3.6.1')
@@ -49,10 +65,113 @@ class RangeV3(CMakePackage):
     conflicts('%gcc@:5.99.99', when='cxxstd=17')
 
     depends_on('cmake@3.6:', type='build')
-    depends_on('doxygen+graphviz', type='build')
+    depends_on('doxygen+graphviz', type='build', when='+doc')
+    depends_on('boost@1.59.0: cxxstd=14', type='build',
+               when='+examples cxxstd=14')
+    depends_on('boost@1.59.0: cxxstd=17', type='build',
+               when='+examples cxxstd=17')
+
+    # Fix reported upstream issue
+    # https://github.com/ericniebler/range-v3/issues/1196 per PR
+    # https://github.com/ericniebler/range-v3/pull/1202.
+    patch('fix-is_trivial.patch', level=1, when='@0.5.0')
+
+    # Some -Wno-... options unknown to GCC were being checked as OK to
+    # use but causing problems during the build. Patch from
+    # https://github.com/ericniebler/range-v3/commit/0c20dbf05973368339aeae0c4e106560e2dcf76b#diff-acb9169b4ccbac494ced5140d285a015
+    patch('gcc-compile-opt-check.patch', level=1, when='@0.5.0%gcc')
+
+    def _remove_cmake_subdir(self, subdir):
+        filter_file(r'^(\s*add_subdirectory\s*\(\s*{0}\s*\))'.format(subdir),
+                    r'#\1',
+                    'CMakeLists.txt')
+
+    # Deal with variant choices for versions that don't have applicable
+    # CMake switches.
+    def patch(self):
+        spec = self.spec
+        if spec.satisfies('@:0.3.0'):
+            if not self.run_tests:
+                self._remove_cmake_subdir('test')
+            if '+examples' not in spec:
+                self._remove_cmake_subdir('example')
+            if '+perf' not in spec:
+                self._remove_cmake_subdir('perf')
+        if spec.satisfies('@:0.3.6~doc'):
+            self._remove_cmake_subdir('doc')
 
     def cmake_args(self):
+        spec = self.spec
+        cxxstd = self.spec.variants['cxxstd'].value
+
+        on_or_off = lambda opt: 'ON' if '+' + opt in spec else 'OFF'
+
         args = [
-            '-DRANGES_CXX_STD={0}'.format(self.spec.variants['cxxstd'].value)
+            '-DRANGES_CXX_STD={0}'.format(cxxstd)
         ]
+
+        if spec.satisfies('@0.3.7:'):
+            args.append('-DRANGE_V3_DOCS=' + on_or_off('doc'))
+
+        if spec.satisfies('@0.3.6:'):
+            args.append('-DRANGE_V3_TESTS=' +
+                        ('ON' if self.run_tests else 'OFF'))
+            args.append('-DRANGE_V3_EXAMPLES=' + on_or_off('examples'))
+            args.append('-DRANGE_V3_PERF=' + on_or_off('perf'))
+        elif spec.satisfies('@0.3.1:'):
+            args.append('-DRANGE_V3_NO_TESTING=' +
+                        ('OFF' if self.run_tests else 'ON'))
+            args.append('-DRANGE_V3_NO_EXAMPLE=' +
+                        ('OFF' if '+examples' in spec else 'ON'))
+            args.append('-DRANGE_V3_NO_PERF=' +
+                        ('OFF' if '+perf' in spec else 'ON'))
+        else:
+            # Older versions don't have the right switches. See patch() above.
+            pass
+
+        if not self.run_tests:
+            args.append('-DRANGE_V3_NO_HEADER_CHECK=ON')
+
+        if '+examples' in spec:
+            args.append('-DRANGES_BUILD_CALENDAR_EXAMPLE=' +
+                        ('ON' if cxxstd in ['14', '17']
+                         else 'OFF'))
+
         return args
+
+    @property
+    def build_targets(self):
+        spec = self.spec
+        targets = []
+        if '+doc' in spec:
+            targets.extend(['all', 'doc'])
+        return targets
+
+    def _copy_and_clean_dirs(self, subdir):
+        install_tree(subdir, os.path.join(self.prefix, subdir))
+        with working_dir(self.build_directory):
+            install_tree(subdir, os.path.join(self.prefix, subdir))
+        with working_dir(os.path.join(self.prefix, subdir)):
+            shutil.rmtree('CMakeFiles')
+            for f in ('cmake_install.cmake', 'CTestTestfile.cmake',
+                      'Makefile', 'CMakeLists.txt'):
+                if os.path.exists(f):
+                    os.remove(f)
+
+    @run_after('install')
+    def install_extra(self):
+        spec = self.spec
+
+        # Install docs.
+        if '+doc' in spec:
+            with working_dir(self.build_directory):
+                install_tree(os.path.join('doc', 'html'),
+                             os.path.join(self.prefix, 'doc', 'html'))
+
+        # Install examples.
+        if '+examples' in spec:
+            self._copy_and_clean_dirs('example')
+
+        # Install performance benchmarks.
+        if '+perf' in spec:
+            self._copy_and_clean_dirs('perf')


Test patch: