CMake: Add WrapPCRE2 package

The WrapPCRE2 package handles the PCRE2 packages that have targets,
and reuse them.

Change-Id: I24b0b51f507703cd8287f845f7e425f62dd2c3d6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Cristian Adam 2019-06-05 10:48:56 +02:00
parent eda3421111
commit 527f3bb31c
6 changed files with 25 additions and 18 deletions

View File

@ -1,13 +0,0 @@
find_library(PCRE2_LIBRARIES NAMES pcre2-16)
find_path(PCRE2_INCLUDE_DIRS pcre2.h)
if (PCRE2_LIBRARIES STREQUAL "PCRE2_LIBRARIES-NOTFOUND" OR PCRE2_INCLUDE_DIRS STREQUAL "PCRE2_INCLUDE_DIRS-NOTFOUND")
set(PCRE2_FOUND 0)
else()
add_library(PCRE2 INTERFACE IMPORTED)
target_link_libraries(PCRE2 INTERFACE ${PCRE2_LIBRARIES})
target_include_directories(PCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
set(PCRE2_FOUND 1)
endif()

20
cmake/FindWrapPCRE2.cmake Normal file
View File

@ -0,0 +1,20 @@
include_guard(GLOBAL) # pragma once equivalent
find_package(PCRE2 CONFIG QUIET)
if(PCRE2_FOUND AND TARGET PCRE2::pcre2-16)
# Hunter case.
add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE PCRE2::pcre2-16)
set(WrapPCRE2_FOUND TRUE)
else()
find_library(PCRE2_LIBRARIES NAMES pcre2-16)
find_path(PCRE2_INCLUDE_DIRS pcre2.h)
if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_LIBRARIES})
target_include_directories(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
set(WrapPCRE2_FOUND TRUE)
endif()
endif()

View File

@ -641,7 +641,7 @@ extend_target(Core CONDITION QT_FEATURE_regularexpression
SOURCES
tools/qregularexpression.cpp tools/qregularexpression.h
LIBRARIES
PCRE2
WrapPCRE2::WrapPCRE2
)
extend_target(Core CONDITION QT_FEATURE_commandlineparser

View File

@ -710,7 +710,7 @@ extend_target(Core CONDITION QT_FEATURE_regularexpression
SOURCES
tools/qregularexpression.cpp tools/qregularexpression.h
LIBRARIES
PCRE2
WrapPCRE2::WrapPCRE2
)
extend_target(Core CONDITION QT_FEATURE_commandlineparser

View File

@ -16,8 +16,8 @@ qt_find_package(Libsystemd PROVIDED_TARGETS PkgConfig::Libsystemd)
qt_find_package(Atomic PROVIDED_TARGETS Atomic)
qt_find_package(WrapRt PROVIDED_TARGETS WrapRt)
qt_find_package(LTTngUST PROVIDED_TARGETS LTTng::UST)
qt_find_package(PCRE2 PROVIDED_TARGETS PCRE2)
set_package_properties(PCRE2 PROPERTIES TYPE REQUIRED)
qt_find_package(WrapPCRE2 PROVIDED_TARGETS WrapPCRE2::WrapPCRE2)
set_package_properties(WrapPCRE2 PROPERTIES TYPE REQUIRED)
if((QNX) OR QT_FIND_ALL_PACKAGES_ALWAYS)
qt_find_package(PPS PROVIDED_TARGETS PPS::PPS)
endif()

View File

@ -215,7 +215,7 @@ _library_map = [
LibraryMapping('opengl', 'OpenGL', 'OpenGL::GL', resultVariable='OpenGL_OpenGL'),
LibraryMapping('openssl_headers', 'OpenSSL', 'OpenSSL::SSL_nolink', resultVariable='OPENSSL_INCLUDE_DIR', appendFoundSuffix=False),
LibraryMapping('openssl', 'OpenSSL', 'OpenSSL::SSL'),
LibraryMapping('pcre2', 'PCRE2', 'PCRE2', extra = ['REQUIRED']),
LibraryMapping('pcre2', 'WrapPCRE2', 'WrapPCRE2::WrapPCRE2', extra = ['REQUIRED']),
LibraryMapping('posix_iconv', None, None),
LibraryMapping('pps', 'PPS', 'PPS::PPS'),
LibraryMapping('psql', 'PostgreSQL', 'PostgreSQL::PostgreSQL'),