From 68c0e932a5acb7e3fe6dc34540fe4c81770eba88 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 18 Mar 2022 14:29:03 +0100 Subject: [PATCH] Unify DEPFILE support check Add common function that unifies the check for the DEPFILE support. Update the check according to the recent CMake version. Task-number: QTBUG-99354 Change-Id: Ia2abf46fe3a9a3d17ea7a37eaf6c9c6a697c5b84 Reviewed-by: Alexandru Croitor --- cmake/QtPublicCMakeHelpers.cmake | 14 ++++++++++++++ src/corelib/Qt6AndroidMacros.cmake | 8 +------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmake/QtPublicCMakeHelpers.cmake b/cmake/QtPublicCMakeHelpers.cmake index 86b8edacd49..35cd4fe1f36 100644 --- a/cmake/QtPublicCMakeHelpers.cmake +++ b/cmake/QtPublicCMakeHelpers.cmake @@ -18,3 +18,17 @@ function(_qt_internal_copy_file_if_different_command out_var src_file dst_file) ) endif() endfunction() + +# The function checks if add_custom_command has the support of the DEPFILE argument. +function(_qt_internal_check_depfile_support out_var) + if(CMAKE_GENERATOR MATCHES "Ninja" OR + CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 AND CMAKE_GENERATOR MATCHES "Makefiles" + OR CMAKE_VERSION VERSION_GREATER_EQUAL 3.21 + AND (CMAKE_GENERATOR MATCHES "Xcode" + OR CMAKE_GENERATOR MATCHES "Visual Studio ([0-9]+)" AND CMAKE_MATCH_1 GREATER_EQUAL 12)) + set(${out_var} TRUE) + else() + set(${out_var} FALSE) + endif() + set(${out_var} "${${out_var}}" PARENT_SCOPE) +endfunction() diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 0a3fc0ff79b..f56532625c6 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -388,13 +388,7 @@ function(qt6_android_add_apk_target target) list(APPEND extra_args "--verbose") endif() - # The DEPFILE argument to add_custom_command is only available with Ninja or CMake>=3.20 and - # make. - set(has_depfile_support FALSE) - if(CMAKE_GENERATOR MATCHES "Ninja" OR - (CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 AND CMAKE_GENERATOR MATCHES "Makefiles")) - set(has_depfile_support TRUE) - endif() + _qt_internal_check_depfile_support(has_depfile_support) if(has_depfile_support) cmake_policy(PUSH)