cmake FEATURE read pcre2 version from header

Instead of running a binary found in the default path.
Refs #1615
diff --git a/CMakeModules/FindPCRE2.cmake b/CMakeModules/FindPCRE2.cmake
index 65d6dc6..19af7b7 100644
--- a/CMakeModules/FindPCRE2.cmake
+++ b/CMakeModules/FindPCRE2.cmake
@@ -36,9 +36,19 @@
         ${CMAKE_LIBRARY_PATH}
         ${CMAKE_INSTALL_PREFIX}/lib)
 
-    if(PCRE2_LIBRARY)
-        # Check required version
-        execute_process(COMMAND pcre2-config --version OUTPUT_VARIABLE PCRE2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(PCRE2_INCLUDE_DIR AND PCRE2_LIBRARY)
+        # learn pcre2 version
+        file(STRINGS ${PCRE2_INCLUDE_DIR}/pcre2.h PCRE2_VERSION_MAJOR
+            REGEX "#define[ ]+PCRE2_MAJOR[ ]+[0-9]+")
+        string(REGEX MATCH " [0-9]+" PCRE2_VERSION_MAJOR ${PCRE2_VERSION_MAJOR})
+        string(STRIP "${PCRE2_VERSION_MAJOR}" PCRE2_VERSION_MAJOR)
+
+        file(STRINGS ${PCRE2_INCLUDE_DIR}/pcre2.h PCRE2_VERSION_MINOR
+            REGEX "#define[ ]+PCRE2_MINOR[ ]+[0-9]+")
+        string(REGEX MATCH " [0-9]+" PCRE2_VERSION_MINOR ${PCRE2_VERSION_MINOR})
+        string(STRIP "${PCRE2_VERSION_MINOR}" PCRE2_VERSION_MINOR)
+
+        set(PCRE2_VERSION ${PCRE2_VERSION_MAJOR}.${PCRE2_VERSION_MINOR})
     endif()
 
     set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})