From 527f3bb31ce066749741bd84145270336e4bbc7a Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 5 Jun 2019 10:48:56 +0200 Subject: [PATCH] CMake: Add WrapPCRE2 package The WrapPCRE2 package handles the PCRE2 packages that have targets, and reuse them. Change-Id: I24b0b51f507703cd8287f845f7e425f62dd2c3d6 Reviewed-by: Alexandru Croitor --- cmake/FindPCRE2.cmake | 13 ------------- cmake/FindWrapPCRE2.cmake | 20 ++++++++++++++++++++ src/corelib/.prev_CMakeLists.txt | 2 +- src/corelib/CMakeLists.txt | 2 +- src/corelib/configure.cmake | 4 ++-- util/cmake/helper.py | 2 +- 6 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 cmake/FindPCRE2.cmake create mode 100644 cmake/FindWrapPCRE2.cmake diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake deleted file mode 100644 index 3977532124..0000000000 --- a/cmake/FindPCRE2.cmake +++ /dev/null @@ -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() - diff --git a/cmake/FindWrapPCRE2.cmake b/cmake/FindWrapPCRE2.cmake new file mode 100644 index 0000000000..b69c5078a5 --- /dev/null +++ b/cmake/FindWrapPCRE2.cmake @@ -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() diff --git a/src/corelib/.prev_CMakeLists.txt b/src/corelib/.prev_CMakeLists.txt index cad230bd87..ee4143ce96 100644 --- a/src/corelib/.prev_CMakeLists.txt +++ b/src/corelib/.prev_CMakeLists.txt @@ -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 diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index a032a9117e..66c211d292 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -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 diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index a144d6dd8f..1a34662fbb 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -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() diff --git a/util/cmake/helper.py b/util/cmake/helper.py index 60128a8b03..a184ce1f4d 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -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'),