CMake: Use PCRE2 system library when available

Similar to other system libraries, use the builtin version on Windows and macOS
and try to find the system library on Unix.

Find the correct PCRE2 library based on the code point width that will be used.
This commit is contained in:
Maarten Bent
2021-07-25 12:04:31 +02:00
parent 68a293e75d
commit d07377fdf7
3 changed files with 62 additions and 3 deletions

View File

@@ -7,8 +7,9 @@
# Licence: wxWindows licence
#############################################################################
if(wxUSE_REGEX)
set(wxUSE_REGEX builtin)
if(wxUSE_REGEX STREQUAL "builtin")
# TODO: implement building PCRE2 via its CMake file, using
# add_subdirectory or ExternalProject_Add
wx_add_builtin_library(wxregex
3rdparty/pcre/src/pcre2_auto_possess.c
3rdparty/pcre/src/pcre2_compile.c
@@ -42,4 +43,8 @@ if(wxUSE_REGEX)
set(REGEX_INCLUDE_DIRS ${wxSOURCE_DIR}/3rdparty/pcre/src/wx)
target_compile_definitions(wxregex PRIVATE __WX__ HAVE_CONFIG_H)
target_include_directories(wxregex PRIVATE ${wxSETUP_HEADER_PATH} ${wxSOURCE_DIR}/include ${REGEX_INCLUDE_DIRS})
elseif(wxUSE_REGEX)
find_package(PCRE2 REQUIRED)
set(REGEX_LIBRARIES ${PCRE2_LIBRARIES})
set(REGEX_INCLUDE_DIRS ${PCRE2_INCLUDE_DIRS})
endif()