summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2023-03-20 17:39:19 -0400
committerGitHub <noreply@github.com>2023-03-20 14:39:19 -0700
commitfa0749bfb8f89bfe4c8124c22a211a39040f2d24 (patch)
tree11ccd78cc89a3dab9792c4ca6d24c7dcae2e9bbf
parentb431c4dc06ec0757b00b6f790be25b601f774a53 (diff)
downloadspack-fa0749bfb8f89bfe4c8124c22a211a39040f2d24.tar.gz
spack-fa0749bfb8f89bfe4c8124c22a211a39040f2d24.tar.bz2
spack-fa0749bfb8f89bfe4c8124c22a211a39040f2d24.tar.xz
spack-fa0749bfb8f89bfe4c8124c22a211a39040f2d24.zip
lz4: switch to CMake build (#35101)
Add support for building with CMake and make it the default build system on all platforms. By doing this, lz4 can now be built on Windows. The makefile-based build remains as an option.
-rw-r--r--var/spack/repos/builtin/packages/lz4/package.py52
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)