diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-20 17:12:45 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-20 18:12:23 +0200 |
commit | 5e0129f63cbd45767342c43135f6061750511e33 (patch) | |
tree | 18b0a9331d618988d6247dfa1843a8599dbfdbe6 /cmake/QtBuildInternals | |
parent | bd143f7df3be50b15b617275b0db2aac292b9a26 (diff) |
CMake: Fix configuration of CMake tests in-build-tree
Qt6 package was not found the tests were configured in-tree as opposed
to standalone tests.
Use the same trick we do for building examples in-tree.
Specify the path to the build tree packages, and don't create targets.
Amends 96e3ee06598d00e7155f3f8574759ea658a134e5
Change-Id: Ia60de416ce0afff5bd40be8c0c6e3c7898fd7ebf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals')
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 2d94e384e5..95564e0599 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -414,18 +414,24 @@ function(qt_set_up_fake_standalone_tests_install_prefix) set(CMAKE_INSTALL_PREFIX "${new_install_prefix}" PARENT_SCOPE) endfunction() +# Mean to be called when configuring examples as part of the main build tree, as well as for CMake +# tests (tests that call CMake to try and build CMake applications). +macro(qt_internal_set_up_build_dir_package_paths) + list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") + # Make sure the CMake config files do not recreate the already-existing targets + set(QT_NO_CREATE_TARGETS TRUE) + set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH") +endmacro() + macro(qt_examples_build_begin) # Examples that are built as part of the Qt build need to use the CMake config files from the # build dir, because they are not installed yet in a prefix build. # Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake. # Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those # find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored. - list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") + qt_internal_set_up_build_dir_package_paths() list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") - # Also make sure the CMake config files do not recreate the already-existing targets - set(QT_NO_CREATE_TARGETS TRUE) - set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH") # Because CMAKE_INSTALL_RPATH is empty by default in the repo project, examples need to have # it set here, so they can run when installed. |