From 897ebf2d6782123f4c3b10fc0a6e76c57bc04b29 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 5 Jun 2025 13:23:49 +0200 Subject: [PATCH] CMake: Make qt-cmake-standalone-tests work from prefix build dir We didn't copy the standalone test template files into the build dir when configuring a prefix build. We also need to copy the mkspecs. Pick-to: 6.8 Change-Id: I517165b2b8db84b0766935e3d535a7a1ef2b6ad9 Reviewed-by: Joerg Bornemann (cherry picked from commit 587649deb7188d6944c31d991d0fd2a71f17ab4e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 20dfcf4c59becea25d62121f617d7aacf099fc76) --- cmake/QtBaseGlobalTargets.cmake | 14 ++++++++++++-- cmake/QtBaseHelpers.cmake | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index cf69c1f540d..15d2b887e20 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -55,11 +55,21 @@ qt_install(FILES DESTINATION "${__build_internals_install_dir}" COMPONENT Devel ) + +qt_path_join(__build_internals_standalone_test_template_path + "${CMAKE_CURRENT_SOURCE_DIR}" + "cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}") + qt_copy_or_install( - DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}" + DIRECTORY "${__build_internals_standalone_test_template_path}" DESTINATION "${__build_internals_install_dir}") +# In prefix builds we also need to copy the files into the build dir. +if(QT_WILL_INSTALL) + file(COPY "${__build_internals_standalone_test_template_path}" + DESTINATION "${__build_internals_install_dir}") +endif() + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}/CMakeLists.txt") diff --git a/cmake/QtBaseHelpers.cmake b/cmake/QtBaseHelpers.cmake index 0c3cca9dc1c..90d2cf8266f 100644 --- a/cmake/QtBaseHelpers.cmake +++ b/cmake/QtBaseHelpers.cmake @@ -137,7 +137,7 @@ macro(qt_internal_qtbase_install_mkspecs) LIST_DIRECTORIES TRUE "${PROJECT_SOURCE_DIR}/mkspecs/*") foreach(entry IN LISTS mkspecs_subdirs) - if (IS_DIRECTORY ${entry}) + if(IS_DIRECTORY ${entry}) qt_copy_or_install(DIRECTORY "${entry}" DESTINATION ${mkspecs_install_dir} USE_SOURCE_PERMISSIONS) @@ -145,6 +145,11 @@ macro(qt_internal_qtbase_install_mkspecs) qt_copy_or_install(FILES "${entry}" DESTINATION ${mkspecs_install_dir}) endif() + + # In prefix builds we also need to copy the files into the build dir. + if(QT_WILL_INSTALL) + file(COPY "${entry}" DESTINATION "${mkspecs_install_dir}") + endif() endforeach() endmacro()