summaryrefslogtreecommitdiffstats
path: root/examples/CMakeLists.txt
blob: 5f61a098bd0a406d3d51f0dfe2b1f9c93de10a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# special case begin
cmake_minimum_required(VERSION 3.14.0)

project(QtBaseExamples LANGUAGES CXX C ASM)

# Check whether this project is built as part of a Qt build
if (CMAKE_PROJECT_NAME STREQUAL "QtBaseExamples")
    set(QT_STANDALONE_EXAMPLES_BUILD TRUE)
endif()

if (NOT QT_STANDALONE_EXAMPLES_BUILD)
    # It is part of a Qt build => Use the CMake config files from the binary dir
    list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
    # Also make sure the CMake config files do not recreate the already-existing targets
    set(QT_NO_CREATE_TARGETS TRUE)
endif()

find_package(Qt5 COMPONENTS DBus Network Test Concurrent Sql Widgets Xml Gui)
# special case end

# Generated from examples.pro.

add_subdirectory(corelib)
add_subdirectory(embedded)
add_subdirectory(qpa)

if(TARGET Qt::DBus)
    add_subdirectory(dbus)
endif()

if(TARGET Qt::Network)
    add_subdirectory(network)
endif()

if(TARGET Qt::Test)
    add_subdirectory(qtestlib)
endif()

if(TARGET Qt::Concurrent)
    add_subdirectory(qtconcurrent)
endif()

if(TARGET Qt::Sql)
    add_subdirectory(sql)
endif()

if(TARGET Qt::Widgets)
    add_subdirectory(widgets)
endif()

if(TARGET Qt::Xml)
    add_subdirectory(xml)
endif()

if(TARGET Qt::Gui)
    add_subdirectory(gui)

    if(QT_FEATURE_opengl)
#         add_subdirectory(opengl) # special case: removed
    endif()

    if(QT_FEATURE_vulkan)
#         add_subdirectory(vulkan) # special case: removed
    endif()
endif()

# special case begin
if (NOT QT_STANDALONE_EXAMPLES_BUILD)
    # We use AUTOMOC/UIC/RCC in the examples. Make sure to not fail on a fresh Qt build, that e.g. the moc binary does not exist yet.

    # This function gets all targets below this directory
    function(get_all_targets _result _dir)
        get_property(_subdirs DIRECTORY "${_dir}" PROPERTY SUBDIRECTORIES)
        foreach(_subdir IN LISTS _subdirs)
            get_all_targets(${_result} "${_subdir}")
        endforeach()
        get_property(_sub_targets DIRECTORY "${_dir}" PROPERTY BUILDSYSTEM_TARGETS)
        set(${_result} ${${_result}} ${_sub_targets} PARENT_SCOPE)
    endfunction()

    get_all_targets(targets "${CMAKE_CURRENT_SOURCE_DIR}")

    foreach(target ${targets})
        qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "uic" "rcc")
    endforeach()

endif()
# special case end