From 60f36007a361f4102a9cc0ceb65040ebc19d2653 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 27 Aug 2021 14:47:45 +0200 Subject: [PATCH] CMake: Don't cache QT_SYNCQT across builds There is no need for this variable to be stored in CMake's cache. We don't perform expensive operations to set up QT_SYNCQT, and we even unset the cache variable to ensure it gets recomputed on reconfiguration. We still store QT_SYNCQT in a global property, because the function qt_ensure_sync_qt is called in different directory scopes, and we want to avoid re-calculations for every subdir. It's now possible for the user to set QT_SYNCQT (see QTBUG-88088 for motivation). Also, in a non-prefix build, changes to syncqt.pl in the source dir are reflected upon re-configuration in the build tree (because qt_copy_or_install is called on every configure). Pick-to: 6.2 Fixes: QTBUG-88088 Task-number: QTBUG-75290 Change-Id: I6137b060d200d3dafd4a64d5a6c1bd2549723d78 Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 4 ---- cmake/QtSyncQtHelpers.cmake | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index f89512ae58b..ec3f25ca4f4 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -401,10 +401,6 @@ qt_internal_set_qt_known_plugins("") set(QT_KNOWN_MODULES_WITH_TOOLS "" CACHE INTERNAL "Known Qt modules with tools" FORCE) -# Reset syncqt cache variable, to make sure it gets recomputed on reconfiguration, otherwise -# it might not get installed. -unset(QT_SYNCQT CACHE) - # For adjusting variables when running tests, we need to know what # the correct variable is for separating entries in PATH-alike # variables. diff --git a/cmake/QtSyncQtHelpers.cmake b/cmake/QtSyncQtHelpers.cmake index 45a0a3b7fbc..894b19b48e7 100644 --- a/cmake/QtSyncQtHelpers.cmake +++ b/cmake/QtSyncQtHelpers.cmake @@ -14,11 +14,17 @@ function(qt_ensure_sync_qt) return() endif() + get_property(QT_SYNCQT GLOBAL PROPERTY _qt_syncqt) + if(NOT "${QT_SYNCQT}" STREQUAL "") + set(QT_SYNCQT "${QT_SYNCQT}" PARENT_SCOPE) + return() + endif() + # When building qtbase, use the source syncqt, otherwise use the installed one. set(SYNCQT_FROM_SOURCE "${QtBase_SOURCE_DIR}/libexec/syncqt.pl") if(NOT ("${QtBase_SOURCE_DIR}" STREQUAL "") AND EXISTS "${SYNCQT_FROM_SOURCE}") - set(QT_SYNCQT "${SYNCQT_FROM_SOURCE}" CACHE FILEPATH "syncqt script") - message(STATUS "Using source syncqt found at: ${QT_SYNCQT}") + set(syncqt_absolute_path "${SYNCQT_FROM_SOURCE}") + message(STATUS "Using source syncqt found at: ${syncqt_absolute_path}") qt_path_join(syncqt_install_dir ${QT_INSTALL_DIR} ${INSTALL_LIBEXECDIR}) qt_copy_or_install(PROGRAMS "${SYNCQT_FROM_SOURCE}" @@ -27,15 +33,16 @@ function(qt_ensure_sync_qt) get_filename_component(syncqt_absolute_path "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}/syncqt.pl" ABSOLUTE) - set(QT_SYNCQT "${syncqt_absolute_path}" CACHE FILEPATH "syncqt script") - message(STATUS "Using host syncqt found at: ${QT_SYNCQT}") + message(STATUS "Using host syncqt found at: ${syncqt_absolute_path}") else() get_filename_component(syncqt_absolute_path "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}/syncqt.pl" ABSOLUTE) - set(QT_SYNCQT "${syncqt_absolute_path}" CACHE FILEPATH "syncqt script") - message(STATUS "Using installed syncqt found at: ${QT_SYNCQT}") + message(STATUS "Using installed syncqt found at: ${syncqt_absolute_path}") endif() + + set(QT_SYNCQT "${syncqt_absolute_path}" PARENT_SCOPE) + set_property(GLOBAL PROPERTY _qt_syncqt "${syncqt_absolute_path}") endfunction() function(qt_install_injections target build_dir install_dir)