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.
This commit is contained in:
parent
b431c4dc06
commit
fa0749bfb8
@ -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 @@ def url_for_version(self, version):
|
||||
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 @@ def install(self, spec, prefix):
|
||||
"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)
|
||||
|
Loading…
Reference in New Issue
Block a user