pcre: ensure consistency between autotools and cmake builds (#41644)

Co-authored-by: wdconinc <wdconinc@users.noreply.github.com>
This commit is contained in:
Wouter Deconinck 2023-12-19 09:57:59 -06:00 committed by GitHub
parent 2e18fbbdeb
commit 5ead4c2d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,21 +40,34 @@ class Pcre(AutotoolsPackage, CMakePackage):
description="Enable support for UTF-8/16/32, " "incompatible with EBCDIC.", 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): class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
def configure_args(self): def configure_args(self):
args = [] args = []
if "+jit" in self.spec: args.extend(self.enable_or_disable("shared"))
args.append("--enable-jit") args.extend(self.enable_or_disable("static"))
args.extend(self.with_or_without("pic"))
if "+multibyte" in self.spec: args.extend(self.enable_or_disable("jit"))
args.append("--enable-pcre16")
args.append("--enable-pcre32")
if "+utf" in self.spec: args.extend(self.enable_or_disable("pcre16", variant="multibyte"))
args.append("--enable-utf") args.extend(self.enable_or_disable("pcre32", variant="multibyte"))
args.append("--enable-unicode-properties")
args.extend(self.enable_or_disable("utf"))
args.extend(self.enable_or_disable("unicode-properties", variant="utf"))
return args return args
@ -63,15 +76,16 @@ class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self): def cmake_args(self):
args = [] args = []
if "+jit" in self.spec: args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared"))
args.append("-DPCRE_SUPPORT_JIT:BOOL=ON") args.append(self.define_from_variant("BUILD_STATIC_LIBS", "static"))
args.append(self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"))
if "+multibyte" in self.spec: args.append(self.define_from_variant("PCRE_SUPPORT_JIT", "jit"))
args.append("-DPCRE_BUILD_PCRE16:BOOL=ON")
args.append("-DPCRE_BUILD_PCRE32:BOOL=ON")
if "+utf" in self.spec: args.append(self.define_from_variant("PCRE_BUILD_PCRE16", "multibyte"))
args.append("-DPCRE_SUPPORT_UTF:BOOL=ON") args.append(self.define_from_variant("PCRE_BUILD_PCRE32", "multibyte"))
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 return args