diff options
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/lz4/package.py | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/var/spack/repos/builtin/packages/lz4/package.py b/var/spack/repos/builtin/packages/lz4/package.py index 1a712b13b3..1cca43eab1 100644 --- a/var/spack/repos/builtin/packages/lz4/package.py +++ b/var/spack/repos/builtin/packages/lz4/package.py @@ -3,12 +3,15 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os import sys +from spack.build_systems.cmake import CMakeBuilder +from spack.build_systems.makefile import MakefileBuilder from spack.package import * -class Lz4(MakefilePackage): +class Lz4(CMakePackage, MakefilePackage): """LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core, scalable with multi-cores CPU. It also features an extremely fast decoder, with speed in multiple GB/s per core, @@ -28,6 +31,8 @@ class Lz4(MakefilePackage): depends_on("valgrind", type="test") + build_system("cmake", "makefile", default="cmake") + parallel = False if sys.platform == "win32" else True variant( "libs", default="shared,static", @@ -44,6 +49,39 @@ class Lz4(MakefilePackage): else: return "{0}/r{1}.tar.gz".format(url, version.joined) + def patch(self): + # Remove flags not recognized by the NVIDIA compiler + if self.spec.satisfies("%nvhpc@:20.11"): + filter_file("-fvisibility=hidden", "", "Makefile") + filter_file("-fvisibility=hidden", "", "lib/Makefile") + filter_file("-pedantic", "", "Makefile") + + @run_after("install") + def darwin_fix(self): + if sys.platform == "darwin": + fix_darwin_install_name(self.prefix.lib) + + +class CMakeBuilder(CMakeBuilder): + @property + def root_cmakelists_dir(self): + return os.path.join(super().root_cmakelists_dir, "build", "cmake") + + def cmake_args(self): + args = [] + # # no pic on windows + if "platform=windows" in self.spec: + args.append(self.define("LZ4_POSITION_INDEPENDENT_LIB", False)) + args.append( + self.define("BUILD_SHARED_LIBS", True if "libs=shared" in self.spec else False) + ) + args.append( + self.define("BUILD_STATIC_LIBS", True if "libs=static" in self.spec else False) + ) + return args + + +class MakefileBuilder(MakefileBuilder): def build(self, spec, prefix): par = True if spec.compiler.name == "nvhpc": @@ -63,15 +101,3 @@ class Lz4(MakefilePackage): "BUILD_SHARED={0}".format("yes" if "libs=shared" in self.spec else "no"), "BUILD_STATIC={0}".format("yes" if "libs=static" in self.spec else "no"), ) - - def patch(self): - # Remove flags not recognized by the NVIDIA compiler - if self.spec.satisfies("%nvhpc@:20.11"): - filter_file("-fvisibility=hidden", "", "Makefile") - filter_file("-fvisibility=hidden", "", "lib/Makefile") - filter_file("-pedantic", "", "Makefile") - - @run_after("install") - def darwin_fix(self): - if sys.platform == "darwin": - fix_darwin_install_name(self.prefix.lib) |