mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
cmake: standardize regex options
Selecting regular expression backend should be specified in the same way as everything else; `USE_REGEX`. Keep `REGEX_BACKEND` as an optional fallback.
This commit is contained in:
@@ -37,7 +37,7 @@ option(USE_NSEC "Support nanosecond precision file mtimes and cti
|
||||
option(USE_GSSAPI "Enable SPNEGO authentication using GSSAPI" OFF)
|
||||
set(USE_HTTP_PARSER "" CACHE STRING "Selects HTTP Parser support: http-parser, llhttp, or builtin. (Defaults to builtin.)")
|
||||
# set(USE_XDIFF "" CACHE STRING "Specifies the xdiff implementation; either system or builtin.")
|
||||
set(REGEX_BACKEND "" CACHE STRING "Selects regex provider. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
|
||||
set(USE_REGEX "" CACHE STRING "Selects regex provider. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
|
||||
set(USE_COMPRESSION "" CACHE STRING "Selects compression backend. Either builtin or zlib.")
|
||||
|
||||
# Debugging options
|
||||
|
||||
@@ -1,27 +1,35 @@
|
||||
# Specify regular expression implementation
|
||||
find_package(PCRE)
|
||||
|
||||
if(REGEX_BACKEND STREQUAL "")
|
||||
set(OPTION_NAME "USE_REGEX")
|
||||
|
||||
# Fall back to the previous cmake configuration, "USE_BUNDLED_ZLIB"
|
||||
if(NOT USE_REGEX AND REGEX_BACKEND)
|
||||
set(USE_REGEX "${REGEX_BACKEND}")
|
||||
set(OPTION_NAME "REGEX_BACKEND")
|
||||
endif()
|
||||
|
||||
if(NOT USE_REGEX)
|
||||
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
|
||||
|
||||
if(HAVE_REGCOMP_L)
|
||||
# 'regcomp_l' has been explicitly marked unavailable on iOS_SDK
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "iOS")
|
||||
set(REGEX_BACKEND "regcomp")
|
||||
set(USE_REGEX "regcomp")
|
||||
else()
|
||||
set(REGEX_BACKEND "regcomp_l")
|
||||
set(USE_REGEX "regcomp_l")
|
||||
endif()
|
||||
elseif(PCRE_FOUND)
|
||||
set(REGEX_BACKEND "pcre")
|
||||
set(USE_REGEX "pcre")
|
||||
else()
|
||||
set(REGEX_BACKEND "builtin")
|
||||
set(USE_REGEX "builtin")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(REGEX_BACKEND STREQUAL "regcomp_l")
|
||||
if(USE_REGEX STREQUAL "regcomp_l")
|
||||
add_feature_info(regex ON "using system regcomp_l")
|
||||
set(GIT_REGEX_REGCOMP_L 1)
|
||||
elseif(REGEX_BACKEND STREQUAL "pcre2")
|
||||
elseif(USE_REGEX STREQUAL "pcre2")
|
||||
find_package(PCRE2)
|
||||
|
||||
if(NOT PCRE2_FOUND)
|
||||
@@ -34,23 +42,23 @@ elseif(REGEX_BACKEND STREQUAL "pcre2")
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE2_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
|
||||
elseif(REGEX_BACKEND STREQUAL "pcre")
|
||||
elseif(USE_REGEX STREQUAL "pcre")
|
||||
add_feature_info(regex ON "using system PCRE")
|
||||
set(GIT_REGEX_PCRE 1)
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
|
||||
elseif(REGEX_BACKEND STREQUAL "regcomp")
|
||||
elseif(USE_REGEX STREQUAL "regcomp")
|
||||
add_feature_info(regex ON "using system regcomp")
|
||||
set(GIT_REGEX_REGCOMP 1)
|
||||
elseif(REGEX_BACKEND STREQUAL "builtin")
|
||||
add_feature_info(regex ON "using bundled PCRE")
|
||||
elseif(USE_REGEX STREQUAL "builtin")
|
||||
add_feature_info(regex ON "using builtin")
|
||||
set(GIT_REGEX_BUILTIN 1)
|
||||
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/pcre" "${PROJECT_BINARY_DIR}/deps/pcre")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/pcre")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>)
|
||||
else()
|
||||
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
|
||||
message(FATAL_ERROR "unknown setting to ${OPTION_NAME}: ${USE_REGEX}")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user