mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Add CMake variable FISH_USE_SYSTEM_PCRE2
The CMake variable FISH_USE_SYSTEM_PCRE2 now controls whether fish uses system PCRE2 or the bundled version. The default is to use the system version, unless no such version is found, or unless it is a macOS build with code signing. Note the default behavior has not changed. Fixes #6952
This commit is contained in:
parent
2951c05934
commit
b88b6ea504
2 changed files with 28 additions and 6 deletions
|
@ -49,6 +49,7 @@
|
|||
- Allow finishing builds on OS X <10.13.6 (previously builds would fail at the `codesign` step)
|
||||
- The pkg-config file now uses pkg-config variables
|
||||
- The default values for the extra_completionsdir, extra_functionsdir and extra_confdir options now use the installation prefix instead of hardcoding `/usr/local`
|
||||
- A new CMake variable `FISH_USE_SYSTEM_PCRE2` controls whether fish builds with the system-installed PCRE2, or the version it bundles. By default it prefers the system library if available, unless Mac codesigning is enabled (#6952).
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -7,16 +7,37 @@ set(PCRE2_BUILD_TESTS OFF CACHE BOOL "Build tests")
|
|||
set(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "Build pcre2grep")
|
||||
|
||||
set(PCRE2_MIN_VERSION 10.21)
|
||||
IF (NOT APPLE)
|
||||
find_library(PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
find_path(PCRE2_INCLUDE_DIR pcre2.h)
|
||||
|
||||
# Look for a system-installed PCRE2.
|
||||
find_library(SYS_PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
find_path(SYS_PCRE2_INCLUDE_DIR pcre2.h)
|
||||
|
||||
# We can either use the system-installed PCRE or our bundled version.
|
||||
# This is controlled by the cache variable FISH_USE_SYSTEM_PCRE2.
|
||||
# Here we compute the default value for that variable.
|
||||
if ((APPLE) AND (MAC_CODESIGN_ID))
|
||||
# On Mac, a codesigned fish will refuse to load a non-codesigned PCRE2
|
||||
# (e.g. from Homebrew) so default to bundled PCRE2.
|
||||
set(USE_SYS_PCRE2_DEFAULT OFF)
|
||||
elseif((NOT SYS_PCRE2_LIB) OR (NOT SYS_PCRE2_INCLUDE_DIR))
|
||||
# We did not find system PCRE2, so default to bundled.
|
||||
set(USE_SYS_PCRE2_DEFAULT OFF)
|
||||
else()
|
||||
# Default to using the system PCRE2, which was found.
|
||||
set(USE_SYS_PCRE2_DEFAULT ON)
|
||||
endif()
|
||||
IF (PCRE2_LIB AND PCRE2_INCLUDE_DIR)
|
||||
message(STATUS "Found system PCRE2 library ${PCRE2_INCLUDE_DIR}")
|
||||
|
||||
set(FISH_USE_SYSTEM_PCRE2 ${USE_SYS_PCRE2_DEFAULT} CACHE BOOL
|
||||
"Use PCRE2 from the system, instead of bundled with fish")
|
||||
|
||||
if(FISH_USE_SYSTEM_PCRE2)
|
||||
set(PCRE2_LIB "${SYS_PCRE2_LIB}")
|
||||
set(PCRE2_INCLUDE_DIR "${SYS_PCRE2_INCLUDE_DIR}")
|
||||
message(STATUS "Using system PCRE2 library ${PCRE2_INCLUDE_DIR}")
|
||||
else()
|
||||
message(STATUS "Using bundled PCRE2 library")
|
||||
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
||||
set(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2)
|
||||
set(PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
endif(PCRE2_LIB AND PCRE2_INCLUDE_DIR)
|
||||
endif(FISH_USE_SYSTEM_PCRE2)
|
||||
include_directories(${PCRE2_INCLUDE_DIR})
|
||||
|
|
Loading…
Reference in a new issue