diff options
Diffstat (limited to 'src/corelib/doc/snippets/cmake-macros')
-rw-r--r-- | src/corelib/doc/snippets/cmake-macros/deployment.cmake | 27 | ||||
-rw-r--r-- | src/corelib/doc/snippets/cmake-macros/examples.cmake | 115 | ||||
-rw-r--r-- | src/corelib/doc/snippets/cmake-macros/examples.cpp | 16 |
3 files changed, 116 insertions, 42 deletions
diff --git a/src/corelib/doc/snippets/cmake-macros/deployment.cmake b/src/corelib/doc/snippets/cmake-macros/deployment.cmake new file mode 100644 index 0000000000..ef7aa726c0 --- /dev/null +++ b/src/corelib/doc/snippets/cmake-macros/deployment.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#! [qt_generate_deploy_script_example] +cmake_minimum_required(VERSION 3.16...3.22) +project(MyThings) + +find_package(Qt6 REQUIRED COMPONENTS Core) +qt_standard_project_setup() + +qt_add_executable(MyApp main.cpp) + +install(TARGETS MyApp + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +qt_generate_deploy_script( + TARGET MyApp + OUTPUT_SCRIPT deploy_script + CONTENT " +qt_deploy_runtime_dependencies( + EXECUTABLE $<TARGET_FILE_NAME:MyApp> +) +") +install(SCRIPT ${deploy_script}) +#! [qt_generate_deploy_script_example] diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cmake b/src/corelib/doc/snippets/cmake-macros/examples.cmake index 913b39cb4f..09b7470962 100644 --- a/src/corelib/doc/snippets/cmake-macros/examples.cmake +++ b/src/corelib/doc/snippets/cmake-macros/examples.cmake @@ -1,75 +1,106 @@ -#! [qt5_wrap_cpp] -set(SOURCES myapp.cpp main.cpp) -qt5_wrap_cpp(SOURCES myapp.h) -add_executable(myapp ${SOURCES}) -#! [qt5_wrap_cpp] +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#! [qt_wrap_cpp] +#! [qt_wrap_cpp_1] set(SOURCES myapp.cpp main.cpp) qt_wrap_cpp(SOURCES myapp.h) -add_executable(myapp ${SOURCES}) -#! [qt_wrap_cpp] +qt_add_executable(myapp ${SOURCES}) +#! [qt_wrap_cpp_1] -#! [qt5_add_resources] -set(SOURCES main.cpp) -qt5_add_resources(SOURCES example.qrc) -add_executable(myapp ${SOURCES}) -#! [qt5_add_resources] +#! [qt_wrap_cpp_2] +set(SOURCES myapp.cpp main.cpp) +qt_wrap_cpp(SOURCES myapp.h + TARGET myapp + OPTIONS + "$<$<CONFIG:Debug>:-DMY_OPTION_FOR_DEBUG>" + "-DDEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)" + "$<$<CONFIG:Debug>:-DDEFINE_CMDLINE_SIGNAL_IN_GENEX=void cmdlineSignal(const QMap<int$<COMMA> int$<ANGLE-R> &i)>") +qt_add_executable(myapp ${SOURCES}) +#! [qt_wrap_cpp_2] + +#! [qt_wrap_cpp_3] +set(SOURCES myapp.cpp main.cpp) +qt_wrap_cpp(SOURCES myapp.h + TARGET myapp) +qt_add_executable(myapp ${SOURCES}) +target_compile_definitions(myapp PRIVATE "$<$<CONFIG:Debug>:MY_OPTION_FOR_DEBUG>" + "DEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)" + "$<$<BOOL:TRUE>:DEFINE_CMDLINE_SIGNAL_IN_GENEX=void cmdlineSignal(const QMap<int$<COMMA> int$<ANGLE-R> &i)>") +#! [qt_wrap_cpp_3] + +#! [qt_wrap_cpp_4] +qt_add_executable(myapp myapp.cpp main.cpp) +qt_wrap_cpp("" myapp.cpp TARGET myapp) +#! [qt_wrap_cpp_4] #! [qt_add_resources] set(SOURCES main.cpp) qt_add_resources(SOURCES example.qrc) -add_executable(myapp ${SOURCES}) +qt_add_executable(myapp ${SOURCES}) #! [qt_add_resources] -#! [qt5_add_big_resources] -set(SOURCES main.cpp) -qt5_add_big_resources(SOURCES big_resource.qrc) -add_executable(myapp ${SOURCES}) -#! [qt5_add_big_resources] +#! [qt_add_resources_target] +qt_add_executable(myapp main.cpp) +qt_add_resources(myapp "images" + PREFIX "/images" + FILES image1.png image2.png) +#! [qt_add_resources_target] #! [qt_add_big_resources] set(SOURCES main.cpp) qt_add_big_resources(SOURCES big_resource.qrc) -add_executable(myapp ${SOURCES}) -#! [qt_add_big_resources] -#! [qt5_add_binary_resources] -qt5_add_binary_resources(resources project.qrc OPTIONS -no-compress) -add_dependencies(myapp resources) -#! [qt5_add_binary_resources] +# Have big_resource.qrc treated as a source file by Qt Creator +list(APPEND SOURCES big_resource.qrc) +set_property(SOURCE big_resource.qrc PROPERTY SKIP_AUTORCC ON) + +qt_add_executable(myapp ${SOURCES}) +#! [qt_add_big_resources] #! [qt_add_binary_resources] qt_add_binary_resources(resources project.qrc OPTIONS -no-compress) add_dependencies(myapp resources) #! [qt_add_binary_resources] -#! [qt5_generate_moc] -qt5_generate_moc(main.cpp main.moc TARGET myapp) -#! [qt5_generate_moc] - #! [qt_generate_moc] qt_generate_moc(main.cpp main.moc TARGET myapp) #! [qt_generate_moc] -#! [qt5_import_plugins] -add_executable(myapp main.cpp) -target_link_libraries(myapp Qt5::Gui Qt5::Sql) -qt5_import_plugins(myapp - INCLUDE Qt5::QCocoaIntegrationPlugin - EXCLUDE Qt5::QMinimalIntegrationPlugin - INCLUDE_BY_TYPE imageformats Qt5::QGifPlugin Qt5::QJpegPlugin - EXCLUDE_BY_TYPE sqldrivers -) -#! [qt5_import_plugins] - #! [qt_import_plugins] -add_executable(myapp main.cpp) +qt_add_executable(myapp main.cpp) target_link_libraries(myapp Qt::Gui Qt::Sql) qt_import_plugins(myapp INCLUDE Qt::QCocoaIntegrationPlugin EXCLUDE Qt::QMinimalIntegrationPlugin - INCLUDE_BY_TYPE imageformats Qt5::QGifPlugin Qt5::QJpegPlugin + INCLUDE_BY_TYPE imageformats Qt::QGifPlugin Qt::QJpegPlugin EXCLUDE_BY_TYPE sqldrivers ) #! [qt_import_plugins] + +#! [qt_add_executable_simple] +qt_add_executable(simpleapp main.cpp) +#! [qt_add_executable_simple] + +#! [qt_add_executable_deferred] +qt_add_executable(complexapp MANUAL_FINALIZATION complex.cpp) +set_target_properties(complexapp PROPERTIES OUTPUT_NAME Complexify) +qt_finalize_target(complexapp) +#! [qt_add_executable_deferred] + +#! [qt_android_deploy_basic] +qt_android_generate_deployment_settings(myapp) +qt_android_add_apk_target(myapp) +#! [qt_android_deploy_basic] + +#! [qt_finalize_project_manual] +cmake_minimum_required(VERSIONS 3.16) + +project(MyProject LANGUAGES CXX) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(MyApp main.cpp) +add_subdirectory(mylib) + +qt_finalize_project() +#! [qt_finalize_project_manual] diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cpp b/src/corelib/doc/snippets/cmake-macros/examples.cpp new file mode 100644 index 0000000000..b17fcd8e77 --- /dev/null +++ b/src/corelib/doc/snippets/cmake-macros/examples.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [qt_wrap_cpp_4] +// myapp.cpp +#include "myapp.h" +#include <QObject> + +class MyApp : public QObject { + Q_OBJECT +public: + MyApp() = default; +}; + +#include "myapp.moc" +//! [qt_wrap_cpp_4] |