summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWouter Deconinck <wdconinc@gmail.com>2023-12-19 09:57:59 -0600
committerGitHub <noreply@github.com>2023-12-19 16:57:59 +0100
commit5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3 (patch)
tree2fda1a3cab2eeb63d96074ca13f4669f2bfddd68
parent2e18fbbdeb29385ce50078eff3a4701a45a3f656 (diff)
downloadspack-5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3.tar.gz
spack-5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3.tar.bz2
spack-5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3.tar.xz
spack-5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3.zip
pcre: ensure consistency between autotools and cmake builds (#41644)
Co-authored-by: wdconinc <wdconinc@users.noreply.github.com>
-rw-r--r--var/spack/repos/builtin/packages/pcre/package.py46
1 files changed, 30 insertions, 16 deletions
diff --git a/var/spack/repos/builtin/packages/pcre/package.py b/var/spack/repos/builtin/packages/pcre/package.py
index 4719f5ea37..f9199427b9 100644
--- a/var/spack/repos/builtin/packages/pcre/package.py
+++ b/var/spack/repos/builtin/packages/pcre/package.py
@@ -40,21 +40,34 @@ class Pcre(AutotoolsPackage, CMakePackage):
description="Enable support for UTF-8/16/32, " "incompatible with EBCDIC.",
)
+ variant("shared", default=True, description="Build shared libraries")
+ variant("static", default=True, description="Build static libraries")
+ conflicts("-shared -static", msg="Must build one of shared and static")
+ conflicts(
+ "+shared +static",
+ when="build_system=cmake",
+ msg="CMake can only build either shared or static",
+ )
+
+ variant("pic", default=True, description="Enable position-independent code (PIC)")
+ requires("+pic", when="+shared build_system=autotools")
+
class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
def configure_args(self):
args = []
- if "+jit" in self.spec:
- args.append("--enable-jit")
+ args.extend(self.enable_or_disable("shared"))
+ args.extend(self.enable_or_disable("static"))
+ args.extend(self.with_or_without("pic"))
- if "+multibyte" in self.spec:
- args.append("--enable-pcre16")
- args.append("--enable-pcre32")
+ args.extend(self.enable_or_disable("jit"))
- if "+utf" in self.spec:
- args.append("--enable-utf")
- args.append("--enable-unicode-properties")
+ args.extend(self.enable_or_disable("pcre16", variant="multibyte"))
+ args.extend(self.enable_or_disable("pcre32", variant="multibyte"))
+
+ args.extend(self.enable_or_disable("utf"))
+ args.extend(self.enable_or_disable("unicode-properties", variant="utf"))
return args
@@ -63,15 +76,16 @@ class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
args = []
- if "+jit" in self.spec:
- args.append("-DPCRE_SUPPORT_JIT:BOOL=ON")
+ args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared"))
+ args.append(self.define_from_variant("BUILD_STATIC_LIBS", "static"))
+ args.append(self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"))
+
+ args.append(self.define_from_variant("PCRE_SUPPORT_JIT", "jit"))
- if "+multibyte" in self.spec:
- args.append("-DPCRE_BUILD_PCRE16:BOOL=ON")
- args.append("-DPCRE_BUILD_PCRE32:BOOL=ON")
+ args.append(self.define_from_variant("PCRE_BUILD_PCRE16", "multibyte"))
+ args.append(self.define_from_variant("PCRE_BUILD_PCRE32", "multibyte"))
- if "+utf" in self.spec:
- args.append("-DPCRE_SUPPORT_UTF:BOOL=ON")
- args.append("-DPCRE_SUPPORT_UNICODE_PROPERTIES:BOOL=ON")
+ args.append(self.define_from_variant("PCRE_SUPPORT_UTF", "utf"))
+ args.append(self.define_from_variant("PCRE_SUPPORT_UNICODE_PROPERTIES", "utf"))
return args