diff options
author | Alexandru Croitor <[email protected]> | 2024-03-18 19:03:03 +0100 |
---|---|---|
committer | Alexandru Croitor <[email protected]> | 2024-03-27 18:57:34 +0100 |
commit | a6bd1dc3e0c3dc118b281afbc60d9de3aefc48fa (patch) | |
tree | d281d6689ca8c438d1df6890ac4ffe972510c121 /examples/quickcontrols/chattutorial | |
parent | 8f741c5496e1aed071db42895fb465bc0419cd48 (diff) |
CMake: Add deployment API to our examples
Projects were modified using the tool at:
https://git.qt.io/alcroito/cmake_refactor
A few examples had to be adapted manually, mostly those that build
additional qml modules / plugins.
The INSTALL_EXAMPLESDIR and INSTALL_EXAMPLEDIR assignments were
removed, these are not needed anymore because example directory
selection is handled by the qt_internal_add_example calls.
The install(TARGETS) calls were modified according to our
documentation snippets for qt_generate_deploy_qml_app_script.
A qt_generate_deploy_qml_app_script call was added for each
executable target.
Note that the deployment step will be skipped in the CI for now,
because:
- we enable QT_DEPLOY_MINIMAL_EXAMPLES in the CI instructions and thus
set QT_INTERNAL_SKIP_DEPLOYMENT to true
- standalone examples feature is not yet enabled in the CI, which
means we continue to build examples in-tree, and deployment is
disabled for in-tree prefix builds.
A small list of examples to deploy in the CI will be chosen in the
future, to ensure deployment coverage, without slowing down overall CI
times due to all the *deployqt invocations.
Even if deployment is disabled in the CI, the install(TARGETS) calls
for each example will still run, installing into an
'installed_examples' directory, which will not be archived by the CI.
The QtBundleQmlModuleForMacOS and bundle_shared code was removed,
because we can now depend on the MACOS_BUNDLE_POST_BUILD option of the
deployment api, to ensure macOS bundle examples run properly in the
build dir. This works even in prefix in-tree builds, when installation
deployment is disabled.
Finally, for all examples that build additional qml module libraries or
plugins, the libraries / plugins must be installed into the bin dir of
each project, along with a qmldir file.
This is to support running the installed project for platforms that
don't have deployment api yet, like boot2qt / yocto.
If we want to have super clean install / deployment rules in the
future, we won't be able to avoid adding ugly per-platform conditions.
The current status quo is deemed an improvement over what we had
before.
Pick-to: 6.7
Task-number: QTBUG-101340
Task-number: QTBUG-102056
Task-number: QTBUG-102057
Change-Id: I843d934668c25dbcd1abca52495b393579633fc5
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Alexey Edelev <[email protected]>
Diffstat (limited to 'examples/quickcontrols/chattutorial')
5 files changed, 60 insertions, 45 deletions
diff --git a/examples/quickcontrols/chattutorial/chapter1/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter1/CMakeLists.txt index d3b4bd5b70..c17c054418 100644 --- a/examples/quickcontrols/chattutorial/chapter1/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter1/CMakeLists.txt @@ -6,12 +6,6 @@ project(chapter1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/chattutorial/chapter1") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) qt_add_executable(chattutorial-chapter1 WIN32 MACOSX_BUNDLE @@ -40,7 +34,16 @@ qt6_add_resources(chattutorial-chapter1 "conf" ) install(TARGETS chattutorial-chapter1 - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_qml_app_script( + TARGET chattutorial-chapter1 + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) +install(SCRIPT ${deploy_script}) diff --git a/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt index 60af57d790..b6e37b4449 100644 --- a/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt @@ -6,12 +6,6 @@ project(chapter2 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/chattutorial/chapter2") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) qt_add_executable(chattutorial-chapter2 WIN32 MACOSX_BUNDLE @@ -53,7 +47,16 @@ qt6_add_resources(chattutorial-chapter2 "conf" ) install(TARGETS chattutorial-chapter2 - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_qml_app_script( + TARGET chattutorial-chapter2 + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) +install(SCRIPT ${deploy_script}) diff --git a/examples/quickcontrols/chattutorial/chapter3/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter3/CMakeLists.txt index b69cfa58cc..a101f3ebb3 100644 --- a/examples/quickcontrols/chattutorial/chapter3/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter3/CMakeLists.txt @@ -6,12 +6,6 @@ project(chapter3 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/chattutorial/chapter3") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) qt_add_executable(chattutorial-chapter3 WIN32 MACOSX_BUNDLE @@ -55,7 +49,16 @@ qt6_add_resources(chattutorial-chapter3 "conf" ) install(TARGETS chattutorial-chapter3 - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_qml_app_script( + TARGET chattutorial-chapter3 + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) +install(SCRIPT ${deploy_script}) diff --git a/examples/quickcontrols/chattutorial/chapter4/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter4/CMakeLists.txt index d1a4f99a41..2d5b930e45 100644 --- a/examples/quickcontrols/chattutorial/chapter4/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter4/CMakeLists.txt @@ -6,12 +6,6 @@ project(chapter4 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/chattutorial/chapter4") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Sql) qt_add_executable(chattutorial-chapter4 WIN32 MACOSX_BUNDLE @@ -58,7 +52,16 @@ qt6_add_resources(chattutorial-chapter4 "conf" ) install(TARGETS chattutorial-chapter4 - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_qml_app_script( + TARGET chattutorial-chapter4 + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) +install(SCRIPT ${deploy_script}) diff --git a/examples/quickcontrols/chattutorial/chapter5/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter5/CMakeLists.txt index 5c3c0d6faf..fa20c96d2d 100644 --- a/examples/quickcontrols/chattutorial/chapter5/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter5/CMakeLists.txt @@ -6,12 +6,6 @@ project(chapter5 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols/chattutorial/chapter5") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Sql) qt_add_executable(chattutorial-chapter5 WIN32 MACOSX_BUNDLE @@ -60,7 +54,16 @@ qt6_add_resources(chattutorial-chapter5 "conf" ) install(TARGETS chattutorial-chapter5 - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_qml_app_script( + TARGET chattutorial-chapter5 + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM ) +install(SCRIPT ${deploy_script}) |