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 <alexandru.croitor@qt.io>
This commit is contained in:
Simon Hausmann 2019-09-04 10:52:18 +02:00
parent 85e3bb7aea
commit 18fc9e1bf8
2 changed files with 20 additions and 4 deletions

View File

@ -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}$<SEMICOLON>%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)

View File

@ -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}
$<TARGET_FILE:@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen>
--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}
$<TARGET_FILE:@QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen>
${retained_args}
--resource-name "${resource_name_arg}"
-o ${qmlcache_loader_file}