From 18fc9e1bf821130f0cfe45dc7d5c05b70458e7c0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 4 Sep 2019 10:52:18 +0200 Subject: [PATCH] Fix qtdeclarative build on Windows Our tools are typically installed into the Qt bin directory, after which they are useable right away on Windows, since the Qt dlls are located there, too. An exception to the rule are tools that are built within a module and used right away. At that point they are in the top-level bin dir of the build directory, along with "local" DLLS they might need, but with the Qt dlls out of reach. To cover this case, we need to prepend a PATH adjusting command when using these with add_custom_command. Change-Id: I7f58581f5060c8004b5d1fa1f6f17297256783de Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 14 ++++++++++++++ cmake/QtResource.cmake.in | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 3f26e828215..dcbe7646432 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -63,6 +63,20 @@ SET(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for instal # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +function(qt_setup_tool_path_command) + if(NOT WIN32) + return() + endif() + set(bindir "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}") + file(TO_NATIVE_PATH "${bindir}" bindir) + list(APPEND command "${CMAKE_COMMAND}") + list(APPEND command -E) + list(APPEND command env) + list(APPEND command set \"PATH=${bindir}$%PATH%\") + set(QT_TOOL_PATH_SETUP_COMMAND "${command}" CACHE INTERNAL "internal command prefix for tool invocations" FORCE) +endfunction() +qt_setup_tool_path_command() + # Platform define path, etc. set(QT_QMAKE_TARGET_MKSPEC "") if(WIN32) diff --git a/cmake/QtResource.cmake.in b/cmake/QtResource.cmake.in index 8474183882d..3f33ba50e56 100644 --- a/cmake/QtResource.cmake.in +++ b/cmake/QtResource.cmake.in @@ -98,9 +98,10 @@ function(__qt_quick_compiler_process_resources target resource_name) set(compiled_file "${CMAKE_CURRENT_BINARY_DIR}/qmlcache/${resource_name}/${compiled_file}.cpp") add_custom_command( OUTPUT ${compiled_file} - DEPENDS ${file_absolute} + DEPENDS ${file_absolute} @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen COMMAND - @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen + ${QT_TOOL_PATH_SETUP_COMMAND} + $ --resource-path ${file_resource_path} -o ${compiled_file} ${file_absolute} @@ -131,9 +132,10 @@ function(__qt_quick_compiler_process_resources target resource_name) add_custom_command( OUTPUT ${qmlcache_loader_file} - DEPENDS ${qmlcache_loader_list} + DEPENDS ${qmlcache_loader_list} @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen COMMAND - @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen + ${QT_TOOL_PATH_SETUP_COMMAND} + $ ${retained_args} --resource-name "${resource_name_arg}" -o ${qmlcache_loader_file}