diff options
author | John W. Parent <45471568+johnwparent@users.noreply.github.com> | 2023-03-24 14:10:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-24 11:10:46 -0700 |
commit | a451f55340816c9e50ac7c208b531ffe26794990 (patch) | |
tree | b4aa4b7e767c5a2048aa56a142cf86b9b817665b | |
parent | 15f7b72557a9c56d66327daf49284fc22cb4bc8d (diff) | |
download | spack-a451f55340816c9e50ac7c208b531ffe26794990.tar.gz spack-a451f55340816c9e50ac7c208b531ffe26794990.tar.bz2 spack-a451f55340816c9e50ac7c208b531ffe26794990.tar.xz spack-a451f55340816c9e50ac7c208b531ffe26794990.zip |
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)
-rw-r--r-- | var/spack/repos/builtin/packages/expat/package.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/expat/package.py b/var/spack/repos/builtin/packages/expat/package.py index bbe2d12d36..c6a5fae505 100644 --- a/var/spack/repos/builtin/packages/expat/package.py +++ b/var/spack/repos/builtin/packages/expat/package.py @@ -5,10 +5,11 @@ import sys +from spack.build_systems import autotools, cmake from spack.package import * -class Expat(AutotoolsPackage): +class Expat(AutotoolsPackage, CMakePackage): """Expat is an XML parser library written in C.""" homepage = "https://libexpat.github.io/" @@ -92,6 +93,8 @@ class Expat(AutotoolsPackage): deprecated=True, ) + build_system("autotools", "cmake", default="autotools") + # Version 2.2.2 introduced a requirement for a high quality # entropy source. "Older" linux systems (aka CentOS 7) do not # support get_random so we'll provide a high quality source via @@ -102,19 +105,41 @@ class Expat(AutotoolsPackage): # `~libbsd`. variant( "libbsd", - default=sys.platform != "darwin", + default=sys.platform != "darwin" and sys.platform != "win32", 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") def url_for_version(self, version): url = "https://github.com/libexpat/libexpat/releases/download/R_{0}/expat-{1}.tar.bz2" return url.format(version.underscored, version.dotted) + +class AutotoolsBuilder(autotools.AutotoolsBuilder): def configure_args(self): spec = self.spec args = ["--without-docbook", "--enable-static"] if "+libbsd" in spec and "@2.2.1:" in spec: args.append("--with-libbsd") 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 |