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

@@ -96,8 +96,19 @@ wx_option(wxUSE_REPRODUCIBLE_BUILD "enable reproducable build" OFF)
# ---------------------------------------------------------------------------
# external libraries
# ---------------------------------------------------------------------------
set(PCRE2_CODE_UNIT_WIDTH 8)
if(wxUSE_UNICODE AND (NOT DEFINED wxUSE_UNICODE_UTF8 OR NOT wxUSE_UNICODE_UTF8))
# This is also checked in setup.cmake, but setup.cmake will run after options.cmake.
include(CheckTypeSize)
check_type_size(wchar_t SIZEOF_WCHAR_T)
if(HAVE_SIZEOF_WCHAR_T AND SIZEOF_WCHAR_T EQUAL 2)
set(PCRE2_CODE_UNIT_WIDTH 16)
elseif(HAVE_SIZEOF_WCHAR_T AND SIZEOF_WCHAR_T EQUAL 4)
set(PCRE2_CODE_UNIT_WIDTH 32)
endif()
endif()
wx_add_thirdparty_library(wxUSE_REGEX REGEX "enable support for wxRegEx class" DEFAULT builtin)
wx_add_thirdparty_library(wxUSE_REGEX PCRE2 "enable support for wxRegEx class")
wx_add_thirdparty_library(wxUSE_ZLIB ZLIB "use zlib for LZW compression" DEFAULT_APPLE sys)
wx_add_thirdparty_library(wxUSE_EXPAT EXPAT "use expat for XML parsing" DEFAULT_APPLE sys)
wx_add_thirdparty_library(wxUSE_LIBJPEG JPEG "use libjpeg (JPEG file format)")