          set_target_properties(Qt5::${Plugin} PROPERTIES
              \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
 diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf
-index c0b50416c9..cabe39b22e 100644
+index 3d6cd9b3db..ca8b0b2701 100644
 --- a/mkspecs/features/qml_module.prf
 +++ b/mkspecs/features/qml_module.prf
 @@ -51,7 +51,7 @@ builtin_resources {

 !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
 !!ENDIF
@@ -499,25 +455,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
 !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
 !!IF isEmpty(CMAKE_DEBUG_TYPE)
 !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)

 
 check_examples {
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index 7777e615bd..b0c6880a74 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -87,19 +87,22 @@ defineTest(qtHaveModule) {
 defineTest(qtPrepareTool) {
     cmd = $$eval(QT_TOOL.$${2}.binary)
     isEmpty(cmd) {
-        cmd = $$[QT_HOST_BINS]/$$2
-        exists($${cmd}.pl) {
-            $${1}_EXE = $${cmd}.pl
-            cmd = perl -w $$system_path($${cmd}.pl)
-        } else: contains(QMAKE_HOST.os, Windows) {
-            $${1}_EXE = $${cmd}.exe
-            cmd = $$system_path($${cmd}.exe)
-        } else:contains(QMAKE_HOST.os, Darwin) {
-            BUNDLENAME = $${cmd}.app/Contents/MacOS/$$2
-            exists($$BUNDLENAME) {
-                cmd = $$BUNDLENAME
+        cmd = $$system("command -v $${2}")
+        isEmpty(cmd) {
+            cmd = $$system("command -v $${2}.pl")
+            !isEmpty(cmd) {
+                $${1}_EXE = $$cmd
+                cmd = perl -w $$system_path($${cmd})
+            } else: contains(QMAKE_HOST.os, Windows) {
+                cmd = $$system("command -v $${2}.exe")
+                $${1}_EXE = $$cmd
+            } else: contains(QMAKE_HOST.os, Darwin) {
+                cmd = $$system("command -v $${2}.app")
+                !isEmpty(cmd) {
+                    cmd = $${cmd}/Contents/MacOS/$${2}
+                    $${1}_EXE = $$cmd
+                }
             }
-            $${1}_EXE = $$cmd
         } else {
             $${1}_EXE = $$cmd
         }
diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf
index 1ebca17366..a8f958eae8 100644
--- a/mkspecs/features/qt_installs.prf
