muparser: refactor to use new multi-build-system logic (#44552)

This commit is contained in:
James Smillie 2024-06-14 14:43:20 -06:00 committed by GitHub
parent e5f5749d67
commit e092026eb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
from spack.package import *
class Muparser(Package):
class Muparser(CMakePackage, Package):
"""C++ math expression parser library."""
homepage = "https://beltoforion.de/en/muparser/"
@ -22,21 +22,29 @@ class Muparser(Package):
# https://github.com/beltoforion/muparser/pull/46
patch("auto_ptr.patch", when="@2.2.5")
depends_on("cmake@3.1.0:", when="@2.2.6:", type="build")
variant("samples", default=True, description="enable samples", when="build_system=cmake")
variant("openmp", default=True, description="enable OpenMP support", when="build_system=cmake")
variant(
"wide_char",
default=False,
description="enable wide character strings in place of ASCII",
when="build_system=cmake",
)
variant("shared", default=True, description="enable shared libs", when="build_system=cmake")
# Cmake build since 2.2.6
@when("@2.2.6:")
def install(self, spec, prefix):
cmake_args = ["-DENABLE_SAMPLES=OFF", "-DENABLE_OPENMP=OFF", "-DBUILD_SHARED_LIBS=ON"]
# Non-CMake build system is not supported by windows
conflicts("platform=windows", when="@:2.2.5")
build_system(conditional("cmake", when="@2.2.6:"), "generic", default="cmake")
cmake_args.extend(std_cmake_args)
def cmake_args(self):
return [
self.define_from_variant("ENABLE_SAMPLES", "samples"),
self.define_from_variant("ENABLE_OPENMP", "openmp"),
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
self.define_from_variant("ENABLE_WIDE_CHAR", "wide_char"),
]
with working_dir("spack-build", create=True):
cmake("..", *cmake_args)
make()
make("install")
@when("@2.2.5")
@when("@:2.2.5")
def install(self, spec, prefix):
options = [
"--disable-debug",