Expat package: add CMake-build option (#35109)
* Add option to optionally build with CMake * Autotools is preferred where available * Unlike the autotools-based build, the CMake-based build creates either static or shared libs, not both (the default is shared and is controlled with a new "shared" variant that only exists when building with cmake) * Note that `cmake~ownlibs` depends on expat, so would require `expat build_system=autotools` (to avoid a cyclic dependency)
This commit is contained in:
parent
15f7b72557
commit
a451f55340
1 changed files with 27 additions and 2 deletions
|
@ -5,10 +5,11 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from spack.build_systems import autotools, cmake
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
class Expat(AutotoolsPackage):
|
class Expat(AutotoolsPackage, CMakePackage):
|
||||||
"""Expat is an XML parser library written in C."""
|
"""Expat is an XML parser library written in C."""
|
||||||
|
|
||||||
homepage = "https://libexpat.github.io/"
|
homepage = "https://libexpat.github.io/"
|
||||||
|
@ -92,6 +93,8 @@ class Expat(AutotoolsPackage):
|
||||||
deprecated=True,
|
deprecated=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
build_system("autotools", "cmake", default="autotools")
|
||||||
|
|
||||||
# Version 2.2.2 introduced a requirement for a high quality
|
# Version 2.2.2 introduced a requirement for a high quality
|
||||||
# entropy source. "Older" linux systems (aka CentOS 7) do not
|
# entropy source. "Older" linux systems (aka CentOS 7) do not
|
||||||
# support get_random so we'll provide a high quality source via
|
# support get_random so we'll provide a high quality source via
|
||||||
|
@ -102,19 +105,41 @@ class Expat(AutotoolsPackage):
|
||||||
# `~libbsd`.
|
# `~libbsd`.
|
||||||
variant(
|
variant(
|
||||||
"libbsd",
|
"libbsd",
|
||||||
default=sys.platform != "darwin",
|
default=sys.platform != "darwin" and sys.platform != "win32",
|
||||||
description="Use libbsd (for high quality randomness)",
|
description="Use libbsd (for high quality randomness)",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
variant(
|
||||||
|
"shared",
|
||||||
|
default=True,
|
||||||
|
description="Build expat as shared if true, static if false",
|
||||||
|
when="build_system=cmake",
|
||||||
|
)
|
||||||
|
|
||||||
depends_on("libbsd", when="@2.2.1:+libbsd")
|
depends_on("libbsd", when="@2.2.1:+libbsd")
|
||||||
|
|
||||||
def url_for_version(self, version):
|
def url_for_version(self, version):
|
||||||
url = "https://github.com/libexpat/libexpat/releases/download/R_{0}/expat-{1}.tar.bz2"
|
url = "https://github.com/libexpat/libexpat/releases/download/R_{0}/expat-{1}.tar.bz2"
|
||||||
return url.format(version.underscored, version.dotted)
|
return url.format(version.underscored, version.dotted)
|
||||||
|
|
||||||
|
|
||||||
|
class AutotoolsBuilder(autotools.AutotoolsBuilder):
|
||||||
def configure_args(self):
|
def configure_args(self):
|
||||||
spec = self.spec
|
spec = self.spec
|
||||||
args = ["--without-docbook", "--enable-static"]
|
args = ["--without-docbook", "--enable-static"]
|
||||||
if "+libbsd" in spec and "@2.2.1:" in spec:
|
if "+libbsd" in spec and "@2.2.1:" in spec:
|
||||||
args.append("--with-libbsd")
|
args.append("--with-libbsd")
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
class CMakeBuilder(cmake.CMakeBuilder):
|
||||||
|
def cmake_args(self):
|
||||||
|
args = [
|
||||||
|
self.define("EXPAT_BUILD_DOCS", False),
|
||||||
|
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
|
||||||
|
]
|
||||||
|
|
||||||
|
if "+libbsd" in self.spec and "@2.2.1:" in self.spec:
|
||||||
|
args.append(self.define_from_variant("EXPAT_WITH_LIBBSD", "libbsd"))
|
||||||
|
|
||||||
|
return args
|
||||||
|
|
Loading…
Reference in a new issue