zstd package: add Cmake build (#35104)

* This enables building zstd on Windows
* CMake is now the default for all systems
This commit is contained in:
John W. Parent 2023-03-23 19:58:12 -04:00 committed by GitHub
parent 118d8e4f57
commit c59bebbff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,14 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack.build_systems.cmake import CMakeBuilder
from spack.build_systems.makefile import MakefileBuilder
from spack.package import *
class Zstd(MakefilePackage):
class Zstd(CMakePackage, MakefilePackage):
"""Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level and
better compression ratios."""
@ -56,6 +60,34 @@ class Zstd(MakefilePackage):
# (last tested: nvhpc@22.3)
conflicts("+programs %nvhpc")
build_system("cmake", "makefile", default="cmake")
class CMakeBuilder(CMakeBuilder):
@property
def root_cmakelists_dir(self):
return os.path.join(super().root_cmakelists_dir, "build", "cmake")
def cmake_args(self):
spec = self.spec
args = []
args.append(self.define_from_variant("ZSTD_BUILD_PROGRAMS", "programs"))
args.extend(
[
self.define("ZSTD_BUILD_STATIC", self.spec.satisfies("libs=static")),
self.define("ZSTD_BUILD_SHARED", self.spec.satisfies("libs=shared")),
]
)
if "compression=zlib" in spec:
args.append(self.define("ZSTD_ZLIB_SUPPORT", True))
if "compression=lzma" in spec:
args.append(self.define("ZSTD_LZMA_SUPPORT", True))
if "compression=lz4" in spec:
args.append(self.define("ZSTD_LZ4_SUPPORT", True))
return args
class MakefileBuilder(MakefileBuilder):
def build(self, spec, prefix):
pass
@ -65,7 +97,6 @@ def install(self, spec, prefix):
# Tested %nvhpc@22.3. No support for -MP
if "%nvhpc" in self.spec:
args.append("DEPFLAGS=-MT $@ -MMD -MF")
# library targets
lib_args = ["-C", "lib"] + args + ["install-pc", "install-includes"]
if "libs=shared" in spec:
@ -75,7 +106,6 @@ def install(self, spec, prefix):
# install the library
make(*lib_args)
# install the programs
if "+programs" in spec:
programs_args = ["-C", "programs"] + args