1From 4afd71e88a906eba8a8f14a12599abcc8582d22c Mon Sep 17 00:00:00 2001
2From: Pascal Bach <pascal.bach@siemens.com>
3Date: Wed, 11 May 2016 15:20:41 +0200
4Subject: [PATCH] Pretend Qt5 wasn't found if OE_QMAKE_PATH_EXTERNAL_HOST_BINS
5 isn't set
6
7This prevents errors like:
8
9|   The imported target "Qt5::Core" references the file
10|
11|      "/qmake"
12|
13|   but this file does not exist.  Possible reasons include:
14
15Which happen if CMake is used without setting OE_QMAKE_PATH_EXTERNAL_HOST_BINS.
16To achieve this a check for OE_QMAKE_PATH_EXTERNAL_HOST_BINS is added to each Qt5*Config.cmake
17file. And in the case where the variable is not set we just return which is basically
18equal to telling CMake that Qt5 wasn't found.
19
20Upstream-Status: Pending
21  The patch only makes sense in connection with other patches included here.
22  Specifically this are:
23    - 0003-Add-external-hostbindir-option.patch
24    - 0010-Add-external-hostbindir-option-for-native-sdk.patch
25
26Signed-off-by: Pascal Bach <pascal.bach@siemens.com>
27---
28 mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 5 +++++
29 src/corelib/Qt5Config.cmake.in                      | 5 +++++
30 2 files changed, 10 insertions(+)
31
32diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
33index db18dbece6..13908c8fe5 100644
34--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
35+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
36@@ -2,6 +2,11 @@ if (CMAKE_VERSION VERSION_LESS 3.1.0)
37     message(FATAL_ERROR \"Qt 5 $${CMAKE_MODULE_NAME} module requires at least CMake version 3.1.0\")
38 endif()
39
40+if(NOT DEFINED OE_QMAKE_PATH_EXTERNAL_HOST_BINS)
41+    message(WARNING "Skipping because OE_QMAKE_PATH_EXTERNAL_HOST_BINS is not defined")
42+    return()
43+endif()
44+
45 !!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
46 !!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
47 set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
48diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in
49index 6b6544f932..d317912632 100644
50--- a/src/corelib/Qt5Config.cmake.in
51+++ b/src/corelib/Qt5Config.cmake.in
52@@ -3,6 +3,11 @@ if (CMAKE_VERSION VERSION_LESS 3.1.0)
53     message(FATAL_ERROR \"Qt5 requires at least CMake version 3.1.0\")
54 endif()
55
56+if(NOT DEFINED OE_QMAKE_PATH_EXTERNAL_HOST_BINS)
57+    message(WARNING "Skipping because OE_QMAKE_PATH_EXTERNAL_HOST_BINS is not defined")
58+    return()
59+endif()
60+
61 if (NOT Qt5_FIND_COMPONENTS)
62     set(Qt5_NOT_FOUND_MESSAGE \"The Qt5 package requires at least one component\")
63     set(Qt5_FOUND False)
64