summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-12-16 12:55:07 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-02-02 14:36:36 +0100
commitef5da25931100de4f824d9609d25b2f0434d46d0 (patch)
tree64453a657a251ccc5e809f4df3f734066ae79a5c /cmake
parent8920874387a80e36926c19ea33cafc75ee8590cf (diff)
CMake: Allow installing examples outside of the Qt prefix
Introduce a new QT_INTERNAL_CUSTOM_INSTALL_DIR variable to allow specifying an 'examples install dir' outside of the Qt prefix. It will be used in a follow-up change to ensure we don't package the example binaries in our CI artifacts (thus saving space). This will be even more important when the examples will contain code to deploy Qt libraries alongside each deployed example (which would significantly increase the package size). Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: I06b4a8f9e8c57a712a356bca0f5c351a9362bc30 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 1031fa15472bba3f20691cda2305e0821391c5db) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake9
-rw-r--r--cmake/QtPostProcessHelpers.cmake6
2 files changed, 14 insertions, 1 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index ae7f8ec0db..87dd783e4c 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -1063,6 +1063,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).
@@ -1089,7 +1090,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 60a745c0f5..12e44113b2 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.