mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
cmake: Download and fetch PCRE2 rather than using vendored sources
This switches to using the CMake FetchContent path to dynamically download and build PCRE2, allowing us to drop the vendored sources. The FISH_USE_SYSTEM_PCRE2 CMake option is kept, but if false it now means fetch-and-build PCRE2 rather than building vendored sources. Note FetchContent was introduced in CMake 3.11. That is now a prerequisite for building fish with FISH_USE_SYSTEM_PCRE2 disabled.
This commit is contained in:
parent
ffded81a00
commit
5b1e106d87
1 changed files with 25 additions and 4 deletions
|
@ -28,16 +28,37 @@ else()
|
|||
endif()
|
||||
|
||||
set(FISH_USE_SYSTEM_PCRE2 ${USE_SYS_PCRE2_DEFAULT} CACHE BOOL
|
||||
"Use PCRE2 from the system, instead of bundled with fish")
|
||||
"Use PCRE2 from the system, instead of fetching and building it")
|
||||
|
||||
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)
|
||||
include(FetchContent RESULT_VARIABLE HAVE_FetchContent)
|
||||
if (${HAVE_FetchContent} STREQUAL "NOTFOUND")
|
||||
message(FATAL_ERROR "Please install PCRE2 headers, or CMake >= 3.11 so I can download PCRE")
|
||||
endif()
|
||||
set(CMAKE_TLS_VERIFY true)
|
||||
set(PCRE2_REPO "https://github.com/PhilipHazel/pcre2.git")
|
||||
|
||||
message(STATUS "Fetching and configuring PCRE2 from ${PCRE2_REPO}")
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
FetchContent_Declare(
|
||||
pcre2
|
||||
GIT_REPOSITORY ${PCRE2_REPO}
|
||||
GIT_TAG "72669190cb947f0cac1d038a8bb1820da59ef447" # tag: pcre2-10.36
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
# Don't try FetchContent_MakeAvailable, there's no way to add EXCLUDE_FROM_ALL
|
||||
# so we end up installing all of PCRE2 including its headers, man pages, etc.
|
||||
FetchContent_GetProperties(pcre2)
|
||||
if (NOT pcre2_POPULATED)
|
||||
FetchContent_Populate(pcre2)
|
||||
add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(PCRE2_INCLUDE_DIR ${pcre2_BINARY_DIR})
|
||||
set(PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
|
||||
# Disable -Wunused-macros inside PCRE2, as it is noisy.
|
||||
|
|
Loading…
Reference in a new issue