summaryrefslogtreecommitdiffstats
path: root/cmake/QtModuleConfig.cmake.in
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-08-02 16:02:04 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-08-06 17:00:21 +0200
commit825cb50c27fc0942a76771f9fb2ec052dc9142bf (patch)
tree2fbe555c9b1061a31aea43e9d29e3af146277253 /cmake/QtModuleConfig.cmake.in
parent9b860ece42e4012821b7e2140f363dbe3e256062 (diff)
CMake: Improve component / package not found error messages
Provide better error messages when a Qt package / component is not found. Mention the location of the expected Config file on the file system, whether it exists Also mention the location of the Config file that was specified by the user when configuring the project or which CMake computed and stored in QtModule_DIR cache var. Mention that a package is not found in case if the main target exposed by that package is not found. If the target is not found, mention that it might be due to QT_NO_CREATE_TARGETS being set to TRUE (when it is set to true). If it is set to true, the assumption is that the target must have been defined by something else before the find_package call (either an earlier find_package call without QT_NO_CREATE_TARGETS set to TRUE or maybe it's the use case of Qt being built together with its examples or it's a super build). Unset _Qt_NOTFOUND_MESSAGE to ensure that the Qt6 not found error message is not spilled into any subsequent find_package(Qt6) calls, causing a cascade of unwarranted warnings / errors. Make sure to unset it only if components were specified, so the message is not shown or unset in any of the recursive find_package(Qt6) calls which is a dependency for regular Qt module packages. This works fine, because find_package(Qt6) calls with components are only done in project code and not done by the transitive dependency code (which looks for Qt6Foo packages directly). Remove some dead code. Pick-to: 6.2 Task-number: QTBUG-95532 Change-Id: Ie93d18e25e33aa0fe9e9da9a60e3d3e4cd6adb58 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtModuleConfig.cmake.in')
-rw-r--r--cmake/QtModuleConfig.cmake.in14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
index ee66f566fa..76fde2dc1f 100644
--- a/cmake/QtModuleConfig.cmake.in
+++ b/cmake/QtModuleConfig.cmake.in
@@ -115,5 +115,17 @@ if (TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@BuildInternals.cmake")
endif()
else()
- set("@INSTALL_CMAKE_NAMESPACE@@target@_FOUND" FALSE)
+
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ if(NOT DEFINED @INSTALL_CMAKE_NAMESPACE@@target@_NOT_FOUND_MESSAGE)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_NOT_FOUND_MESSAGE
+ "Target \"@QT_CMAKE_EXPORT_NAMESPACE@::@target@\" was not found. ${@INSTALL_CMAKE_NAMESPACE@@target@_extra_not_found_message}")
+
+ if(QT_NO_CREATE_TARGETS)
+ string(APPEND @INSTALL_CMAKE_NAMESPACE@@target@_NOT_FOUND_MESSAGE
+ "Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus "
+ "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake was not "
+ "included to define the target.")
+ endif()
+ endif()
endif()