Use IMPORTED_LOCATION of rcc target
Use IMPORTED_LOCATION of rcc target when generating Android deployment settings, instead of the hardcoded host path. Introduce a helper function to find the location of the imported tool target. Change-Id: Icfa51ee7a01b3f58fc4892da03055f9ed531cc0b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
1b672951ca
commit
f9e48854af
@ -303,6 +303,7 @@ set(__public_cmake_helpers
|
||||
cmake/QtPublicFinalizerHelpers.cmake
|
||||
cmake/QtPublicPluginHelpers.cmake
|
||||
cmake/QtPublicTargetHelpers.cmake
|
||||
cmake/QtPublicToolHelpers.cmake
|
||||
cmake/QtPublicWalkLibsHelpers.cmake
|
||||
cmake/QtPublicFindPackageHelpers.cmake
|
||||
cmake/QtPublicDependencyHelpers.cmake
|
||||
|
@ -545,6 +545,7 @@ include(QtPublicTargetHelpers)
|
||||
include(QtPublicWalkLibsHelpers)
|
||||
include(QtPublicFindPackageHelpers)
|
||||
include(QtPublicDependencyHelpers)
|
||||
include(QtPublicToolHelpers)
|
||||
|
||||
# TODO: This block provides support for old variables. It should be removed once
|
||||
# we remove all references to these variables in other Qt module repos.
|
||||
|
@ -91,6 +91,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTargetHelpers.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicWalkLibsHelpers.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFindPackageHelpers.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicDependencyHelpers.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicToolHelpers.cmake")
|
||||
|
||||
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
||||
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
||||
|
43
cmake/QtPublicToolHelpers.cmake
Normal file
43
cmake/QtPublicToolHelpers.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
# The function returns location of the imported 'tool', returns an empty string if tool is not
|
||||
# imported.
|
||||
function(__qt_internal_get_tool_imported_location out_var tool)
|
||||
unset(${out_var})
|
||||
if("${tool}" MATCHES "^Qt[0-9]?::.+$")
|
||||
# The tool target has namespace already
|
||||
set(target ${tool})
|
||||
else()
|
||||
set(target ${QT_CMAKE_EXPORT_NAMESPACE}::${tool})
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${target})
|
||||
message(FATAL_ERROR "${target} is not a target.")
|
||||
endif()
|
||||
|
||||
get_target_property(is_imported ${target} IMPORTED)
|
||||
if(NOT is_imported)
|
||||
set(${out_var} "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(configs ${target} IMPORTED_CONFIGURATIONS)
|
||||
list(TRANSFORM configs PREPEND _)
|
||||
# Well-known configuration types
|
||||
list(APPEND
|
||||
_RELWITHDEBINFO
|
||||
_RELEASE
|
||||
_MINSIZEREL
|
||||
_DEBUG
|
||||
)
|
||||
list(REMOVE_DUPLICATES configs)
|
||||
# Look for the default empty configuration type at the first place.
|
||||
list(PREPEND configs "")
|
||||
|
||||
foreach(config ${configs})
|
||||
get_target_property(${out_var} ${target} "IMPORTED_LOCATION${config}")
|
||||
if(${out_var})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
||||
endfunction()
|
@ -17,6 +17,35 @@ function(_qt_internal_android_get_sdk_build_tools_revision out_var)
|
||||
set(${out_var} "${android_build_tools_latest}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# The function appends to the 'out_var' a 'json_property' that contains the 'tool' path. If 'tool'
|
||||
# target or its IMPORTED_LOCATION are not found the function displays warning, but is not failing
|
||||
# at the project configuring phase.
|
||||
function(_qt_internal_add_tool_to_android_deployment_settings out_var tool json_property target)
|
||||
unset(tool_binary_path)
|
||||
__qt_internal_get_tool_imported_location(tool_binary_path ${tool})
|
||||
if("${tool_binary_path}" STREQUAL "")
|
||||
# Fallback search for the tool in host bin and host libexec directories
|
||||
find_program(tool_binary_path
|
||||
NAMES ${tool} ${tool}.exe
|
||||
PATHS
|
||||
"${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}"
|
||||
"${QT_HOST_PATH}/${QT6_HOST_INFO_LIBEXECDIR}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT tool_binary_path)
|
||||
message(WARNING "Unable to locate ${tool}. Android package deployment of ${target}"
|
||||
" target can be incomplete. Make sure the host Qt has ${tool} installed.")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(TO_CMAKE_PATH "${tool_binary_path}" tool_binary_path)
|
||||
string(APPEND ${out_var}
|
||||
" \"${json_property}\" : \"${tool_binary_path}\",\n")
|
||||
|
||||
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Generate the deployment settings json file for a cmake target.
|
||||
function(qt6_android_generate_deployment_settings target)
|
||||
# Information extracted from mkspecs/features/android/android_deployment_settings.prf
|
||||
@ -241,13 +270,7 @@ function(qt6_android_generate_deployment_settings target)
|
||||
" \"qml-importscanner-binary\" : \"${qml_importscanner_binary_path_native}\",\n")
|
||||
|
||||
# Override rcc binary path
|
||||
set(rcc_binary_path "${QT_HOST_PATH}/${QT6_HOST_INFO_LIBEXECDIR}/rcc")
|
||||
if (WIN32)
|
||||
string(APPEND rcc_binary_path ".exe")
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "${rcc_binary_path}" rcc_binary_path_native)
|
||||
string(APPEND file_contents
|
||||
" \"rcc-binary\" : \"${rcc_binary_path_native}\",\n")
|
||||
_qt_internal_add_tool_to_android_deployment_settings(file_contents rcc "rcc-binary" "${target}")
|
||||
|
||||
# Extra prefix paths
|
||||
foreach(prefix IN LISTS CMAKE_FIND_ROOT_PATH)
|
||||
|
Loading…
Reference in New Issue
Block a user