diff options
Diffstat (limited to 'src/corelib/doc/snippets/cmake-macros/examples.cmake')
-rw-r--r-- | src/corelib/doc/snippets/cmake-macros/examples.cmake | 103 |
1 files changed, 56 insertions, 47 deletions
diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cmake b/src/corelib/doc/snippets/cmake-macros/examples.cmake index 56d667914d..09b7470962 100644 --- a/src/corelib/doc/snippets/cmake-macros/examples.cmake +++ b/src/corelib/doc/snippets/cmake-macros/examples.cmake @@ -1,82 +1,78 @@ -#! [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] #! [qt_add_resources_target] -add_executable(myapp main.cpp) +qt_add_executable(myapp main.cpp) qt_add_resources(myapp "images" PREFIX "/images" FILES image1.png image2.png) #! [qt_add_resources_target] -#! [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_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) -target_link_libraries(myapp Qt5::Gui Qt5::Sql) +qt_add_executable(myapp main.cpp) +target_link_libraries(myapp Qt::Gui Qt::Sql) qt_import_plugins(myapp - INCLUDE Qt5::QCocoaIntegrationPlugin - EXCLUDE Qt5::QMinimalIntegrationPlugin - INCLUDE_BY_TYPE imageformats Qt5::QGifPlugin Qt5::QJpegPlugin + INCLUDE Qt::QCocoaIntegrationPlugin + EXCLUDE Qt::QMinimalIntegrationPlugin + INCLUDE_BY_TYPE imageformats Qt::QGifPlugin Qt::QJpegPlugin EXCLUDE_BY_TYPE sqldrivers ) #! [qt_import_plugins] @@ -95,3 +91,16 @@ qt_finalize_target(complexapp) 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] |