-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
188 lines (156 loc) · 6.35 KB
/
CMakeLists.txt
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
cmake_minimum_required(VERSION 3.16)
set(MIN_QT_VERSION 6.8.0)
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
HttpServer
)
if (${Qt6_VERSION} VERSION_LESS "${MIN_QT_VERSION}")
message(FATAL_ERROR "Qt ${MIN_QT_VERSION} or newer is required for building version ${PROJECT_VERSION} of the QtApplicationManager")
endif()
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(QT_BUILD_TESTS_BY_DEFAULT ON)
add_compile_options(--coverage -fprofile-update=atomic)
add_link_options(--coverage)
add_compile_definitions(QT_AM_COVERAGE)
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/*'
'${CMAKE_CURRENT_LIST_DIR}/src/plugin-interfaces/*'
'moc_*'
'${CMAKE_CURRENT_BINARY_DIR}/*'
)
if(QT_SOURCE_TREE AND NOT DEFINED ENV{HOST_OS_COIN})
string(REGEX REPLACE "/qtbase$" "" qtSrcDir ${QT_SOURCE_TREE})
list(APPEND GCOV_EXCLUDE '${qtSrcDir}/*')
endif()
set(COVERAGE_DEPENDS all)
if(QT_WILL_INSTALL)
list(APPEND COVERAGE_DEPENDS tests/auto/install)
endif()
add_custom_target(check_coverage
COMMAND sh -c 'which lcov >/dev/null || { echo "The lcov tool is not available." && exit 2 \; }'
COMMAND sh -c 'which genhtml >/dev/null || { echo "The genhtml tool is not available." && exit 2 \; }'
COMMAND sh -c 'lcov --version | grep -q "^lcov: LCOV version 2\." || { echo "The lcov tool must be version 2." && exit 2 \; }'
COMMAND find . \\\( -name \"*.gcov-info\" -o -name \"*.gcda\" \\\) -print0 | xargs -0 rm -f
COMMAND lcov -keep-going -c -i -d . --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/base.gcov-info"
COMMAND ctest --test-dir tests/auto --verbose --repeat until-pass:3
COMMAND lcov -keep-going -c -d . --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/test.gcov-info"
COMMAND lcov -keep-going --rc branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/temp.gcov-info" `find . -name \"*.gcov-info\" | xargs -n1 echo -a`
COMMAND lcov -keep-going --rc branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.gcov-info" -r temp.gcov-info ${GCOV_EXCLUDE}
COMMAND rm -f base.gcov-info test.gcov-info temp.gcov-info
COMMAND genhtml -o coverage-report -s -f -t "${PROJECT_NAME}" --legend --branch-coverage --rc branch_coverage=1 --rc geninfo_unexecuted_blocks=1 --demangle-cpp "c++filt" ${PROJECT_NAME}.gcov-info
COMMAND echo \"\\n\\nCoverage info is available at file://`pwd`/coverage-report/index.html\\n\"
DEPENDS ${COVERAGE_DEPENDS}
USES_TERMINAL
)
endif()
## SANITIZE ###########################################################
if (AM_SANITIZE)
if (MSVC)
set(ECM_ENABLE_SANITIZERS address)
else()
set(ECM_ENABLE_SANITIZERS address undefined)
endif()
include(3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers)
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}
)
add_custom_target("Other-Files" SOURCES
.cmake.conf
qt_cmdline.cmake
src/common-lib/qt_cmdline.cmake
src/package-lib/qt_cmdline.cmake
src/window-lib/qt_cmdline.cmake
src/common-lib/configure.cmake
src/plugin-interfaces/configure.cmake
cmake/FindWrapLibArchive.cmake
cmake/FindWrapLibYaml.cmake
cmake/QtAppManHelpers.cmake
cmake/QtAppManBuildConfig.cmake
cmake/QtAppManVersionDefines.cmake
dependencies.yaml
sync.profile
LICENSES/BSD-3-Clause.txt
LICENSES/GFDL-1.3-no-invariants-only.txt
LICENSES/GPL-3.0-only.txt
LICENSES/LicenseRef-Qt-Commercial.txt
LICENSES/Qt-GPL-exception-1.0.txt
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()