summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 96675412f68b45ace27b5e0ea92d791cd1015dfd (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

cmake_minimum_required(VERSION 3.16)

include(.cmake.conf)
project(QtApplicationManager # special case
    VERSION "${QT_REPO_MODULE_VERSION}"
    DESCRIPTION "QtAplicationManager Tools and Libraries" # special case
    HOMEPAGE_URL "https://qt.io/"
    LANGUAGES CXX C
)

set(QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS TRUE)
add_compile_definitions(
    QT_STRICT_ITERATORS
    QT_NO_CAST_TO_ASCII
    QT_NO_CAST_FROM_ASCII
)

# populate the platform check variables
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals)

if(NOT (ANDROID OR IOS OR LINUX OR MACOS OR (WIN32 AND NOT WINRT)))
    if (QNX)
        message(NOTICE "QNX is not officially supported - continuing anyway ...")
    else()
        message(NOTICE "Skipping the build as building is only supported on Windows, macOS, Linux, Android and iOS.")
        return()
    endif()
endif()

# find the all modules (Gui isn't really optional, but we have to deal with a no-gui CI configuration)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core Concurrent)
find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS
    Gui
    Qml
    Quick
    QuickTest
    DBus
    WaylandClient
    WaylandCompositor
    QuickTest
    Widgets
    ZlibPrivate
    DltLogging
    WaylandGlobalPrivate # remove after QTBUG-95388 is fixed
)

include(src/main-lib/Qt6AppManMainPrivateMacros.cmake)

if(NOT TARGET Qt::Gui OR NOT TARGET Qt::Quick)
    message(NOTICE "Skipping the build as QtGui and/or QtQuick are not available.")
    return()
endif()

## COVERAGE ###########################################################

if(AM_COVERAGE)
    if(NOT (LINUX AND (GCC OR CLANG)))
        message(FATAL_ERROR "Coverage builds are only supported on Linux, using GCC or Clang.")
        return()
    endif()

    set(QT_BUILD_TESTS ON)
    set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
    set(GCC_COVERAGE_LINK_FLAGS    "-fprofile-arcs -fprofile-generate -lgcov --coverage")
    set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")

    set(GCOV_EXCLUDE
        '/usr/*'
        '${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/*'
        '${CMAKE_CURRENT_LIST_DIR}/tests/*'
        '${CMAKE_CURRENT_LIST_DIR}/examples/*'
        '${CMAKE_CURRENT_LIST_DIR}/src/3rdparty/*'
        'moc_*'
        '${CMAKE_CURRENT_BINARY_DIR}/*'
    )

    if(QT_SOURCE_TREE)
        string(REGEX REPLACE "/qtbase$" "" qtSrcDir ${QT_SOURCE_TREE})
        list(APPEND GCOV_EXCLUDE '${qtSrcDir}/*')
    endif()

    add_custom_target(check_coverage
        find . -name \"*.gcov-info\" -print0 | xargs -0 rm -f &&
        lcov -c -i -d . --rc lcov_branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/base.gcov-info" >/dev/null 2>&1 &&
        ctest --test-dir tests/auto --verbose &&
        lcov -c -d . --rc lcov_branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/test.gcov-info" >/dev/null &&
        lcov --rc lcov_branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/temp.gcov-info" `find . -name \"*.gcov-info\" | xargs -n1 echo -a` >/dev/null &&
        lcov --rc lcov_branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/qtapplicationmanager.gcov-info" -r temp.gcov-info ${GCOV_EXCLUDE} >/dev/null &&
        rm -f base.gcov-info test.gcov-info temp.gcov-info &&
        genhtml -o branch-coverage -s -f --legend --branch-coverage --rc lcov_branch_coverage=1 --demangle-cpp qtapplicationmanager.gcov-info >/dev/null &&
        echo \"\\n\\nCoverage info is available at file://`pwd`/branch-coverage/index.html\\n\"

        DEPENDS
            tests/auto/install
        USES_TERMINAL
    )
endif()

## BUILD ##############################################################

qt_build_repo()

## DOCUMENTATION ######################################################

file(GLOB_RECURSE allDocFiles "doc/*.qdoc" "doc/*.png" "doc/*.qdocconf")

if(QT_BUILD_ONLINE_DOCS)
    set(DOC_CONF "doc/online/qtapplicationmanager.qdocconf")
else()
    set(DOC_CONF "doc/qtapplicationmanager.qdocconf")
endif()

add_custom_target(Documentation SOURCES
    doc/QtApplicationManagerDoc
    ${allDocFiles}
)

qt_internal_add_docs(Documentation
    ${DOC_CONF}
)

file(GLOB licenses "LICENSE.*[^~]")

add_custom_target("Other-Files" SOURCES
    .cmake.conf
    configure.cmake
    qt_cmdline.cmake
    dependencies.yaml
    sync.profile
    ${licenses}
    util/bash/appman-prompt
    util/bash/README
)

## QMAKE FEATURES #####################################################

if(NOT QT_BUILD_STANDALONE_TESTS)
    # Copy mkspecs for users preferring qmake builds
    set(mkspecs_install_dir "${INSTALL_MKSPECSDIR}")
    qt_path_join(mkspecs_install_dir ${QT_INSTALL_DIR} ${mkspecs_install_dir})

    file(GLOB QMAKE_FEATURES
        "qmake-features/*.prf"
    )

    qt_copy_or_install(
        FILES "${QMAKE_FEATURES}"
        DESTINATION "${mkspecs_install_dir}/features"
    )
endif()