summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@qt.io>2019-06-05 10:48:56 +0200
committerCristian Adam <cristian.adam@qt.io>2019-06-05 09:42:55 +0000
commit527f3bb31ce066749741bd84145270336e4bbc7a (patch)
treeacb6eaaac30f9d390fd2543fa3dc783e39c503a1 /cmake
parenteda342111156e828caa1f900b5b55d575881ac22 (diff)
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>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindPCRE2.cmake13
-rw-r--r--cmake/FindWrapPCRE2.cmake20
2 files changed, 20 insertions, 13 deletions
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()