From 5ead4c2d56b5fa934d96e157bc8ebc11817ffcb3 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 19 Dec 2023 09:57:59 -0600 Subject: pcre: ensure consistency between autotools and cmake builds (#41644) Co-authored-by: wdconinc --- var/spack/repos/builtin/packages/pcre/package.py | 46 +++++++++++++++--------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'var') 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 -- cgit v1.2.3-70-g09d2