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)