From 16df037f9dcced9b3efc7457e50491ce0363e125 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 20 Mar 2020 10:03:59 +0100 Subject: [PATCH] CMake: Fix metatype file generation not to happen in the source dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building qtdeclarative in a non-prefix configuration, metatypes.json files were created in the source dir. This happened because the default arg_INSTALL_DIR value is relative in qt6_generate_meta_types_json_file, and thus a file(TOUCH) with a relative path creats it in the source dir. The fix is to check if it's relative during a non-prefix build, and make it absolute (relative to the install prefix, which is the qtbase build dir). Change-Id: Ie9abbd5d93a64e79184d77655d8d8399e894fde5 Reviewed-by: Simon Hausmann Reviewed-by: Leander Beernaert Reviewed-by: MÃ¥rten Nordheim --- src/corelib/Qt6CoreMacros.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 4940eaa44dd..4a1e4a6821b 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -768,6 +768,13 @@ function(qt6_generate_meta_types_json_file target) file(MAKE_DIRECTORY "${target_binary_dir}/meta_types") file(TOUCH ${metatypes_file}) endif() + + # Need to make the path absolute during a Qt non-prefix build, otherwise files are written + # to the source dir because the paths are relative to the source dir when using file(TOUCH). + if(arg_COPY_OVER_INSTALL AND NOT IS_ABSOLUTE "${arg_INSTALL_DIR}/${metatypes_file_name}") + set(arg_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${arg_INSTALL_DIR}") + endif() + if (arg_COPY_OVER_INSTALL AND NOT EXISTS ${arg_INSTALL_DIR}/${metatypes_file_name}) file(MAKE_DIRECTORY "${arg_INSTALL_DIR}") file(TOUCH "${arg_INSTALL_DIR}/${metatypes_file_name}")