Skip to content

Commit

Permalink
CMake: Don't cache QT_SYNCQT across builds
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jobor committed Sep 3, 2021
1 parent 4d8fb1b commit 60f3600
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 0 additions & 4 deletions cmake/QtBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 13 additions & 6 deletions cmake/QtSyncQtHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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)
Expand Down

0 comments on commit 60f3600

Please sign in to comment.