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:
parent
118d8e4f57
commit
c59bebbff9
@ -3,10 +3,14 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# 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 *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
class Zstd(MakefilePackage):
|
class Zstd(CMakePackage, MakefilePackage):
|
||||||
"""Zstandard, or zstd as short version, is a fast lossless compression
|
"""Zstandard, or zstd as short version, is a fast lossless compression
|
||||||
algorithm, targeting real-time compression scenarios at zlib-level and
|
algorithm, targeting real-time compression scenarios at zlib-level and
|
||||||
better compression ratios."""
|
better compression ratios."""
|
||||||
@ -56,6 +60,34 @@ class Zstd(MakefilePackage):
|
|||||||
# (last tested: nvhpc@22.3)
|
# (last tested: nvhpc@22.3)
|
||||||
conflicts("+programs %nvhpc")
|
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):
|
def build(self, spec, prefix):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -65,7 +97,6 @@ def install(self, spec, prefix):
|
|||||||
# Tested %nvhpc@22.3. No support for -MP
|
# Tested %nvhpc@22.3. No support for -MP
|
||||||
if "%nvhpc" in self.spec:
|
if "%nvhpc" in self.spec:
|
||||||
args.append("DEPFLAGS=-MT $@ -MMD -MF")
|
args.append("DEPFLAGS=-MT $@ -MMD -MF")
|
||||||
|
|
||||||
# library targets
|
# library targets
|
||||||
lib_args = ["-C", "lib"] + args + ["install-pc", "install-includes"]
|
lib_args = ["-C", "lib"] + args + ["install-pc", "install-includes"]
|
||||||
if "libs=shared" in spec:
|
if "libs=shared" in spec:
|
||||||
@ -75,7 +106,6 @@ def install(self, spec, prefix):
|
|||||||
|
|
||||||
# install the library
|
# install the library
|
||||||
make(*lib_args)
|
make(*lib_args)
|
||||||
|
|
||||||
# install the programs
|
# install the programs
|
||||||
if "+programs" in spec:
|
if "+programs" in spec:
|
||||||
programs_args = ["-C", "programs"] + args
|
programs_args = ["-C", "programs"] + args
|
||||||
|
Loading…
Reference in New Issue
Block a user