diff options
author | Craig Scott <craig.scott@qt.io> | 2021-03-29 15:00:27 +1100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-30 18:48:15 +0000 |
commit | 43cd08cde3e9115753a6b3a817419f199c703405 (patch) | |
tree | 2832736433408f7f661d10960d169aae8c335e1f /src | |
parent | c3cc4c7abba34107f3c32dcc2fda2b6fcede35fe (diff) |
Prevent CMP0116 warning with CMake 3.20 or later
CMake 3.20 introduced a change in the handling of relative paths in *.d
depfiles referenced by custom commands. To avoid a CMP0116 policy
warning, we have to explicitly set the policy to NEW and also change
the relative path(s) we embed in the depfiles to be relative to
CMAKE_CURRENT_BINARY_DIR rather than the top level binary directory.
Fixes: QTBUG-92026
Change-Id: I1a84d29f1a8d5c48bae5bc11596806f1e0e07919
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 8deb1b279fad2b10598af0870dd3b0d99f5ef128)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 6e8bfb7d37..f9af50dcad 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -767,14 +767,6 @@ function(qt6_qml_type_registration target) set(foreign_types_file "${target_binary_dir}/qmltypes/${target}_foreign_types.txt") set(type_registration_cpp_file "${target_binary_dir}/${type_registration_cpp_file_name}") - set(dependency_file_cpp "${target_binary_dir}/qmltypes/${type_registration_cpp_file_name}.d") - file(RELATIVE_PATH cpp_file_name "${${CMAKE_PROJECT_NAME}_BINARY_DIR}" "${type_registration_cpp_file}") - - set (use_dep_files FALSE) - if (CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "Ninja Multi-Config") - set(use_dep_files TRUE) - endif() - # Enable evaluation of metatypes.json source interfaces set_target_properties(${target} PROPERTIES QT_CONSUMES_METATYPES TRUE) set(genex_list "$<REMOVE_DUPLICATES:$<FILTER:$<TARGET_PROPERTY:${target},SOURCES>,INCLUDE,metatypes.json$>>") @@ -796,9 +788,22 @@ function(qt6_qml_type_registration target) message(FATAL_ERROR "Need target metatypes.json file") endif() + cmake_policy(PUSH) + set(registration_cpp_file_dep_args) - if (use_dep_files) + if (CMAKE_GENERATOR MATCHES "Ninja") # TODO: Makefiles supported too since CMake 3.20 + 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() + set(dependency_file_cpp "${target_binary_dir}/qmltypes/${type_registration_cpp_file_name}.d") set(registration_cpp_file_dep_args DEPFILE ${dependency_file_cpp}) + file(RELATIVE_PATH cpp_file_name "${relative_to_dir}" "${type_registration_cpp_file}") file(GENERATE OUTPUT "${dependency_file_cpp}" CONTENT "${cpp_file_name}: $<IF:$<BOOL:${genex_list}>,\\\n$<JOIN:${genex_list}, \\\n>, \\\n>" ) @@ -833,6 +838,8 @@ function(qt6_qml_type_registration target) COMMENT "Automatic QML type registration for target ${target}" ) + cmake_policy(POP) + target_sources(${target} PRIVATE ${type_registration_cpp_file}) # Circumvent "too many sections" error when doing a 32 bit debug build on Windows with |