opennurbs: multiple build systems (#44871)

This commit is contained in:
Harmen Stoppels 2024-06-26 15:34:20 +02:00 committed by GitHub
parent 9d0102ac89
commit c24265fe7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,10 +4,11 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.build_systems import cmake, makefile
from spack.package import * from spack.package import *
class Opennurbs(Package): class Opennurbs(CMakePackage, MakefilePackage):
"""OpenNURBS is an open-source NURBS-based geometric modeling library """OpenNURBS is an open-source NURBS-based geometric modeling library
and toolset, with meshing and display / output functions. and toolset, with meshing and display / output functions.
""" """
@ -20,34 +21,31 @@ class Opennurbs(Package):
license("Zlib") license("Zlib")
version("develop", branch="develop") version("develop", branch="develop")
version( version(
"percept", "percept",
sha256="d12a8f14f0b27d286fb7a75ab3c4e300f77d1fbb028326d1c8d28e4641605538", sha256="d12a8f14f0b27d286fb7a75ab3c4e300f77d1fbb028326d1c8d28e4641605538",
url="https://github.com/PerceptTools/percept/raw/master/build-cmake/opennurbs-percept.tar.gz", url="https://github.com/PerceptTools/percept/raw/master/build-cmake/opennurbs-percept.tar.gz",
) )
build_system(
conditional("cmake", when="@1:"), conditional("makefile", when="@:0"), default="cmake"
)
variant("shared", default=True, description="Build shared libraries") variant("shared", default=True, description="Build shared libraries")
# CMake installation method
def install(self, spec, prefix):
cmake_args = [self.define_from_variant("BUILD_SHARED_LIBS", "shared")]
cmake_args.extend(std_cmake_args) class CMakeBuilder(cmake.CMakeBuilder):
def cmake_args(self):
return [self.define_from_variant("BUILD_SHARED_LIBS", "shared")]
with working_dir("spack-build", create=True):
cmake("..", *cmake_args)
make()
make("install")
# Pre-cmake installation method class MakefileBuilder(makefile.MakefileBuilder):
@when("@percept")
def install(self, spec, prefix):
make(parallel=False)
# Install manually def build(self, pkg, spec, prefix):
make("RM=rm -f", "AR=ar cr", f"CC={spack_cc}", f"CCC={spack_cxx}", parallel=False)
def install(self, pkg, spec, prefix):
mkdir(prefix.lib) mkdir(prefix.lib)
mkdir(prefix.include) mkdir(prefix.include)
install("libopenNURBS.a", prefix.lib) install("libopenNURBS.a", prefix.lib)
install_tree("zlib", join_path(prefix.include, "zlib"))
install("*.h", prefix.include) install("*.h", prefix.include)