aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-03-29 15:00:27 +1100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-30 15:39:58 +0000
commita80ce81b5fe7befde34e4fbab91e09013288f284 (patch)
tree6e0bed543806cedb60f3067c14a5a32c0d1ccebf /src
parentbc5ae286c891e40aed6f483d78eac43905ea5c17 (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.cmake25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index a1b7408e2f..ce179b567f 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -773,14 +773,6 @@ function(qt6_qml_type_registration target)
set(foreign_types_file "${target_binary_dir}/qmltypes/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$>>")
@@ -802,9 +794,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>"
)
@@ -835,6 +840,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