diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-03-18 13:21:08 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-03-22 20:23:52 +0100 |
commit | 3b30b0fc2e1cda30b83bd2de1f70b3ee0c83ba46 (patch) | |
tree | f6ad0c88ee352de901fafbf56aa948e8bb78aad7 /examples/corelib/serialization | |
parent | 84dc1f21235db7d0ea59a7f20fa9e811958cef1f (diff) |
CMake: Add deployment API to our examples
Projects were modified using the tool at:
https://git.qt.io/alcroito/cmake_refactor
A couple of examples had to be adapted manually, due to them including
more than one app per example subdirectory.
The INSTALL_EXAMPLESDIR and INSTALL_EXAMPLEDIR assignments were
removed.
The install(TARGETS) calls were modified according to our
documentation snippets for qt_generate_deploy_app_script.
A qt_generate_deploy_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 and thus
QT_INTERNAL_SKIP_DEPLOYMENT, and also because standalone examples
are not enabled yet, and deployment is disabled for in-tree (so
no-standalone-example) prefix builds.
The install(TARGETS) calls for each example will still run,
installing the examples into an installed_examples directory, that
will not be archived by the CI.
Pick-to: 6.7
Task-number: QTBUG-102056
Task-number: QTBUG-102057
Change-Id: Ida389bbad41710b2ae5da4d95e2d85be9e0cd9ce
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'examples/corelib/serialization')
4 files changed, 40 insertions, 36 deletions
diff --git a/examples/corelib/serialization/cbordump/CMakeLists.txt b/examples/corelib/serialization/cbordump/CMakeLists.txt index 36eacf9461..b2c3a536e3 100644 --- a/examples/corelib/serialization/cbordump/CMakeLists.txt +++ b/examples/corelib/serialization/cbordump/CMakeLists.txt @@ -8,12 +8,6 @@ if (ANDROID) message(FATAL_ERROR "This project cannot be built on Android.") endif() -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/cbordump") - find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() @@ -27,7 +21,14 @@ target_link_libraries(cbordump PRIVATE ) install(TARGETS cbordump - 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_app_script( + TARGET cbordump + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/corelib/serialization/convert/CMakeLists.txt b/examples/corelib/serialization/convert/CMakeLists.txt index 4cd3bc74d1..24ad5bbb6a 100644 --- a/examples/corelib/serialization/convert/CMakeLists.txt +++ b/examples/corelib/serialization/convert/CMakeLists.txt @@ -8,12 +8,6 @@ if (ANDROID) message(FATAL_ERROR "This project cannot be built on Android.") endif() -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/convert") - find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() @@ -36,7 +30,14 @@ target_link_libraries(convert PRIVATE ) install(TARGETS convert - 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_app_script( + TARGET convert + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/corelib/serialization/savegame/CMakeLists.txt b/examples/corelib/serialization/savegame/CMakeLists.txt index aa901bd699..14621ccc23 100644 --- a/examples/corelib/serialization/savegame/CMakeLists.txt +++ b/examples/corelib/serialization/savegame/CMakeLists.txt @@ -8,12 +8,6 @@ if (ANDROID) message(FATAL_ERROR "This project cannot be built on Android.") endif() -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/savegame") - find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() @@ -30,7 +24,14 @@ target_link_libraries(savegame PRIVATE ) install(TARGETS savegame - 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_app_script( + TARGET savegame + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/corelib/serialization/streambookmarks/CMakeLists.txt b/examples/corelib/serialization/streambookmarks/CMakeLists.txt index 38c5e7f303..bad55fa661 100644 --- a/examples/corelib/serialization/streambookmarks/CMakeLists.txt +++ b/examples/corelib/serialization/streambookmarks/CMakeLists.txt @@ -4,12 +4,6 @@ cmake_minimum_required(VERSION 3.16) project(streambookmarks LANGUAGES CXX) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/streambookmarks") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) qt_standard_project_setup() @@ -33,7 +27,14 @@ target_link_libraries(streambookmarks PRIVATE ) install(TARGETS streambookmarks - 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_app_script( + TARGET streambookmarks + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) |