From 6c00d9075e19c949e6cf5b401fc4e42784fd5bf0 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 5 Sep 2019 18:17:00 +0200 Subject: [PATCH] Use $$source_path/qtbase/cmake modules when doing non-prefix builds This is similar to qmake, where the .prf files from the source location of qtbase/mkspecs are used in a non-prefix build. This means that if a developer changes the source QtBuild.cmake, and then runs make in qtdeclarative, cmake will reconfigure qtdeclarative because the timestamp of QtBuild.cmake changed. Before this change you first had to make && make install in the qtbase build directory, before qtdeclarative saw the modified QtBuild.cmake. This change also makes the module paths be prepended to CMAKE_MODULE_PATH instead of appended, which means they will take precedence to any path provided via command line. Change-Id: I9178d5183a95b3b67bfe1b1fe91d3d3371ffe5c5 Reviewed-by: Simon Hausmann --- .../QtBuildInternalsConfig.cmake | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 1ebd3217530..c7c6f757a4c 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -13,13 +13,24 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake") endif() macro(qt_set_up_build_internals_paths) - # Set up the paths for the modules. + # Set up the paths for the cmake modules located in the build dir. Prepend, so the paths are + # least important compared to the source dir ones, but more important than command line + # provided ones. set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}") - list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH}) + list(PREPEND CMAKE_MODULE_PATH "${QT_CMAKE_MODULE_PATH}") + + # When doing a non-prefix build, prepend the qtbase source cmake directory to CMAKE_MODULE_PATH, + # so that if a change is done in cmake/QtBuild.cmake, it gets automatically picked up when + # building qtdeclarative, rather than having to build qtbase first (which will copy + # QtBuild.cmake to the build dir). This is similar to qmake non-prefix builds, where the + # source qtbase/mkspecs directory is used. + if(NOT QT_WILL_INSTALL) + list(PREPEND CMAKE_MODULE_PATH "${QT_SOURCE_TREE}/cmake") + endif() # If the repo has its own cmake modules, include those in the module path. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif() endmacro()