diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 618f1205975..e37a018bb13 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -1086,6 +1086,7 @@ function(qt_internal_add_example_external_project subdir) # E.g. ensure qtbase/examples/widgets/widgets/wiggly is installed to # $qt_example_install_prefix/examples/widgets/widgets/wiggly/wiggly.exe # $qt_example_install_prefix defaults to ${CMAKE_INSTALL_PREFIX}/${INSTALL_EXAMPLEDIR} + # but can also be set to a custom location. # This needs to work both: # - when using ExternalProject to build examples # - when examples are built in-tree as part of Qt (no ExternalProject). @@ -1112,7 +1113,13 @@ function(qt_internal_add_example_external_project subdir) # example_source_dir, use _qt_internal_override_example_install_dir_to_dot to ensure # INSTALL_EXAMPLEDIR does not interfere. - set(qt_example_install_prefix "${CMAKE_INSTALL_PREFIX}/${INSTALL_EXAMPLESDIR}") + # Allow installing somewhere under the build dir. + if(QT_INTERNAL_CUSTOM_INSTALL_DIR) + set(qt_example_install_prefix "${QT_INTERNAL_CUSTOM_INSTALL_DIR}") + else() + set(qt_example_install_prefix "${CMAKE_INSTALL_PREFIX}/${INSTALL_EXAMPLESDIR}") + endif() + set(example_install_prefix "${qt_example_install_prefix}/${example_rel_path}") set(ep_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${subdir}") diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 60a745c0f54..12e44113b29 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -596,6 +596,12 @@ endif()\n") "set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING \"TRUE\" CACHE BOOL \"\" FORCE)\n") endif() + if(QT_INTERNAL_CUSTOM_INSTALL_DIR) + file(TO_CMAKE_PATH "${QT_INTERNAL_CUSTOM_INSTALL_DIR}" qt_internal_custom_install_dir) + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS + "set(QT_INTERNAL_CUSTOM_INSTALL_DIR \"${qt_internal_custom_install_dir}\" CACHE STRING \"\")\n") + endif() + # Save the default qpa platform. # Used by qtwayland/src/plugins/platforms/qwayland-generic/CMakeLists.txt. Otherwise # the DEFAULT_IF condition is evaluated incorrectly.