Files
poco/cmake/FindPCRE2.cmake
Matej Kenda 7a23a039f9 Reorganise external libs to separate subdirectory (#4996)
* chore(PCRE): properly detect library type on newer macOS

* chore(ZLIB): move source files to own zlib directory and update CMake files.

* chore(PCRE): move source files to own pcre2 directory and update CMake files.

* chore(UTF8PROC): move source files to own utf8proc directory and update CMake files.

* chore(ZLIB): remove header files

* chore(PDJSON): move source files to own pdjson directory and update CMake files.

* chore(SQLite3): move source files to own sqlite3 directory and update CMake files.

* chore(UNBUNDLED): Correct includes.

* chore(expat): move source files to own expat directory and update CMake files.

* chore(wepoll): move source files to own wepoll directory and update CMake files.

* chore(7zip): move source files to own 7zip directory and update CMake files.

* chore(CMake): fix compile and link flags for dependent static libraries

* chore(CMake): set PCRE2_STATIC when building PCRE2.

* chore(SQLite3): Set SQLITE_THREADSAFE for unbundled build, add warnings.

* chore(CMake): Modifications to build and link properly static target libraries (using OBJECT library type and link using BUILD_LOCAL_INTERFACE)

* chore(CMake): fix order of includes in main CMakeLists.txt.

* chore(CI): Build mysql tests with cmake.

* chore(CI): Build mongodb, redis, sqlite no parser tests with cmake.

* chore(CI): Build odbc tests with cmake.

* chore(CI): Build more ations with cmake, other fixes.

* chore(CI): Fixes for macOS

* chore(CMake): extract hpdf and png files to own directories in dependencies

* fix(CMake): include dependencies after all module dependencies are resolved.

* fix(CMake): Improve dependency handling of dependencies to compile them only when necessary.

* fix(CMake): PDF: move t4.h to proper directory, modify include.

* fix(CMake): Fixes to link properly on all platforms.

* fix(CMAKE): Wrong ENABLE for SQLITE

* enh(PDF): Remove dependencies on hpdf headers from Poco::PDF interface and make usage of hpdf only internal.

* enh(CI): Convert more jobs to use cmake.

* enh(CI): Convert macOS sanitizer jobs to use cmake.

* enh(mkrelease): Copy dependencies when creating release package.

* eng(CMake): Add missing POCO_SO option to enable/disable small object optimization.

* enh(CI): Run linux sanitizer with cmake, various fixes and improvements.

* fix(CMake): bundled build: ZLIB::ZLIB is already linked with Foundation, no need to link again to Poco::Zip

* fix(CI): vptr undefined sanitizer causes foundation tests to fail when linking, disable it

* chore(tests): Minor code improvements.

* fix(AsyncNotificationCenter): fix a data race with member _listsEmpty by making it atomic.

* eng(CI): Add a few more time sensitive tests to cppignore.lnx

* chore(Thread): Code updates.

* eng(CI): Add a few more time sensitive tests to cppignore.lnx

* fix(AsyncNotificationCenter): must join threads to avoid data race in dtor.

* chore(CI): Pass TSAN_OPTIONS to jobs where necessary

* chore(CI): run rests without sudo, compile with parallelism

* chore(CI): Use POCO_MINIMAL_BUILD to simplify CMake configure lines.

* chore(CI): Add 32-bit Windows VS build

* chore(CMake): Printout cmake generator platform.

* chore(CMake): linux-gcc-make-armv7l -> linux-gcc-cmake-armv7l

* chore(ci): windows-2025-msvc-cmake-32bit -> windows-2025-msvc-cmake-Win32

* chore(CI): Convert all remaining jobs to CMake.

* chore(make): Prevent building with make.

* chore(CodeQL): exclude all external code from CodeQL checks.

* chore(macOS): Set min support version to 13.3 to properly support C++20 standard.
2025-09-11 17:11:29 +02:00

123 lines
3.1 KiB
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindPCRE2
---------
Finds the PCRE2 library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``Pcre2::Pcre2``
The PCRE2 library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``PCRE2_FOUND``
True if the system has the PCRE2 library.
``PCRE2_VERSION``
The version of the PCRE2 library which was found.
``PCRE2_INCLUDE_DIRS``
Include directories needed to use PCRE2.
``PCRE2_LIBRARIES``
Libraries needed to link to PCRE2.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``PCRE2_INCLUDE_DIR``
The directory containing ``pcre2.h``.
``PCRE2_LIBRARY``
The path to the PCRE2 library.
Hints
^^^^^
``PCRE2_ROOT_DIR``
The path to the root directory of a PCRE2 installation.
``PCRE2_ROOT_INCLUDE_DIRS``
The path to the include directory of a PCRE2 installation.
``PCRE2_ROOT_LIBRARY_DIRS``
The path to the library directory of a PCRE2 installation.
#]=======================================================================]#
include(FindPackageHandleStandardArgs)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_PCRE2 QUIET pcre2)
find_path(PCRE2_INCLUDE_DIR
NAMES pcre2.h
HINTS
${PCRE2_ROOT_DIR}/include
${PCRE2_ROOT_INCLUDE_DIRS}
PATHS
${PC_PCRE2_INCLUDE_DIRS}
DOC "Specify the include directory containing pcre2.h"
)
find_library(PCRE2_LIBRARY
NAMES pcre2-8
HINTS
${PCRE2_ROOT_DIR}/lib
${PCRE2_ROOT_LIBRARY_DIRS}
PATHS
${PC_PCRE2_LIBRARY_DIRS}
DOC "Specify the lib directory containing pcre2"
)
set(PCRE2_VERSION ${PC_PCRE2_VERSION})
find_package_handle_standard_args(PCRE2
FOUND_VAR PCRE2_FOUND
REQUIRED_VARS
PCRE2_LIBRARY
PCRE2_INCLUDE_DIR
VERSION_VAR PCRE2_VERSION
)
if(PCRE2_FOUND)
set(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
set(PCRE2_DEFINITIONS ${PC_PCRE2_CFLAGS_OTHER})
endif()
if(PCRE2_FOUND AND NOT TARGET Pcre2::Pcre2)
# Determine PCRE2 library type
set(_PCRE2_LIB_TYPE UNKNOWN)
# cmake_path(GET PCRE2_LIBRARY EXTENSION LAST_ONLY _PCRE2_SUFFIX) # CMake 3.20+
get_filename_component(_PCRE2_SUFFIX ${PCRE2_LIBRARY} LAST_EXT)
if ("${_PCRE2_SUFFIX}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(_PCRE2_LIB_TYPE STATIC)
elseif ("${_PCRE2_SUFFIX}" STREQUAL "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(_PCRE2_LIB_TYPE SHARED)
elseif ("${_PCRE2_SUFFIX}" STREQUAL ".tbd") # new versions of macOS
set(_PCRE2_LIB_TYPE SHARED)
endif()
add_library(Pcre2::Pcre2 ${_PCRE2_LIB_TYPE} IMPORTED)
set_target_properties(Pcre2::Pcre2 PROPERTIES
IMPORTED_LOCATION "${PCRE2_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_PCRE2_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${PCRE2_INCLUDE_DIR}"
)
unset(_PCRE2_LIB_TYPE)
unset(_PCRE2_SUFFIX)
endif()
mark_as_advanced(
PCRE2_INCLUDE_DIR
PCRE2_LIBRARY
)