summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-11-24 17:19:25 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2021-11-30 20:16:13 +0100
commit34fc4770e7eb39946b11ff070e3d9b5c43e75ac0 (patch)
treea29703249f614c43d5ab2781d8e8d684589cfa57 /src
parentd162ce3732bc125ad42c5c5e98050a8e09ab9054 (diff)
Fix the path to the build dir when creating an androiddeployqt depfile
According to the CMake documentation any relative paths in DEPFILE should be relative to the CMAKE_CURRENT_BINARY_DIR if the CMP0116 is set to NEW. This also forces CMP0116 to NEW if the policy exists. Pick-to: 6.2 Change-Id: I3d697b008ea06effb2247bc204da9bcc4e9046b4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 9495be94e5..52a5deca8c 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -373,10 +373,22 @@ function(qt6_android_add_apk_target target)
if(QT_ENABLE_VERBOSE_DEPLOYMENT)
list(APPEND extra_args "--verbose")
endif()
+
# The DEPFILE argument to add_custom_command is only available with Ninja or CMake>=3.20 and
# make.
if(CMAKE_GENERATOR MATCHES "Ninja" OR
(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 AND CMAKE_GENERATOR MATCHES "Makefiles"))
+ cmake_policy(PUSH)
+ if(POLICY CMP0116)
+ # Without explicitly setting this policy to NEW, we get a warning
+ # even though we ensure there's actually no problem here.
+ # See https://gitlab.kitware.com/cmake/cmake/-/issues/21959
+ cmake_policy(SET CMP0116 NEW)
+ set(relative_to_dir ${CMAKE_CURRENT_BINARY_DIR})
+ else()
+ set(relative_to_dir ${CMAKE_BINARY_DIR})
+ endif()
+
# Add custom command that creates the apk and triggers rebuild if files listed in
# ${dep_file_path} are changed.
add_custom_command(OUTPUT "${apk_final_file_path}"
@@ -388,12 +400,13 @@ function(qt6_android_add_apk_target target)
--output "${apk_final_dir}"
--apk "${apk_final_file_path}"
--depfile "${dep_file_path}"
- --builddir "${CMAKE_BINARY_DIR}"
+ --builddir "${relative_to_dir}"
${extra_args}
COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
DEPFILE "${dep_file_path}"
)
+ cmake_policy(POP)
# Create a ${target}_make_apk target to trigger the apk build.
add_custom_target(${target}_make_apk DEPENDS "${apk_final_file_path}")