From 3306722e9f5ffbfc44263eb9510a5adae7b4b1b2 Mon Sep 17 00:00:00 2001
From: "FeRD (Frank Dana)" <ferdnyc@gmail.com>
Date: Wed, 21 Apr 2021 13:23:36 -0400
Subject: [PATCH 4/8] generate-proper-pkg-config-file

---
 cmake/OpenCVUtils.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
index f42ad0b..b81ebc0 100644
--- a/cmake/OpenCVUtils.cmake
+++ b/cmake/OpenCVUtils.cmake
@@ -1649,7 +1649,7 @@ endfunction()
 macro(ocv_get_libname var_name)
   get_filename_component(__libname "${ARGN}" NAME)
   # libopencv_core.so.3.3 -> opencv_core
-  string(REGEX REPLACE "^lib(.+)\\.(a|so|dll)(\\.[.0-9]+)?$" "\\1" __libname "${__libname}")
+  string(REGEX REPLACE "^lib(.+[^.0-9])(\\-[0-9]+)?\\.(a|so|dll)(\\.[.0-9]+)?$" "\\1" __libname "${__libname}")
   # MacOSX: libopencv_core.3.3.1.dylib -> opencv_core
   string(REGEX REPLACE "^lib(.+[^.0-9])\\.([.0-9]+\\.)?dylib$" "\\1" __libname "${__libname}")
   set(${var_name} "${__libname}")
-- 
2.31.1

