From bc37d3e125da5b1a225b02dbfb27f20ac404d8d7 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Thu, 14 Feb 2019 03:09:59 +0100
Subject: [PATCH] Fix generation of the Qt5::GLESv2 target on ARM

Since 5.12.1 the library name provided is an absolute path. We need to
take the case into account, otherwise it just fails to build if the
target is used.

Change-Id: I96407e5fe1831487da77cbe7b24b64dae59b22ff
---
 src/gui/Qt5GuiConfigExtras.cmake.in | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
index 07869efd7d8..84dbbfebd47 100644
--- a/src/gui/Qt5GuiConfigExtras.cmake.in
+++ b/src/gui/Qt5GuiConfigExtras.cmake.in
@@ -91,16 +91,29 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
     endforeach()
 !!ENDIF
     foreach(_lib ${Libs})
-        string(REGEX REPLACE "[^_A-Za-z0-9]" "_" _cmake_lib_name ${_lib})
+        if (IS_ABSOLUTE ${_lib})
+            get_filename_component(_libFile ${_lib} NAME_WE)
+            if (_libFile MATCHES \"^${CMAKE_SHARED_LIBRARY_PREFIX}(.*)\")
+                set(_libFile ${CMAKE_MATCH_1})
+            endif()
+        else()
+            set(_libFile ${_lib})
+        endif()
+
+        string(REGEX REPLACE "[^_A-Za-z0-9]" "_" _cmake_lib_name ${_libFile})
         if (NOT TARGET Qt5::Gui_${_cmake_lib_name} AND NOT _Qt5Gui_${_cmake_lib_name}_LIBRARY_DONE)
-            find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib}
+            if (IS_ABSOLUTE ${_lib})
+                set(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib})
+            else()
+                find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib}
 !!IF !isEmpty(CROSS_COMPILE)
-                PATHS \"${LibDir}\"
+                    PATHS \"${LibDir}\"
 !!IF !mac
-                NO_DEFAULT_PATH
+                    NO_DEFAULT_PATH
 !!ENDIF
 !!ENDIF
-            )
+                )
+            endif()
 !!IF mac
             set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}")
             if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
-- 
2.16.3

