summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/3rdparty/extra-cmake-modules/COPYING-CMAKE-SCRIPTS22
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/ECMFindModuleHelpersStub.cmake1
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake172
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindGLIB2.cmake101
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindWayland.cmake143
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindWaylandScanner.cmake167
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindX11_XCB.cmake118
-rw-r--r--cmake/3rdparty/extra-cmake-modules/find-modules/FindXCB.cmake201
-rw-r--r--cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake173
-rw-r--r--cmake/3rdparty/extra-cmake-modules/modules/ECMFindModuleHelpers.cmake297
-rw-r--r--cmake/3rdparty/extra-cmake-modules/qt_attribution.json15
-rw-r--r--cmake/3rdparty/kwin/COPYING-CMAKE-SCRIPTS22
-rw-r--r--cmake/3rdparty/kwin/FindLibdrm.cmake126
-rw-r--r--cmake/3rdparty/kwin/FindLibinput.cmake125
-rw-r--r--cmake/3rdparty/kwin/FindXKB.cmake101
-rw-r--r--cmake/3rdparty/kwin/Findgbm.cmake125
-rw-r--r--cmake/3rdparty/kwin/qt_attribution.json17
-rw-r--r--cmake/3rdpartyConfig.cmake.in15
-rw-r--r--cmake/FindATSPI2.cmake7
-rw-r--r--cmake/FindAtomic.cmake44
-rw-r--r--cmake/FindCups.cmake98
-rw-r--r--cmake/FindDB2.cmake59
-rw-r--r--cmake/FindDirectFB.cmake7
-rw-r--r--cmake/FindGLESv2.cmake72
-rw-r--r--cmake/FindGSSAPI.cmake39
-rw-r--r--cmake/FindGTK3.cmake7
-rw-r--r--cmake/FindLibproxy.cmake7
-rw-r--r--cmake/FindLibsystemd.cmake7
-rw-r--r--cmake/FindLibudev.cmake7
-rw-r--r--cmake/FindMtdev.cmake7
-rw-r--r--cmake/FindMySQL.cmake50
-rw-r--r--cmake/FindOracle.cmake48
-rw-r--r--cmake/FindPPS.cmake19
-rw-r--r--cmake/FindSlog2.cmake19
-rw-r--r--cmake/FindTslib.cmake7
-rw-r--r--cmake/FindWrapDBus1.cmake35
-rw-r--r--cmake/FindWrapDoubleConversion.cmake61
-rw-r--r--cmake/FindWrapFreetype.cmake33
-rw-r--r--cmake/FindWrapHarfbuzz.cmake45
-rw-r--r--cmake/FindWrapPCRE2.cmake23
-rw-r--r--cmake/FindWrapRt.cmake34
-rw-r--r--cmake/FindXKB_COMMON_X11.cmake7
-rw-r--r--cmake/FindXRender.cmake11
-rw-r--r--cmake/FindZSTD.cmake50
-rw-r--r--cmake/Finddouble-conversion.cmake32
-rw-r--r--cmake/ModuleDescription.json.in11
-rw-r--r--cmake/QtAutoDetect.cmake179
-rw-r--r--cmake/QtBaseCMakeTesting.cmake9
-rw-r--r--cmake/QtBaseConfigureTests.cmake198
-rw-r--r--cmake/QtBaseGlobalTargets.cmake287
-rw-r--r--cmake/QtBuild.cmake4056
-rw-r--r--cmake/QtBuildInformation.cmake35
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake217
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake237
-rw-r--r--cmake/QtBuildInternalsExtra.cmake.in37
-rw-r--r--cmake/QtCompilerFlags.cmake6
-rw-r--r--cmake/QtCompilerOptimization.cmake123
-rw-r--r--cmake/QtConfig.cmake.in59
-rw-r--r--cmake/QtFeature.cmake760
-rw-r--r--cmake/QtInternalTargets.cmake114
-rw-r--r--cmake/QtModuleConfig.cmake.in68
-rw-r--r--cmake/QtModuleDependencies.cmake.in66
-rw-r--r--cmake/QtModuleToolsConfig.cmake.in17
-rw-r--r--cmake/QtModuleToolsDependencies.cmake.in16
-rw-r--r--cmake/QtModuleToolsVersionlessTargets.cmake.in23
-rw-r--r--cmake/QtPlatformAndroid.cmake378
-rw-r--r--cmake/QtPlatformSupport.cmake81
-rw-r--r--cmake/QtPluginConfig.cmake.in17
-rw-r--r--cmake/QtPluginDependencies.cmake.in42
-rw-r--r--cmake/QtPlugins.cmake.in131
-rw-r--r--cmake/QtPostProcess.cmake405
-rw-r--r--cmake/QtProperties.cmake107
-rw-r--r--cmake/QtResource.cmake.in313
-rw-r--r--cmake/QtSetup.cmake176
-rw-r--r--cmake/QtStandaloneTestsConfig.cmake.in2
-rw-r--r--cmake/QtToolsConfig.cmake.in35
-rw-r--r--cmake/README.md308
-rw-r--r--cmake/qt.toolchain.cmake.in20
-rw-r--r--cmake/tests/CMakeLists.txt48
-rw-r--r--cmake/tests/empty.cpp0
-rw-r--r--cmake/tests/features/CMakeLists.txt42
-rw-r--r--cmake/tests/features/configure.cmake35
-rw-r--r--cmake/tests/features/src/CMakeLists.txt7
-rw-r--r--cmake/tests/main.cpp1
-rw-r--r--cmake/tests/qt_make_output_file/CMakeLists.txt22
-rw-r--r--cmake/tests/test.cmake54
86 files changed, 11518 insertions, 0 deletions
diff --git a/cmake/3rdparty/extra-cmake-modules/COPYING-CMAKE-SCRIPTS b/cmake/3rdparty/extra-cmake-modules/COPYING-CMAKE-SCRIPTS
new file mode 100644
index 0000000000..4b417765f3
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/COPYING-CMAKE-SCRIPTS
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/ECMFindModuleHelpersStub.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/ECMFindModuleHelpersStub.cmake
new file mode 100644
index 0000000000..bb8c9a62fc
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/ECMFindModuleHelpersStub.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/../modules/ECMFindModuleHelpers.cmake)
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
new file mode 100644
index 0000000000..48e5172877
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
@@ -0,0 +1,172 @@
+#.rst:
+# FindEGL
+# -------
+#
+# Try to find EGL.
+#
+# This will define the following variables:
+#
+# ``EGL_FOUND``
+# True if (the requested version of) EGL is available
+# ``EGL_VERSION``
+# The version of EGL; note that this is the API version defined in the
+# headers, rather than the version of the implementation (eg: Mesa)
+# ``EGL_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the ``EGL::EGL``
+# target
+# ``EGL_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the target is not
+# used for linking
+# ``EGL_DEFINITIONS``
+# This should be passed to target_compile_options() if the target is not
+# used for linking
+#
+# If ``EGL_FOUND`` is TRUE, it will also define the following imported target:
+#
+# ``EGL::EGL``
+# The EGL library
+#
+# In general we recommend using the imported target, as it is easier to use.
+# Bear in mind, however, that if the target is in the link interface of an
+# exported library, it must be made available by the package config file.
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
+include(CheckCXXSourceCompiles)
+include(CMakePushCheckState)
+
+ecm_find_package_version_check(EGL)
+
+# Use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig)
+pkg_check_modules(PKG_EGL QUIET egl)
+
+set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER})
+
+find_path(EGL_INCLUDE_DIR
+ NAMES
+ EGL/egl.h
+ HINTS
+ ${PKG_EGL_INCLUDE_DIRS}
+)
+find_library(EGL_LIBRARY
+ NAMES
+ EGL
+ HINTS
+ ${PKG_EGL_LIBRARY_DIRS}
+)
+
+# NB: We do *not* use the version information from pkg-config, as that
+# is the implementation version (eg: the Mesa version)
+if(EGL_INCLUDE_DIR)
+ # egl.h has defines of the form EGL_VERSION_x_y for each supported
+ # version; so the header for EGL 1.1 will define EGL_VERSION_1_0 and
+ # EGL_VERSION_1_1. Finding the highest supported version involves
+ # finding all these defines and selecting the highest numbered.
+ file(READ "${EGL_INCLUDE_DIR}/EGL/egl.h" _EGL_header_contents)
+ string(REGEX MATCHALL
+ "[ \t]EGL_VERSION_[0-9_]+"
+ _EGL_version_lines
+ "${_EGL_header_contents}"
+ )
+ unset(_EGL_header_contents)
+ foreach(_EGL_version_line ${_EGL_version_lines})
+ string(REGEX REPLACE
+ "[ \t]EGL_VERSION_([0-9_]+)"
+ "\\1"
+ _version_candidate
+ "${_EGL_version_line}"
+ )
+ string(REPLACE "_" "." _version_candidate "${_version_candidate}")
+ if(NOT DEFINED EGL_VERSION OR EGL_VERSION VERSION_LESS _version_candidate)
+ set(EGL_VERSION "${_version_candidate}")
+ endif()
+ endforeach()
+ unset(_EGL_version_lines)
+endif()
+
+cmake_push_check_state(RESET)
+list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
+list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
+
+check_cxx_source_compiles("
+#include <EGL/egl.h>
+
+int main(int argc, char *argv[]) {
+ EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
+ eglDestroyContext(dpy, ctx);
+}" HAVE_EGL)
+
+cmake_pop_check_state()
+
+set(required_vars EGL_INCLUDE_DIR HAVE_EGL)
+if(NOT EMSCRIPTEN)
+ list(APPEND required_vars EGL_LIBRARY)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(EGL
+ FOUND_VAR
+ EGL_FOUND
+ REQUIRED_VARS
+ ${required_vars}
+ VERSION_VAR
+ EGL_VERSION
+)
+
+if(EGL_FOUND AND NOT TARGET EGL::EGL)
+ if (EMSCRIPTEN)
+ add_library(EGL::EGL INTERFACE IMPORTED)
+ # Nothing further to be done, system include paths have headers and linkage is implicit.
+ else()
+ add_library(EGL::EGL UNKNOWN IMPORTED)
+ set_target_properties(EGL::EGL PROPERTIES
+ IMPORTED_LOCATION "${EGL_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${EGL_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}"
+ )
+ endif()
+endif()
+
+mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR HAVE_EGL)
+
+# compatibility variables
+set(EGL_LIBRARIES ${EGL_LIBRARY})
+set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
+set(EGL_VERSION_STRING ${EGL_VERSION})
+
+include(FeatureSummary)
+set_package_properties(EGL PROPERTIES
+ URL "https://www.khronos.org/egl/"
+ DESCRIPTION "A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG."
+)
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindGLIB2.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindGLIB2.cmake
new file mode 100644
index 0000000000..993535123a
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindGLIB2.cmake
@@ -0,0 +1,101 @@
+#.rst:
+# FindGLIB2
+# ---------
+#
+# Try to locate the GLib2 library.
+# If found, this will define the following variables:
+#
+# ``GLIB2_FOUND``
+# True if the GLib2 library is available
+# ``GLIB2_INCLUDE_DIRS``
+# The GLib2 include directories
+# ``GLIB2_LIBRARIES``
+# The GLib2 libraries for linking
+# ``GLIB2_INCLUDE_DIR``
+# Deprecated, use ``GLIB2_INCLUDE_DIRS``
+# ``GLIB2_LIBRARY``
+# Deprecated, use ``GLIB2_LIBRARIES``
+#
+# If ``GLIB2_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``GLIB2::GLIB2``
+# The GLIB2 library
+#
+# Since 5.41.0.
+
+#=============================================================================
+# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+find_package(PkgConfig)
+pkg_check_modules(PC_GLIB2 QUIET glib-2.0)
+
+find_path(GLIB2_INCLUDE_DIRS
+ NAMES glib.h
+ HINTS ${PC_GLIB2_INCLUDEDIR}
+ PATH_SUFFIXES glib-2.0)
+
+find_library(GLIB2_LIBRARIES
+ NAMES glib-2.0
+ HINTS ${PC_GLIB2_LIBDIR}
+)
+
+# search the glibconfig.h include dir under the same root where the library is found
+get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
+
+find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
+ PATH_SUFFIXES glib-2.0/include
+ HINTS ${PC_GLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
+
+# not sure if this include dir is optional or required
+# for now it is optional
+if(GLIB2_INTERNAL_INCLUDE_DIR)
+ list(APPEND GLIB2_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}")
+endif()
+
+# Deprecated synonyms
+set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}")
+set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_INCLUDE_DIRS)
+
+if(GLIB2_FOUND AND NOT TARGET GLIB2::GLIB2)
+ add_library(GLIB2::GLIB2 UNKNOWN IMPORTED)
+ set_target_properties(GLIB2::GLIB2 PROPERTIES
+ IMPORTED_LOCATION "${GLIB2_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR
+ GLIB2_LIBRARIES GLIB2_LIBRARY)
+
+include(FeatureSummary)
+set_package_properties(GLIB2 PROPERTIES
+ URL "https://wiki.gnome.org/Projects/GLib"
+ DESCRIPTION "Event loop and utility library")
+
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindWayland.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindWayland.cmake
new file mode 100644
index 0000000000..233cc88d02
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindWayland.cmake
@@ -0,0 +1,143 @@
+#.rst:
+# FindWayland
+# -----------
+#
+# Try to find Wayland.
+#
+# This is a component-based find module, which makes use of the COMPONENTS
+# and OPTIONAL_COMPONENTS arguments to find_module. The following components
+# are available::
+#
+# Client Server Cursor Egl
+#
+# If no components are specified, this module will act as though all components
+# were passed to OPTIONAL_COMPONENTS.
+#
+# This module will define the following variables, independently of the
+# components searched for or found:
+#
+# ``Wayland_FOUND``
+# TRUE if (the requested version of) Wayland is available
+# ``Wayland_VERSION``
+# Found Wayland version
+# ``Wayland_TARGETS``
+# A list of all targets imported by this module (note that there may be more
+# than the components that were requested)
+# ``Wayland_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the imported
+# targets
+# ``Wayland_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the targets are
+# not used for linking
+# ``Wayland_DEFINITIONS``
+# This should be passed to target_compile_options() if the targets are not
+# used for linking
+#
+# For each searched-for components, ``Wayland_<component>_FOUND`` will be set to
+# TRUE if the corresponding Wayland library was found, and FALSE otherwise. If
+# ``Wayland_<component>_FOUND`` is TRUE, the imported target
+# ``Wayland::<component>`` will be defined. This module will also attempt to
+# determine ``Wayland_*_VERSION`` variables for each imported target, although
+# ``Wayland_VERSION`` should normally be sufficient.
+#
+# In general we recommend using the imported targets, as they are easier to use
+# and provide more control. Bear in mind, however, that if any target is in the
+# link interface of an exported library, it must be made available by the
+# package config file.
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
+
+ecm_find_package_version_check(Wayland)
+
+set(Wayland_known_components
+ Client
+ Server
+ Cursor
+ Egl
+)
+foreach(_comp ${Wayland_known_components})
+ string(TOLOWER "${_comp}" _lc_comp)
+ set(Wayland_${_comp}_component_deps)
+ set(Wayland_${_comp}_pkg_config "wayland-${_lc_comp}")
+ set(Wayland_${_comp}_lib "wayland-${_lc_comp}")
+ set(Wayland_${_comp}_header "wayland-${_lc_comp}.h")
+endforeach()
+set(Wayland_Egl_component_deps Client)
+
+ecm_find_package_parse_components(Wayland
+ RESULT_VAR Wayland_components
+ KNOWN_COMPONENTS ${Wayland_known_components}
+)
+ecm_find_package_handle_library_components(Wayland
+ COMPONENTS ${Wayland_components}
+)
+
+# If pkg-config didn't provide us with version information,
+# try to extract it from wayland-version.h
+# (Note that the version from wayland-egl.pc will probably be
+# the Mesa version, rather than the Wayland version, but that
+# version will be ignored as we always find wayland-client.pc
+# first).
+if(NOT Wayland_VERSION)
+ find_file(Wayland_VERSION_HEADER
+ NAMES wayland-version.h
+ HINTS ${Wayland_INCLUDE_DIRS}
+ )
+ mark_as_advanced(Wayland_VERSION_HEADER)
+ if(Wayland_VERSION_HEADER)
+ file(READ ${Wayland_VERSION_HEADER} _wayland_version_header_contents)
+ string(REGEX REPLACE
+ "^.*[ \t]+WAYLAND_VERSION[ \t]+\"([0-9.]*)\".*$"
+ "\\1"
+ Wayland_VERSION
+ "${_wayland_version_header_contents}"
+ )
+ unset(_wayland_version_header_contents)
+ endif()
+endif()
+
+find_package_handle_standard_args(Wayland
+ FOUND_VAR
+ Wayland_FOUND
+ REQUIRED_VARS
+ Wayland_LIBRARIES
+ VERSION_VAR
+ Wayland_VERSION
+ HANDLE_COMPONENTS
+)
+
+include(FeatureSummary)
+set_package_properties(Wayland PROPERTIES
+ URL "http://wayland.freedesktop.org"
+ DESCRIPTION "C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients"
+)
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindWaylandScanner.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindWaylandScanner.cmake
new file mode 100644
index 0000000000..ed9c4c4c9a
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindWaylandScanner.cmake
@@ -0,0 +1,167 @@
+#.rst:
+# FindWaylandScanner
+# ------------------
+#
+# Try to find wayland-scanner.
+#
+# If the wayland-scanner executable is not in your PATH, you can provide
+# an alternative name or full path location with the ``WaylandScanner_EXECUTABLE``
+# variable.
+#
+# This will define the following variables:
+#
+# ``WaylandScanner_FOUND``
+# True if wayland-scanner is available.
+#
+# ``WaylandScanner_EXECUTABLE``
+# The wayland-scanner executable.
+#
+# If ``WaylandScanner_FOUND`` is TRUE, it will also define the following imported
+# target:
+#
+# ``Wayland::Scanner``
+# The wayland-scanner executable.
+#
+# This module provides the following functions to generate C protocol
+# implementations:
+#
+# - ``ecm_add_wayland_client_protocol``
+# - ``ecm_add_wayland_server_protocol``
+#
+# ::
+#
+# ecm_add_wayland_client_protocol(<source_files_var>
+# PROTOCOL <xmlfile>
+# BASENAME <basename>)
+#
+# Generate Wayland client protocol files from ``<xmlfile>`` XML
+# definition for the ``<basename>`` interface and append those files
+# to ``<source_files_var>``.
+#
+# ::
+#
+# ecm_add_wayland_server_protocol(<source_files_var>
+# PROTOCOL <xmlfile>
+# BASENAME <basename>)
+#
+# Generate Wayland server protocol files from ``<xmlfile>`` XML
+# definition for the ``<basename>`` interface and append those files
+# to ``<source_files_var>``.
+#
+# Since 1.4.0.
+
+#=============================================================================
+# Copyright 2012-2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
+
+ecm_find_package_version_check(WaylandScanner)
+
+# Find wayland-scanner
+find_program(WaylandScanner_EXECUTABLE NAMES wayland-scanner)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WaylandScanner
+ FOUND_VAR
+ WaylandScanner_FOUND
+ REQUIRED_VARS
+ WaylandScanner_EXECUTABLE
+)
+
+mark_as_advanced(WaylandScanner_EXECUTABLE)
+
+if(NOT TARGET Wayland::Scanner AND WaylandScanner_FOUND)
+ add_executable(Wayland::Scanner IMPORTED)
+ set_target_properties(Wayland::Scanner PROPERTIES
+ IMPORTED_LOCATION "${WaylandScanner_EXECUTABLE}"
+ )
+endif()
+
+include(FeatureSummary)
+set_package_properties(WaylandScanner PROPERTIES
+ URL "https://wayland.freedesktop.org/"
+ DESCRIPTION "Executable that converts XML protocol files to C code"
+)
+
+
+include(CMakeParseArguments)
+
+function(ecm_add_wayland_client_protocol out_var)
+ # Parse arguments
+ set(oneValueArgs PROTOCOL BASENAME)
+ cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN})
+
+ if(ARGS_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_client_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE)
+ set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-client-protocol.h")
+ set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-protocol.c")
+
+ set_source_files_properties(${_client_header} GENERATED)
+ set_source_files_properties(${_code} GENERATED)
+ set_property(SOURCE ${_client_header} PROPERTY SKIP_AUTOMOC ON)
+
+ add_custom_command(OUTPUT "${_client_header}"
+ COMMAND ${WaylandScanner_EXECUTABLE} client-header ${_infile} ${_client_header}
+ DEPENDS ${_infile} VERBATIM)
+
+ add_custom_command(OUTPUT "${_code}"
+ COMMAND ${WaylandScanner_EXECUTABLE} code ${_infile} ${_code}
+ DEPENDS ${_infile} ${_client_header} VERBATIM)
+
+ list(APPEND ${out_var} "${_client_header}" "${_code}")
+ set(${out_var} ${${out_var}} PARENT_SCOPE)
+endfunction()
+
+
+function(ecm_add_wayland_server_protocol out_var)
+ # Parse arguments
+ set(oneValueArgs PROTOCOL BASENAME)
+ cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN})
+
+ if(ARGS_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ ecm_add_wayland_client_protocol(${out_var}
+ PROTOCOL ${ARGS_PROTOCOL}
+ BASENAME ${ARGS_BASENAME})
+
+ get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE)
+ set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-server-protocol.h")
+ set_property(SOURCE ${_server_header} PROPERTY SKIP_AUTOMOC ON)
+ set_source_files_properties(${_server_header} GENERATED)
+
+ add_custom_command(OUTPUT "${_server_header}"
+ COMMAND ${WaylandScanner_EXECUTABLE} server-header ${_infile} ${_server_header}
+ DEPENDS ${_infile} VERBATIM)
+
+ list(APPEND ${out_var} "${_server_header}")
+ set(${out_var} ${${out_var}} PARENT_SCOPE)
+endfunction()
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindX11_XCB.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindX11_XCB.cmake
new file mode 100644
index 0000000000..dd55fd7b30
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindX11_XCB.cmake
@@ -0,0 +1,118 @@
+#.rst:
+# FindX11_XCB
+# -----------
+#
+# Try to find the X11 XCB compatibility library.
+#
+# This will define the following variables:
+#
+# ``X11_XCB_FOUND``
+# True if (the requested version of) libX11-xcb is available
+# ``X11_XCB_VERSION``
+# The version of libX11-xcb (this is not guaranteed to be set even when
+# X11_XCB_FOUND is true)
+# ``X11_XCB_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the ``EGL::EGL``
+# target
+# ``X11_XCB_INCLUDE_DIR``
+# This should be passed to target_include_directories() if the target is not
+# used for linking
+# ``X11_XCB_DEFINITIONS``
+# This should be passed to target_compile_options() if the target is not
+# used for linking
+#
+# If ``X11_XCB_FOUND`` is TRUE, it will also define the following imported
+# target:
+#
+# ``X11::XCB``
+# The X11 XCB compatibility library
+#
+# In general we recommend using the imported target, as it is easier to use.
+# Bear in mind, however, that if the target is in the link interface of an
+# exported library, it must be made available by the package config file.
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2011 Fredrik Höglund <fredrik@kde.org>
+# Copyright 2008 Helio Chissini de Castro <helio@kde.org>
+# Copyright 2007 Matthias Kretz <kretz@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
+
+ecm_find_package_version_check(X11_XCB)
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig)
+pkg_check_modules(PKG_X11_XCB QUIET x11-xcb)
+
+set(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS_OTHER})
+set(X11_XCB_VERSION ${PKG_X11_XCB_VERSION})
+
+find_path(X11_XCB_INCLUDE_DIR
+ NAMES X11/Xlib-xcb.h
+ HINTS ${PKG_X11_XCB_INCLUDE_DIRS}
+)
+find_library(X11_XCB_LIBRARY
+ NAMES X11-xcb
+ HINTS ${PKG_X11_XCB_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(X11_XCB
+ FOUND_VAR
+ X11_XCB_FOUND
+ REQUIRED_VARS
+ X11_XCB_LIBRARY
+ X11_XCB_INCLUDE_DIR
+ VERSION_VAR
+ X11_XCB_VERSION
+)
+
+if(X11_XCB_FOUND AND NOT TARGET X11::XCB)
+ add_library(X11::XCB UNKNOWN IMPORTED)
+ set_target_properties(X11::XCB PROPERTIES
+ IMPORTED_LOCATION "${X11_XCB_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${X11_XCB_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_XCB_INCLUDE_DIR}"
+ )
+endif()
+
+mark_as_advanced(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARY)
+
+# compatibility variables
+set(X11_XCB_LIBRARIES ${X11_XCB_LIBRARY})
+set(X11_XCB_INCLUDE_DIRS ${X11_XCB_INCLUDE_DIR})
+set(X11_XCB_VERSION_STRING ${X11_XCB_VERSION})
+
+include(FeatureSummary)
+set_package_properties(X11_XCB PROPERTIES
+ URL "http://xorg.freedesktop.org/"
+ DESCRIPTION "A compatibility library for code that translates Xlib API calls into XCB calls"
+)
diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindXCB.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindXCB.cmake
new file mode 100644
index 0000000000..d530d2d7f4
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindXCB.cmake
@@ -0,0 +1,201 @@
+#.rst:
+# FindXCB
+# -------
+#
+# Try to find XCB.
+#
+# This is a component-based find module, which makes use of the COMPONENTS and
+# OPTIONAL_COMPONENTS arguments to find_module. The following components are
+# available::
+#
+# XCB
+# ATOM AUX COMPOSITE CURSOR DAMAGE
+# DPMS DRI2 DRI3 EVENT EWMH
+# GLX ICCCM IMAGE KEYSYMS PRESENT
+# RANDR RECORD RENDER RENDERUTIL RES
+# SCREENSAVER SHAPE SHM SYNC UTIL
+# XEVIE XF86DRI XFIXES XINERAMA XINPUT
+# XKB XPRINT XTEST XV XVMC
+#
+# If no components are specified, this module will act as though all components
+# except XINPUT (which is considered unstable) were passed to
+# OPTIONAL_COMPONENTS.
+#
+# This module will define the following variables, independently of the
+# components searched for or found:
+#
+# ``XCB_FOUND``
+# True if (the requestion version of) xcb is available
+# ``XCB_VERSION``
+# Found xcb version
+# ``XCB_TARGETS``
+# A list of all targets imported by this module (note that there may be more
+# than the components that were requested)
+# ``XCB_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the imported
+# targets
+# ``XCB_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the targets are
+# not used for linking
+# ``XCB_DEFINITIONS``
+# This should be passed to target_compile_options() if the targets are not
+# used for linking
+#
+# For each searched-for components, ``XCB_<component>_FOUND`` will be set to
+# true if the corresponding xcb library was found, and false otherwise. If
+# ``XCB_<component>_FOUND`` is true, the imported target ``XCB::<component>``
+# will be defined. This module will also attempt to determine
+# ``XCB_*_VERSION`` variables for each imported target, although
+# ``XCB_VERSION`` should normally be sufficient.
+#
+# In general we recommend using the imported targets, as they are easier to use
+# and provide more control. Bear in mind, however, that if any target is in the
+# link interface of an exported library, it must be made available by the
+# package config file.
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2011 Fredrik Höglund <fredrik@kde.org>
+# Copyright 2013 Martin Gräßlin <mgraesslin@kde.org>
+# Copyright 2014-2015 Alex Merry <alex.merry@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
+
+ecm_find_package_version_check(XCB)
+
+# Note that this list needs to be ordered such that any component
+# appears after its dependencies
+set(XCB_known_components
+ XCB
+ RENDER
+ SHAPE
+ XFIXES
+ SHM
+ ATOM
+ AUX
+ COMPOSITE
+ CURSOR
+ DAMAGE
+ DPMS
+ DRI2
+ DRI3
+ EVENT
+ EWMH
+ GLX
+ ICCCM
+ IMAGE
+ KEYSYMS
+ PRESENT
+ RANDR
+ RECORD
+ RENDERUTIL
+ RES
+ SCREENSAVER
+ SYNC
+ UTIL
+ XEVIE
+ XF86DRI
+ XINERAMA
+ XINPUT
+ XKB
+ XPRINT
+ XTEST
+ XV
+ XVMC
+)
+
+# XINPUT is unstable; do not include it by default
+set(XCB_default_components ${XCB_known_components})
+list(REMOVE_ITEM XCB_default_components "XINPUT")
+
+# default component info: xcb components have fairly predictable
+# header files, library names and pkg-config names
+foreach(_comp ${XCB_known_components})
+ string(TOLOWER "${_comp}" _lc_comp)
+ set(XCB_${_comp}_component_deps XCB)
+ set(XCB_${_comp}_pkg_config "xcb-${_lc_comp}")
+ set(XCB_${_comp}_lib "xcb-${_lc_comp}")
+ set(XCB_${_comp}_header "xcb/${_lc_comp}.h")
+endforeach()
+# exceptions
+set(XCB_XCB_component_deps)
+set(XCB_COMPOSITE_component_deps XCB XFIXES)
+set(XCB_DAMAGE_component_deps XCB XFIXES)
+set(XCB_IMAGE_component_deps XCB SHM)
+set(XCB_RENDERUTIL_component_deps XCB RENDER)
+set(XCB_XFIXES_component_deps XCB RENDER SHAPE)
+set(XCB_XVMC_component_deps XCB XV)
+set(XCB_XV_component_deps XCB SHM)
+set(XCB_XCB_pkg_config "xcb")
+set(XCB_XCB_lib "xcb")
+set(XCB_ATOM_header "xcb/xcb_atom.h")
+set(XCB_ATOM_lib "xcb-util")
+set(XCB_AUX_header "xcb/xcb_aux.h")
+set(XCB_AUX_lib "xcb-util")
+set(XCB_CURSOR_header "xcb/xcb_cursor.h")
+set(XCB_EVENT_header "xcb/xcb_event.h")
+set(XCB_EVENT_lib "xcb-util")
+set(XCB_EWMH_header "xcb/xcb_ewmh.h")
+set(XCB_ICCCM_header "xcb/xcb_icccm.h")
+set(XCB_IMAGE_header "xcb/xcb_image.h")
+set(XCB_KEYSYMS_header "xcb/xcb_keysyms.h")
+set(XCB_PIXEL_header "xcb/xcb_pixel.h")
+set(XCB_RENDERUTIL_header "xcb/xcb_renderutil.h")
+set(XCB_RENDERUTIL_lib "xcb-render-util")
+set(XCB_UTIL_header "xcb/xcb_util.h")
+
+ecm_find_package_parse_components(XCB
+ RESULT_VAR XCB_components
+ KNOWN_COMPONENTS ${XCB_known_components}
+ DEFAULT_COMPONENTS ${XCB_default_components}
+)
+
+list(FIND XCB_components "XINPUT" _XCB_XINPUT_index)
+if (NOT _XCB_XINPUT_index EQUAL -1)
+ message(AUTHOR_WARNING "XINPUT from XCB was requested: this is EXPERIMENTAL and is likely to unavailable on many systems!")
+endif()
+
+ecm_find_package_handle_library_components(XCB
+ COMPONENTS ${XCB_components}
+)
+
+find_package_handle_standard_args(XCB
+ FOUND_VAR
+ XCB_FOUND
+ REQUIRED_VARS
+ XCB_LIBRARIES
+ VERSION_VAR
+ XCB_VERSION
+ HANDLE_COMPONENTS
+)
+
+include(FeatureSummary)
+set_package_properties(XCB PROPERTIES
+ URL "http://xcb.freedesktop.org"
+ DESCRIPTION "X protocol C-language Binding"
+)
diff --git a/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake b/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake
new file mode 100644
index 0000000000..06cc0b66d8
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake
@@ -0,0 +1,173 @@
+#.rst:
+# ECMEnableSanitizers
+# -------------------
+#
+# Enable compiler sanitizer flags.
+#
+# The following sanitizers are supported:
+#
+# - Address Sanitizer
+# - Memory Sanitizer
+# - Thread Sanitizer
+# - Leak Sanitizer
+# - Undefined Behaviour Sanitizer
+#
+# All of them are implemented in Clang, depending on your version, and
+# there is an work in progress in GCC, where some of them are currently
+# implemented.
+#
+# This module will check your current compiler version to see if it
+# supports the sanitizers that you want to enable
+#
+# Usage
+# =====
+#
+# Simply add::
+#
+# include(ECMEnableSanitizers)
+#
+# to your ``CMakeLists.txt``. Note that this module is included in
+# KDECompilerSettings, so projects using that module do not need to also
+# include this one.
+#
+# The sanitizers are not enabled by default. Instead, you must set
+# ``ECM_ENABLE_SANITIZERS`` (either in your ``CMakeLists.txt`` or on the
+# command line) to a semicolon-separated list of sanitizers you wish to enable.
+# The options are:
+#
+# - address
+# - memory
+# - thread
+# - leak
+# - undefined
+#
+# The sanitizers "address", "memory" and "thread" are mutually exclusive. You
+# cannot enable two of them in the same build.
+#
+# "leak" requires the "address" sanitizer.
+#
+# .. note::
+#
+# To reduce the overhead induced by the instrumentation of the sanitizers, it
+# is advised to enable compiler optimizations (``-O1`` or higher).
+#
+# Example
+# =======
+#
+# This is an example of usage::
+#
+# mkdir build
+# cd build
+# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' ..
+#
+# .. note::
+#
+# Most of the sanitizers will require Clang. To enable it, use::
+#
+# -DCMAKE_CXX_COMPILER=clang++
+#
+# Since 1.3.0.
+
+#=============================================================================
+# Copyright 2014 Mathieu Tarral <mathieu.tarral@gmail.com>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# MACRO check_compiler_version
+#-----------------------------
+macro (check_compiler_version gcc_required_version clang_required_version)
+ if (
+ (
+ CMAKE_CXX_COMPILER_ID MATCHES "GNU"
+ AND
+ CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_required_version}
+ )
+ OR
+ (
+ CMAKE_CXX_COMPILER_ID MATCHES "Clang"
+ AND
+ CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${clang_required_version}
+ )
+ )
+ # error !
+ message(FATAL_ERROR "You ask to enable the sanitizer ${CUR_SANITIZER},
+ but your compiler ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION}
+ does not support it !
+ You should use at least GCC ${gcc_required_version} or Clang ${clang_required_version}
+ (99.99 means not implemented yet)")
+ endif ()
+endmacro ()
+
+# MACRO check_compiler_support
+#------------------------------
+macro (enable_sanitizer_flags sanitize_option)
+ if (${sanitize_option} MATCHES "address")
+ check_compiler_version("4.8" "3.1")
+ set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
+ set(XSAN_LINKER_FLAGS "asan")
+ elseif (${sanitize_option} MATCHES "thread")
+ check_compiler_version("4.8" "3.1")
+ set(XSAN_COMPILE_FLAGS "-fsanitize=thread")
+ set(XSAN_LINKER_FLAGS "tsan")
+ elseif (${sanitize_option} MATCHES "memory")
+ check_compiler_version("99.99" "3.1")
+ set(XSAN_COMPILE_FLAGS "-fsanitize=memory")
+ elseif (${sanitize_option} MATCHES "leak")
+ check_compiler_version("4.9" "3.4")
+ set(XSAN_COMPILE_FLAGS "-fsanitize=leak")
+ set(XSAN_LINKER_FLAGS "lsan")
+ elseif (${sanitize_option} MATCHES "undefined")
+ check_compiler_version("4.9" "3.1")
+ set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls")
+ else ()
+ message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.")
+ endif ()
+endmacro ()
+
+if (ECM_ENABLE_SANITIZERS)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # for each element of the ECM_ENABLE_SANITIZERS list
+ foreach ( CUR_SANITIZER ${ECM_ENABLE_SANITIZERS} )
+ # lowercase filter
+ string(TOLOWER ${CUR_SANITIZER} CUR_SANITIZER)
+ # check option and enable appropriate flags
+ enable_sanitizer_flags ( ${CUR_SANITIZER} )
+ # TODO: GCC will not link pthread library if enabled ASan
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XSAN_COMPILE_FLAGS}" )
+ endif()
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XSAN_COMPILE_FLAGS}" )
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ link_libraries(${XSAN_LINKER_FLAGS})
+ endif()
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
+ string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
+ endif ()
+ endforeach()
+ else()
+ message(STATUS "Tried to enable sanitizers (-DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}), \
+but compiler (${CMAKE_CXX_COMPILER_ID}) does not have sanitizer support")
+ endif()
+endif()
diff --git a/cmake/3rdparty/extra-cmake-modules/modules/ECMFindModuleHelpers.cmake b/cmake/3rdparty/extra-cmake-modules/modules/ECMFindModuleHelpers.cmake
new file mode 100644
index 0000000000..f2e32f959e
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/modules/ECMFindModuleHelpers.cmake
@@ -0,0 +1,297 @@
+#.rst:
+# ECMFindModuleHelpers
+# --------------------
+#
+# Helper macros for find modules: ecm_find_package_version_check(),
+# ecm_find_package_parse_components() and
+# ecm_find_package_handle_library_components().
+#
+# ::
+#
+# ecm_find_package_version_check(<name>)
+#
+# Prints warnings if the CMake version or the project's required CMake version
+# is older than that required by extra-cmake-modules.
+#
+# ::
+#
+# ecm_find_package_parse_components(<name>
+# RESULT_VAR <variable>
+# KNOWN_COMPONENTS <component1> [<component2> [...]]
+# [SKIP_DEPENDENCY_HANDLING])
+#
+# This macro will populate <variable> with a list of components found in
+# <name>_FIND_COMPONENTS, after checking that all those components are in the
+# list of KNOWN_COMPONENTS; if there are any unknown components, it will print
+# an error or warning (depending on the value of <name>_FIND_REQUIRED) and call
+# return().
+#
+# The order of components in <variable> is guaranteed to match the order they
+# are listed in the KNOWN_COMPONENTS argument.
+#
+# If SKIP_DEPENDENCY_HANDLING is not set, for each component the variable
+# <name>_<component>_component_deps will be checked for dependent components.
+# If <component> is listed in <name>_FIND_COMPONENTS, then all its (transitive)
+# dependencies will also be added to <variable>.
+#
+# ::
+#
+# ecm_find_package_handle_library_components(<name>
+# COMPONENTS <component> [<component> [...]]
+# [SKIP_DEPENDENCY_HANDLING])
+# [SKIP_PKG_CONFIG])
+#
+# Creates an imported library target for each component. The operation of this
+# macro depends on the presence of a number of CMake variables.
+#
+# The <name>_<component>_lib variable should contain the name of this library,
+# and <name>_<component>_header variable should contain the name of a header
+# file associated with it (whatever relative path is normally passed to
+# '#include'). <name>_<component>_header_subdir variable can be used to specify
+# which subdirectory of the include path the headers will be found in.
+# ecm_find_package_components() will then search for the library
+# and include directory (creating appropriate cache variables) and create an
+# imported library target named <name>::<component>.
+#
+# Additional variables can be used to provide additional information:
+#
+# If SKIP_PKG_CONFIG, the <name>_<component>_pkg_config variable is set, and
+# pkg-config is found, the pkg-config module given by
+# <name>_<component>_pkg_config will be searched for and used to help locate the
+# library and header file. It will also be used to set
+# <name>_<component>_VERSION.
+#
+# Note that if version information is found via pkg-config,
+# <name>_<component>_FIND_VERSION can be set to require a particular version
+# for each component.
+#
+# If SKIP_DEPENDENCY_HANDLING is not set, the INTERFACE_LINK_LIBRARIES property
+# of the imported target for <component> will be set to contain the imported
+# targets for the components listed in <name>_<component>_component_deps.
+# <component>_FOUND will also be set to false if any of the compoments in
+# <name>_<component>_component_deps are not found. This requires the components
+# in <name>_<component>_component_deps to be listed before <component> in the
+# COMPONENTS argument.
+#
+# The following variables will be set:
+#
+# ``<name>_TARGETS``
+# the imported targets
+# ``<name>_LIBRARIES``
+# the found libraries
+# ``<name>_INCLUDE_DIRS``
+# the combined required include directories for the components
+# ``<name>_DEFINITIONS``
+# the "other" CFLAGS provided by pkg-config, if any
+# ``<name>_VERSION``
+# the value of ``<name>_<component>_VERSION`` for the first component that
+# has this variable set (note that components are searched for in the order
+# they are passed to the macro), although if it is already set, it will not
+# be altered
+#
+# Note that these variables are never cleared, so if
+# ecm_find_package_handle_library_components() is called multiple times with
+# different components (typically because of multiple find_package() calls) then
+# ``<name>_TARGETS``, for example, will contain all the targets found in any
+# call (although no duplicates).
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include(CMakeParseArguments)
+
+macro(ecm_find_package_version_check module_name)
+ if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by Find${module_name}.cmake")
+ endif()
+ if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use Find${module_name}.cmake")
+ endif()
+endmacro()
+
+macro(ecm_find_package_parse_components module_name)
+ set(ecm_fppc_options SKIP_DEPENDENCY_HANDLING)
+ set(ecm_fppc_oneValueArgs RESULT_VAR)
+ set(ecm_fppc_multiValueArgs KNOWN_COMPONENTS DEFAULT_COMPONENTS)
+ cmake_parse_arguments(ECM_FPPC "${ecm_fppc_options}" "${ecm_fppc_oneValueArgs}" "${ecm_fppc_multiValueArgs}" ${ARGN})
+
+ if(ECM_FPPC_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unexpected arguments to ecm_find_package_parse_components: ${ECM_FPPC_UNPARSED_ARGUMENTS}")
+ endif()
+ if(NOT ECM_FPPC_RESULT_VAR)
+ message(FATAL_ERROR "Missing RESULT_VAR argument to ecm_find_package_parse_components")
+ endif()
+ if(NOT ECM_FPPC_KNOWN_COMPONENTS)
+ message(FATAL_ERROR "Missing KNOWN_COMPONENTS argument to ecm_find_package_parse_components")
+ endif()
+ if(NOT ECM_FPPC_DEFAULT_COMPONENTS)
+ set(ECM_FPPC_DEFAULT_COMPONENTS ${ECM_FPPC_KNOWN_COMPONENTS})
+ endif()
+
+ if(${module_name}_FIND_COMPONENTS)
+ set(ecm_fppc_requestedComps ${${module_name}_FIND_COMPONENTS})
+
+ if(NOT ECM_FPPC_SKIP_DEPENDENCY_HANDLING)
+ # Make sure deps are included
+ foreach(ecm_fppc_comp ${ecm_fppc_requestedComps})
+ foreach(ecm_fppc_dep_comp ${${module_name}_${ecm_fppc_comp}_component_deps})
+ list(FIND ecm_fppc_requestedComps "${ecm_fppc_dep_comp}" ecm_fppc_index)
+ if("${ecm_fppc_index}" STREQUAL "-1")
+ if(NOT ${module_name}_FIND_QUIETLY)
+ message(STATUS "${module_name}: ${ecm_fppc_comp} requires ${${module_name}_${ecm_fppc_comp}_component_deps}")
+ endif()
+ list(APPEND ecm_fppc_requestedComps "${ecm_fppc_dep_comp}")
+ endif()
+ endforeach()
+ endforeach()
+ else()
+ message(STATUS "Skipping dependency handling for ${module_name}")
+ endif()
+ list(REMOVE_DUPLICATES ecm_fppc_requestedComps)
+
+ # This makes sure components are listed in the same order as
+ # KNOWN_COMPONENTS (potentially important for inter-dependencies)
+ set(${ECM_FPPC_RESULT_VAR})
+ foreach(ecm_fppc_comp ${ECM_FPPC_KNOWN_COMPONENTS})
+ list(FIND ecm_fppc_requestedComps "${ecm_fppc_comp}" ecm_fppc_index)
+ if(NOT "${ecm_fppc_index}" STREQUAL "-1")
+ list(APPEND ${ECM_FPPC_RESULT_VAR} "${ecm_fppc_comp}")
+ list(REMOVE_AT ecm_fppc_requestedComps ${ecm_fppc_index})
+ endif()
+ endforeach()
+ # if there are any left, they are unknown components
+ if(ecm_fppc_requestedComps)
+ set(ecm_fppc_msgType STATUS)
+ if(${module_name}_FIND_REQUIRED)
+ set(ecm_fppc_msgType FATAL_ERROR)
+ endif()
+ if(NOT ${module_name}_FIND_QUIETLY)
+ message(${ecm_fppc_msgType} "${module_name}: requested unknown components ${ecm_fppc_requestedComps}")
+ endif()
+ return()
+ endif()
+ else()
+ set(${ECM_FPPC_RESULT_VAR} ${ECM_FPPC_DEFAULT_COMPONENTS})
+ endif()
+endmacro()
+
+macro(ecm_find_package_handle_library_components module_name)
+ set(ecm_fpwc_options SKIP_PKG_CONFIG SKIP_DEPENDENCY_HANDLING)
+ set(ecm_fpwc_oneValueArgs)
+ set(ecm_fpwc_multiValueArgs COMPONENTS)
+ cmake_parse_arguments(ECM_FPWC "${ecm_fpwc_options}" "${ecm_fpwc_oneValueArgs}" "${ecm_fpwc_multiValueArgs}" ${ARGN})
+
+ if(ECM_FPWC_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unexpected arguments to ecm_find_package_handle_components: ${ECM_FPWC_UNPARSED_ARGUMENTS}")
+ endif()
+ if(NOT ECM_FPWC_COMPONENTS)
+ message(FATAL_ERROR "Missing COMPONENTS argument to ecm_find_package_handle_components")
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ find_package(PkgConfig)
+ foreach(ecm_fpwc_comp ${ECM_FPWC_COMPONENTS})
+ set(ecm_fpwc_dep_vars)
+ set(ecm_fpwc_dep_targets)
+ if(NOT SKIP_DEPENDENCY_HANDLING)
+ foreach(ecm_fpwc_dep ${${module_name}_${ecm_fpwc_comp}_component_deps})
+ list(APPEND ecm_fpwc_dep_vars "${module_name}_${ecm_fpwc_dep}_FOUND")
+ list(APPEND ecm_fpwc_dep_targets "${module_name}::${ecm_fpwc_dep}")
+ endforeach()
+ endif()
+
+ if(NOT ECM_FPWC_SKIP_PKG_CONFIG AND ${module_name}_${ecm_fpwc_comp}_pkg_config)
+ pkg_check_modules(PKG_${module_name}_${ecm_fpwc_comp} QUIET
+ ${${module_name}_${ecm_fpwc_comp}_pkg_config})
+ endif()
+
+ find_path(${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR
+ NAMES ${${module_name}_${ecm_fpwc_comp}_header}
+ HINTS ${PKG_${module_name}_${ecm_fpwc_comp}_INCLUDE_DIRS}
+ PATH_SUFFIXES ${${module_name}_${ecm_fpwc_comp}_header_subdir}
+ )
+ find_library(${module_name}_${ecm_fpwc_comp}_LIBRARY
+ NAMES ${${module_name}_${ecm_fpwc_comp}_lib}
+ HINTS ${PKG_${module_name}_${ecm_fpwc_comp}_LIBRARY_DIRS}
+ )
+
+ set(${module_name}_${ecm_fpwc_comp}_VERSION "${PKG_${module_name}_${ecm_fpwc_comp}_VERSION}")
+ if(NOT ${module_name}_VERSION)
+ set(${module_name}_VERSION ${${module_name}_${ecm_fpwc_comp}_VERSION})
+ endif()
+
+ find_package_handle_standard_args(${module_name}_${ecm_fpwc_comp}
+ FOUND_VAR
+ ${module_name}_${ecm_fpwc_comp}_FOUND
+ REQUIRED_VARS
+ ${module_name}_${ecm_fpwc_comp}_LIBRARY
+ ${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR
+ ${ecm_fpwc_dep_vars}
+ VERSION_VAR
+ ${module_name}_${ecm_fpwc_comp}_VERSION
+ )
+
+ mark_as_advanced(
+ ${module_name}_${ecm_fpwc_comp}_LIBRARY
+ ${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR
+ )
+
+ if(${module_name}_${ecm_fpwc_comp}_FOUND)
+ list(APPEND ${module_name}_LIBRARIES
+ "${${module_name}_${ecm_fpwc_comp}_LIBRARY}")
+ list(APPEND ${module_name}_INCLUDE_DIRS
+ "${${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR}")
+ set(${module_name}_DEFINITIONS
+ ${${module_name}_DEFINITIONS}
+ ${PKG_${module_name}_${ecm_fpwc_comp}_DEFINITIONS})
+ if(NOT TARGET ${module_name}::${ecm_fpwc_comp})
+ add_library(${module_name}::${ecm_fpwc_comp} UNKNOWN IMPORTED)
+ set_target_properties(${module_name}::${ecm_fpwc_comp} PROPERTIES
+ IMPORTED_LOCATION "${${module_name}_${ecm_fpwc_comp}_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${PKG_${module_name}_${ecm_fpwc_comp}_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR}"
+ INTERFACE_LINK_LIBRARIES "${ecm_fpwc_dep_targets}"
+ )
+ endif()
+ list(APPEND ${module_name}_TARGETS
+ "${module_name}::${ecm_fpwc_comp}")
+ endif()
+ endforeach()
+ if(${module_name}_LIBRARIES)
+ list(REMOVE_DUPLICATES ${module_name}_LIBRARIES)
+ endif()
+ if(${module_name}_INCLUDE_DIRS)
+ list(REMOVE_DUPLICATES ${module_name}_INCLUDE_DIRS)
+ endif()
+ if(${module_name}_DEFINITIONS)
+ list(REMOVE_DUPLICATES ${module_name}_DEFINITIONS)
+ endif()
+ if(${module_name}_TARGETS)
+ list(REMOVE_DUPLICATES ${module_name}_TARGETS)
+ endif()
+endmacro()
diff --git a/cmake/3rdparty/extra-cmake-modules/qt_attribution.json b/cmake/3rdparty/extra-cmake-modules/qt_attribution.json
new file mode 100644
index 0000000000..cebebf82eb
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/qt_attribution.json
@@ -0,0 +1,15 @@
+{
+ "Id": "extra-cmake-modules",
+ "Name": "extra-cmake-modules",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used as part of the build system.",
+
+ "Description": "Additional CMake modules.",
+ "Homepage": "https://api.kde.org/ecm/",
+ "Version": "5.50.0",
+
+ "License": "BSD-3-Clause",
+ "LicenseId": "BSD 3-Clause License",
+ "LicenseFile": "COPYING-CMAKE-SCRIPTS",
+ "Copyright": "Copyright © 2011-2018 The KDE community"
+}
diff --git a/cmake/3rdparty/kwin/COPYING-CMAKE-SCRIPTS b/cmake/3rdparty/kwin/COPYING-CMAKE-SCRIPTS
new file mode 100644
index 0000000000..4b417765f3
--- /dev/null
+++ b/cmake/3rdparty/kwin/COPYING-CMAKE-SCRIPTS
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/cmake/3rdparty/kwin/FindLibdrm.cmake b/cmake/3rdparty/kwin/FindLibdrm.cmake
new file mode 100644
index 0000000000..9936e07eee
--- /dev/null
+++ b/cmake/3rdparty/kwin/FindLibdrm.cmake
@@ -0,0 +1,126 @@
+#.rst:
+# FindLibdrm
+# -------
+#
+# Try to find libdrm on a Unix system.
+#
+# This will define the following variables:
+#
+# ``Libdrm_FOUND``
+# True if (the requested version of) libdrm is available
+# ``Libdrm_VERSION``
+# The version of libdrm
+# ``Libdrm_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the ``Libdrm::Libdrm``
+# target
+# ``Libdrm_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the target is not
+# used for linking
+# ``Libdrm_DEFINITIONS``
+# This should be passed to target_compile_options() if the target is not
+# used for linking
+#
+# If ``Libdrm_FOUND`` is TRUE, it will also define the following imported target:
+#
+# ``Libdrm::Libdrm``
+# The libdrm library
+#
+# In general we recommend using the imported target, as it is easier to use.
+# Bear in mind, however, that if the target is in the link interface of an
+# exported library, it must be made available by the package config file.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by FindLibdrm.cmake")
+endif()
+if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibdrm.cmake")
+endif()
+
+if(NOT WIN32)
+ # Use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ find_package(PkgConfig)
+ pkg_check_modules(PKG_Libdrm QUIET libdrm)
+
+ set(Libdrm_DEFINITIONS ${PKG_Libdrm_CFLAGS_OTHER})
+ set(Libdrm_VERSION ${PKG_Libdrm_VERSION})
+
+ find_path(Libdrm_INCLUDE_DIR
+ NAMES
+ xf86drm.h
+ HINTS
+ ${PKG_Libdrm_INCLUDE_DIRS}
+ )
+ find_library(Libdrm_LIBRARY
+ NAMES
+ drm
+ HINTS
+ ${PKG_Libdrm_LIBRARY_DIRS}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Libdrm
+ FOUND_VAR
+ Libdrm_FOUND
+ REQUIRED_VARS
+ Libdrm_LIBRARY
+ Libdrm_INCLUDE_DIR
+ VERSION_VAR
+ Libdrm_VERSION
+ )
+
+ if(Libdrm_FOUND AND NOT TARGET Libdrm::Libdrm)
+ add_library(Libdrm::Libdrm UNKNOWN IMPORTED)
+ set_target_properties(Libdrm::Libdrm PROPERTIES
+ IMPORTED_LOCATION "${Libdrm_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${Libdrm_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}/libdrm"
+ )
+ endif()
+
+ mark_as_advanced(Libdrm_LIBRARY Libdrm_INCLUDE_DIR)
+
+ # compatibility variables
+ set(Libdrm_LIBRARIES ${Libdrm_LIBRARY})
+ set(Libdrm_INCLUDE_DIRS ${Libdrm_INCLUDE_DIR} "${Libdrm_INCLUDE_DIR}/libdrm")
+ set(Libdrm_VERSION_STRING ${Libdrm_VERSION})
+
+else()
+ message(STATUS "FindLibdrm.cmake cannot find libdrm on Windows systems.")
+ set(Libdrm_FOUND FALSE)
+endif()
+
+include(FeatureSummary)
+set_package_properties(Libdrm PROPERTIES
+ URL "https://wiki.freedesktop.org/dri/"
+ DESCRIPTION "Userspace interface to kernel DRM services."
+)
diff --git a/cmake/3rdparty/kwin/FindLibinput.cmake b/cmake/3rdparty/kwin/FindLibinput.cmake
new file mode 100644
index 0000000000..b856e0bbcb
--- /dev/null
+++ b/cmake/3rdparty/kwin/FindLibinput.cmake
@@ -0,0 +1,125 @@
+#.rst:
+# FindLibinput
+# -------
+#
+# Try to find libinput on a Unix system.
+#
+# This will define the following variables:
+#
+# ``Libinput_FOUND``
+# True if (the requested version of) libinput is available
+# ``Libinput_VERSION``
+# The version of libinput
+# ``Libinput_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the ``Libinput::Libinput``
+# target
+# ``Libinput_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the target is not
+# used for linking
+# ``Libinput_DEFINITIONS``
+# This should be passed to target_compile_options() if the target is not
+# used for linking
+#
+# If ``Libinput_FOUND`` is TRUE, it will also define the following imported target:
+#
+# ``Libinput::Libinput``
+# The libinput library
+#
+# In general we recommend using the imported target, as it is easier to use.
+# Bear in mind, however, that if the target is in the link interface of an
+# exported library, it must be made available by the package config file.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by FindLibinput.cmake")
+endif()
+if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibinput.cmake")
+endif()
+
+if(NOT WIN32)
+ # Use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ find_package(PkgConfig)
+ pkg_check_modules(PKG_Libinput QUIET libinput)
+
+ set(Libinput_DEFINITIONS ${PKG_Libinput_CFLAGS_OTHER})
+ set(Libinput_VERSION ${PKG_Libinput_VERSION})
+
+ find_path(Libinput_INCLUDE_DIR
+ NAMES
+ libinput.h
+ HINTS
+ ${PKG_Libinput_INCLUDE_DIRS}
+ )
+ find_library(Libinput_LIBRARY
+ NAMES
+ input
+ HINTS
+ ${PKG_Libinput_LIBRARY_DIRS}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Libinput
+ FOUND_VAR
+ Libinput_FOUND
+ REQUIRED_VARS
+ Libinput_LIBRARY
+ Libinput_INCLUDE_DIR
+ VERSION_VAR
+ Libinput_VERSION
+ )
+
+ if(Libinput_FOUND AND NOT TARGET Libinput::Libinput)
+ add_library(Libinput::Libinput UNKNOWN IMPORTED)
+ set_target_properties(Libinput::Libinput PROPERTIES
+ IMPORTED_LOCATION "${Libinput_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${Libinput_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Libinput_INCLUDE_DIR}"
+ )
+ endif()
+
+ mark_as_advanced(Libinput_LIBRARY Libinput_INCLUDE_DIR)
+
+ # compatibility variables
+ set(Libinput_LIBRARIES ${Libinput_LIBRARY})
+ set(Libinput_INCLUDE_DIRS ${Libinput_INCLUDE_DIR})
+ set(Libinput_VERSION_STRING ${Libinput_VERSION})
+
+else()
+ message(STATUS "FindLibinput.cmake cannot find libinput on Windows systems.")
+ set(Libinput_FOUND FALSE)
+endif()
+
+include(FeatureSummary)
+set_package_properties(Libinput PROPERTIES
+ URL "http://www.freedesktop.org/wiki/Software/libinput/"
+ DESCRIPTION "Library to handle input devices in Wayland compositors and to provide a generic X.Org input driver."
+)
diff --git a/cmake/3rdparty/kwin/FindXKB.cmake b/cmake/3rdparty/kwin/FindXKB.cmake
new file mode 100644
index 0000000000..0d599df0fd
--- /dev/null
+++ b/cmake/3rdparty/kwin/FindXKB.cmake
@@ -0,0 +1,101 @@
+# Try to find xkbcommon on a Unix system
+#
+# This will define:
+#
+# XKB_FOUND - True if XKB is available
+# XKB_LIBRARIES - Link these to use XKB
+# XKB_INCLUDE_DIRS - Include directory for XKB
+# XKB_DEFINITIONS - Compiler flags for using XKB
+#
+# Additionally, the following imported targets will be defined:
+#
+# XKB::XKB
+#
+# Copyright (c) 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by FindXKB.cmake")
+endif()
+if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindXKB.cmake")
+endif()
+
+if(NOT WIN32)
+ # Use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ find_package(PkgConfig)
+ pkg_check_modules(PKG_XKB QUIET xkbcommon)
+
+ set(XKB_DEFINITIONS ${PKG_XKB_CFLAGS_OTHER})
+
+ find_path(XKB_INCLUDE_DIR
+ NAMES
+ xkbcommon/xkbcommon.h
+ HINTS
+ ${PKG_XKB_INCLUDE_DIRS}
+ )
+ find_library(XKB_LIBRARY
+ NAMES
+ xkbcommon
+ HINTS
+ ${PKG_XKB_LIBRARY_DIRS}
+ )
+
+ set(XKB_LIBRARIES ${XKB_LIBRARY})
+ set(XKB_INCLUDE_DIRS ${XKB_INCLUDE_DIR})
+ set(XKB_VERSION ${PKG_XKB_VERSION})
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(XKB
+ FOUND_VAR
+ XKB_FOUND
+ REQUIRED_VARS
+ XKB_LIBRARY
+ XKB_INCLUDE_DIR
+ VERSION_VAR
+ XKB_VERSION
+ )
+
+ if(XKB_FOUND AND NOT TARGET XKB::XKB)
+ add_library(XKB::XKB UNKNOWN IMPORTED)
+ set_target_properties(XKB::XKB PROPERTIES
+ IMPORTED_LOCATION "${XKB_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${XKB_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${XKB_INCLUDE_DIR}"
+ )
+ endif()
+
+else()
+ message(STATUS "FindXKB.cmake cannot find XKB on Windows systems.")
+ set(XKB_FOUND FALSE)
+endif()
+
+include(FeatureSummary)
+set_package_properties(XKB PROPERTIES
+ URL "http://xkbcommon.org"
+ DESCRIPTION "XKB API common to servers and clients."
+)
diff --git a/cmake/3rdparty/kwin/Findgbm.cmake b/cmake/3rdparty/kwin/Findgbm.cmake
new file mode 100644
index 0000000000..6dfc895daa
--- /dev/null
+++ b/cmake/3rdparty/kwin/Findgbm.cmake
@@ -0,0 +1,125 @@
+#.rst:
+# Findgbm
+# -------
+#
+# Try to find gbm on a Unix system.
+#
+# This will define the following variables:
+#
+# ``gbm_FOUND``
+# True if (the requested version of) gbm is available
+# ``gbm_VERSION``
+# The version of gbm
+# ``gbm_LIBRARIES``
+# This can be passed to target_link_libraries() instead of the ``gbm::gbm``
+# target
+# ``gbm_INCLUDE_DIRS``
+# This should be passed to target_include_directories() if the target is not
+# used for linking
+# ``gbm_DEFINITIONS``
+# This should be passed to target_compile_options() if the target is not
+# used for linking
+#
+# If ``gbm_FOUND`` is TRUE, it will also define the following imported target:
+#
+# ``gbm::gbm``
+# The gbm library
+#
+# In general we recommend using the imported target, as it is easier to use.
+# Bear in mind, however, that if the target is in the link interface of an
+# exported library, it must be made available by the package config file.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by Findgbm.cmake")
+endif()
+if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use Findgbm.cmake")
+endif()
+
+if(NOT WIN32)
+ # Use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ find_package(PkgConfig)
+ pkg_check_modules(PKG_gbm QUIET gbm)
+
+ set(gbm_DEFINITIONS ${PKG_gbm_CFLAGS_OTHER})
+ set(gbm_VERSION ${PKG_gbm_VERSION})
+
+ find_path(gbm_INCLUDE_DIR
+ NAMES
+ gbm.h
+ HINTS
+ ${PKG_gbm_INCLUDE_DIRS}
+ )
+ find_library(gbm_LIBRARY
+ NAMES
+ gbm
+ HINTS
+ ${PKG_gbm_LIBRARY_DIRS}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(gbm
+ FOUND_VAR
+ gbm_FOUND
+ REQUIRED_VARS
+ gbm_LIBRARY
+ gbm_INCLUDE_DIR
+ VERSION_VAR
+ gbm_VERSION
+ )
+
+ if(gbm_FOUND AND NOT TARGET gbm::gbm)
+ add_library(gbm::gbm UNKNOWN IMPORTED)
+ set_target_properties(gbm::gbm PROPERTIES
+ IMPORTED_LOCATION "${gbm_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${gbm_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${gbm_INCLUDE_DIR}"
+ )
+ endif()
+
+ mark_as_advanced(gbm_LIBRARY gbm_INCLUDE_DIR)
+
+ # compatibility variables
+ set(gbm_LIBRARIES ${gbm_LIBRARY})
+ set(gbm_INCLUDE_DIRS ${gbm_INCLUDE_DIR})
+ set(gbm_VERSION_STRING ${gbm_VERSION})
+
+else()
+ message(STATUS "Findgbm.cmake cannot find gbm on Windows systems.")
+ set(gbm_FOUND FALSE)
+endif()
+
+include(FeatureSummary)
+set_package_properties(gbm PROPERTIES
+ URL "http://www.mesa3d.org"
+ DESCRIPTION "Mesa gbm library."
+)
diff --git a/cmake/3rdparty/kwin/qt_attribution.json b/cmake/3rdparty/kwin/qt_attribution.json
new file mode 100644
index 0000000000..5c22641132
--- /dev/null
+++ b/cmake/3rdparty/kwin/qt_attribution.json
@@ -0,0 +1,17 @@
+{
+ "Id": "kwin",
+ "Name": "KWin",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used as part of the build system.",
+
+ "Description": "Additional CMake modules for graphics system dependencies.",
+ "Homepage": "https://www.kde.org/",
+ "Version": "5.13.4",
+
+ "License": "BSD-3-Clause",
+ "LicenseId": "BSD 3-Clause License",
+ "LicenseFile": "COPYING-CMAKE-SCRIPTS",
+ "Copyright": "Copyright 2014 Alex Merry <alex.merry@kde.org>
+Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>,
+Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>"
+}
diff --git a/cmake/3rdpartyConfig.cmake.in b/cmake/3rdpartyConfig.cmake.in
new file mode 100644
index 0000000000..6af3792333
--- /dev/null
+++ b/cmake/3rdpartyConfig.cmake.in
@@ -0,0 +1,15 @@
+@PACKAGE_INIT@
+
+get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
+
+set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+set(CMAKE_MODULE_PATH "${_import_prefix}" ${CMAKE_MODULE_PATH} )
+
+@3RDPARTY_ADDITIONAL_SETUP_CODE@
+
+set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
+
+if (NOT QT_NO_CREATE_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@target@Targets.cmake")
+endif()
diff --git a/cmake/FindATSPI2.cmake b/cmake/FindATSPI2.cmake
new file mode 100644
index 0000000000..ca0045635b
--- /dev/null
+++ b/cmake/FindATSPI2.cmake
@@ -0,0 +1,7 @@
+include(FindPkgConfig)
+
+pkg_check_modules(ATSPI2 atspi-2 IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::ATSPI2)
+ set(ATSPI2_FOUND 0)
+endif()
diff --git a/cmake/FindAtomic.cmake b/cmake/FindAtomic.cmake
new file mode 100644
index 0000000000..91cee62046
--- /dev/null
+++ b/cmake/FindAtomic.cmake
@@ -0,0 +1,44 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET Atomic)
+ set(Atomic_FOUND ON)
+ return()
+endif()
+
+include(CheckCXXSourceCompiles)
+
+set (atomic_test_sources "#include <atomic>
+#include <cstdint>
+
+void test(volatile std::atomic<std::int64_t> &a)
+{
+ std::int64_t v = a.load(std::memory_order_acquire);
+ while (!a.compare_exchange_strong(v, v + 1,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire)) {
+ v = a.exchange(v - 1);
+ }
+ a.store(v + 1, std::memory_order_release);
+}
+
+int main(int, char **)
+{
+ void *ptr = (void*)0xffffffc0; // any random pointer
+ test(*reinterpret_cast<std::atomic<std::int64_t> *>(ptr));
+ return 0;
+}")
+
+check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC)
+if(NOT HAVE_STDATOMIC)
+ set(_req_libraries "${CMAKE_REQUIRE_LIBRARIES}")
+ set(CMAKE_REQUIRE_LIBRARIES "atomic")
+ check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC_WITH_LIB)
+ set(CMAKE_REQUIRE_LIBRARIES "${_req_libraries}")
+endif()
+
+add_library(Atomic INTERFACE IMPORTED)
+if(HAVE_STDATOMIC_WITH_LIB)
+ target_link_libraries(Atomic INTERFACE atomic)
+endif()
+
+set(Atomic_FOUND 1)
diff --git a/cmake/FindCups.cmake b/cmake/FindCups.cmake
new file mode 100644
index 0000000000..7a78100aae
--- /dev/null
+++ b/cmake/FindCups.cmake
@@ -0,0 +1,98 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindCups
+--------
+
+Find the CUPS printing system.
+
+Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which
+features this function (i.e. at least 1.1.19)
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``Cups::Cups``, if Cups has
+been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``CUPS_FOUND``
+ true if CUPS headers and libraries were found
+``CUPS_INCLUDE_DIRS``
+ the directory containing the Cups headers
+``CUPS_LIBRARIES``
+ the libraries to link against to use CUPS.
+``CUPS_VERSION_STRING``
+ the version of CUPS found (since CMake 2.8.8)
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``CUPS_INCLUDE_DIR``
+ the directory containing the Cups headers
+#]=======================================================================]
+
+find_path(CUPS_INCLUDE_DIR cups/cups.h )
+
+find_library(CUPS_LIBRARIES NAMES cups )
+
+if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY})
+
+ # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint)
+ CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE)
+ cmake_pop_check_state()
+endif ()
+
+if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
+ file(STRINGS "${CUPS_INCLUDE_DIR}/cups/cups.h" cups_version_str
+ REGEX "^#[\t ]*define[\t ]+CUPS_VERSION_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
+
+ unset(CUPS_VERSION_STRING)
+ foreach(VPART MAJOR MINOR PATCH)
+ foreach(VLINE ${cups_version_str})
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$")
+ set(CUPS_VERSION_PART "${CMAKE_MATCH_1}")
+ if(CUPS_VERSION_STRING)
+ string(APPEND CUPS_VERSION_STRING ".${CUPS_VERSION_PART}")
+ else()
+ set(CUPS_VERSION_STRING "${CUPS_VERSION_PART}")
+ endif()
+ endif()
+ endforeach()
+ endforeach()
+endif ()
+
+include(FindPackageHandleStandardArgs)
+
+if (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
+ REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR CUPS_HAS_IPP_DELETE_ATTRIBUTE
+ VERSION_VAR CUPS_VERSION_STRING)
+else ()
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
+ REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR
+ VERSION_VAR CUPS_VERSION_STRING)
+endif ()
+
+mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES)
+
+if (CUPS_FOUND)
+ set(CUPS_INCLUDE_DIRS "${CUPS_INCLUDE_DIR}")
+ if (NOT TARGET Cups::Cups)
+ add_library(Cups::Cups INTERFACE IMPORTED)
+ set_target_properties(Cups::Cups PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${CUPS_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${CUPS_INCLUDE_DIR}")
+ endif ()
+endif ()
diff --git a/cmake/FindDB2.cmake b/cmake/FindDB2.cmake
new file mode 100644
index 0000000000..59eadab7d5
--- /dev/null
+++ b/cmake/FindDB2.cmake
@@ -0,0 +1,59 @@
+#.rst:
+# FindDB2
+# ---------
+#
+# Try to locate the db2 client library.
+# If found, this will define the following variables:
+#
+# ``DB2_FOUND``
+# True if the db2 library is available
+# ``DB2_INCLUDE_DIRS``
+# The db2 include directories
+# ``DB2_LIBRARIES``
+# The db2 libraries for linking
+#
+# If ``DB2_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``DB2::DB2``
+# The db2 client library
+
+if (NOT DEFINED DB2_INCLUDE_DIR)
+ find_path(DB2_INCLUDE_DIRS
+ NAMES sqlcli1.h
+ HINTS ENV DB2_HOME
+ PATH_SUFFIXES include)
+else()
+ find_path(DB2_INCLUDE_DIRS
+ NAMES sqlcli1.h
+ HINTS ${DB2_INCLUDE_DIR})
+endif()
+
+if (NOT DEFINED DB2_LIBRARY_DIR)
+ find_library(DB2_LIBRARIES
+ NAMES db2
+ HINTS ENV DB2LIB)
+else()
+ find_library(DB2_LIBRARIES
+ NAMES db2
+ HINTS ${DB2_LIBRARY_DIR})
+endif()
+
+if (NOT DB2_INCLUDE_DIRS STREQUAL "DB2_INCLUDE_DIRS-NOTFOUND" AND NOT DB2_LIBRARIES STREQUAL "DB2_LIBRARIES-NOTFOUND")
+ set(DB2_FOUND ON)
+endif()
+
+if(DB2_FOUND AND NOT TARGET DB2::DB2)
+ add_library(DB2::DB2 UNKNOWN IMPORTED)
+ set_target_properties(DB2::DB2 PROPERTIES
+ IMPORTED_LOCATION "${DB2_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${DB2_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(DB2_INCLUDE_DIRS DB2_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(DB2 PROPERTIES
+ URL "https://www.ibm.com"
+ DESCRIPTION "IBM DB2 client library")
+
diff --git a/cmake/FindDirectFB.cmake b/cmake/FindDirectFB.cmake
new file mode 100644
index 0000000000..4446018587
--- /dev/null
+++ b/cmake/FindDirectFB.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(DirectFB directfb IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::DirectFB)
+ set(DirectFB_FOUND 0)
+endif()
diff --git a/cmake/FindGLESv2.cmake b/cmake/FindGLESv2.cmake
new file mode 100644
index 0000000000..49e757ef55
--- /dev/null
+++ b/cmake/FindGLESv2.cmake
@@ -0,0 +1,72 @@
+include(CheckCXXSourceCompiles)
+
+# No library linkage is necessary to use GLESv2 with Emscripten. The headers are also
+# system headers, so we don't need to search for them.
+if(EMSCRIPTEN)
+ set(HAVE_GLESv2 ON)
+else()
+ find_library(GLESv2_LIBRARY NAMES GLESv2 OpenGLES)
+ find_path(GLESv2_INCLUDE_DIR NAMES "GLES2/gl2.h" "OpenGLES/ES2/gl.h" DOC "The OpenGLES 2 include path")
+ set(_libraries "${CMAKE_REQUIRED_LIBRARIES}")
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${GLESv2_LIBRARY}")
+ set(_includes "${CMAKE_REQUIRED_INCLUDES}")
+ list(APPEND CMAKE_REQUIRED_INCLUDES "${GLESv2_INCLUDE_DIR}")
+
+ check_cxx_source_compiles("
+#ifdef __APPLE__
+# include <OpenGLES/ES2/gl.h>
+#else
+# define GL_GLEXT_PROTOTYPES
+# include <GLES2/gl2.h>
+#endif
+
+int main(int argc, char *argv[]) {
+ glUniform1f(1, GLfloat(1.0));
+ glClear(GL_COLOR_BUFFER_BIT);
+}" HAVE_GLESv2)
+
+ set(CMAKE_REQUIRED_LIBRARY "${_libraries}")
+ unset(_libraries)
+ set(CMAKE_REQUIRED_INCLUDES "${_includes}")
+ unset(_includes)
+ set(package_args GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2)
+endif()
+
+# Framework handling partially inspired by FindGLUT.cmake.
+if(GLESv2_LIBRARY MATCHES "/([^/]+)\\.framework$")
+ # TODO: Might need to handle non .tbd suffixes, but didn't find an
+ # example like that.
+ # TODO: Might need to handle INTERFACE_INCLUDE_DIRECTORIES differently.
+ set(_library_imported_location "${GLESv2_LIBRARY}/${CMAKE_MATCH_1}.tbd")
+ if(NOT EXISTS "${_library_imported_location}")
+ set(_library_imported_location "")
+ endif()
+else()
+ set(_library_imported_location "${GLESv2_LIBRARY}")
+endif()
+set(GLESv2_LIBRARY "${_library_imported_location}")
+
+list(APPEND package_args HAVE_GLESv2)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLESv2 DEFAULT_MSG ${package_args})
+
+mark_as_advanced(${package_args})
+
+if(GLESv2_FOUND AND NOT TARGET GLESv2::GLESv2)
+ if(EMSCRIPTEN OR APPLE_UIKIT)
+ add_library(GLESv2::GLESv2 INTERFACE IMPORTED)
+ if(APPLE_UIKIT)
+ # For simulator_and_device builds we can't specify the full library path, because
+ # it's specific to either the device or the simulator. Resort to passing a link
+ # flag instead.
+ set_target_properties(GLESv2::GLESv2 PROPERTIES
+ INTERFACE_LINK_LIBRARIES "-framework OpenGLES")
+ endif()
+ else()
+ add_library(GLESv2::GLESv2 UNKNOWN IMPORTED)
+ set_target_properties(GLESv2::GLESv2 PROPERTIES
+ IMPORTED_LOCATION "${GLESv2_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}")
+ endif()
+endif()
diff --git a/cmake/FindGSSAPI.cmake b/cmake/FindGSSAPI.cmake
new file mode 100644
index 0000000000..6f22929b6c
--- /dev/null
+++ b/cmake/FindGSSAPI.cmake
@@ -0,0 +1,39 @@
+find_package(PkgConfig)
+pkg_check_modules(PC_GSSAPI QUIET krb5-gssapi)
+
+find_path(GSSAPI_INCLUDE_DIRS
+ NAMES gssapi/gssapi.h
+ HINTS ${PC_GSSAPI_INCLUDEDIR}
+ PATH_SUFFIXES gssapi)
+
+find_library(GSSAPI_LIBRARIES
+ NAMES
+ GSS # framework
+ gssapi_krb5
+ HINTS ${PC_GSSAPILIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIRS)
+
+if(GSSAPI_FOUND AND NOT TARGET GSSAPI::GSSAPI)
+ if(GSSAPI_LIBRARIES MATCHES "/([^/]+)\\.framework$")
+ add_library(GSSAPI::GSSAPI INTERFACE IMPORTED)
+ set_target_properties(GSSAPI::GSSAPI PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${GSSAPI_LIBRARIES}")
+ else()
+ add_library(GSSAPI::GSSAPI UNKNOWN IMPORTED)
+ set_target_properties(GSSAPI::GSSAPI PROPERTIES
+ IMPORTED_LOCATION "${GSSAPI_LIBRARIES}")
+ endif()
+
+ set_target_properties(GSSAPI::GSSAPI PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GSSAPI_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(GSSAPI PROPERTIES
+ DESCRIPTION "Generic Security Services Application Program Interface")
+
diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake
new file mode 100644
index 0000000000..9423eb4b9b
--- /dev/null
+++ b/cmake/FindGTK3.cmake
@@ -0,0 +1,7 @@
+include(FindPkgConfig)
+
+pkg_check_modules(GTK3 "gtk+-3.0 >= 3.6" IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::GTK3)
+ set(GTK3_FOUND 0)
+endif()
diff --git a/cmake/FindLibproxy.cmake b/cmake/FindLibproxy.cmake
new file mode 100644
index 0000000000..95d86d1617
--- /dev/null
+++ b/cmake/FindLibproxy.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Libproxy libproxy-1.0 IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::Libproxy)
+ set(Libproxy_FOUND 0)
+endif()
diff --git a/cmake/FindLibsystemd.cmake b/cmake/FindLibsystemd.cmake
new file mode 100644
index 0000000000..9b480700f9
--- /dev/null
+++ b/cmake/FindLibsystemd.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Libsystemd libsystemd IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::Libsystemd)
+ set(Libsystemd_FOUND 0)
+endif()
diff --git a/cmake/FindLibudev.cmake b/cmake/FindLibudev.cmake
new file mode 100644
index 0000000000..637c7c6d88
--- /dev/null
+++ b/cmake/FindLibudev.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Libudev libudev IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::Libudev)
+ set(Libudev_FOUND 0)
+endif()
diff --git a/cmake/FindMtdev.cmake b/cmake/FindMtdev.cmake
new file mode 100644
index 0000000000..c852a77c1c
--- /dev/null
+++ b/cmake/FindMtdev.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Mtdev mtdev IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::MtDev)
+ set(Mtdev_FOUND 0)
+endif()
diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake
new file mode 100644
index 0000000000..0cc5cb6368
--- /dev/null
+++ b/cmake/FindMySQL.cmake
@@ -0,0 +1,50 @@
+#.rst:
+# FindMySQL
+# ---------
+#
+# Try to locate the mysql client library.
+# If found, this will define the following variables:
+#
+# ``MySQL_FOUND``
+# True if the mysql library is available
+# ``MySQL_INCLUDE_DIRS``
+# The mysql include directories
+# ``MySQL_LIBRARIES``
+# The mysql libraries for linking
+#
+# If ``MySQL_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``MySQL::MySQL``
+# The mysql client library
+
+find_package(PkgConfig)
+pkg_check_modules(PC_MySQL QUIET mysqlclient)
+
+find_path(MySQL_INCLUDE_DIRS
+ NAMES mysql.h
+ HINTS ${PC_MySQL_INCLUDEDIR}
+ PATH_SUFFIXES mysql)
+
+find_library(MySQL_LIBRARIES
+ NAMES mysqlclient
+ HINTS ${PC_MySQL_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MySQL DEFAULT_MSG MySQL_LIBRARIES MySQL_INCLUDE_DIRS)
+
+if(MySQL_FOUND AND NOT TARGET MySQL::MySQL)
+ add_library(MySQL::MySQL UNKNOWN IMPORTED)
+ set_target_properties(MySQL::MySQL PROPERTIES
+ IMPORTED_LOCATION "${MySQL_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${MySQL_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(MySQL_INCLUDE_DIRS MySQL_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(MySQL PROPERTIES
+ URL "https://www.mysql.com"
+ DESCRIPTION "MySQL client library")
+
diff --git a/cmake/FindOracle.cmake b/cmake/FindOracle.cmake
new file mode 100644
index 0000000000..58e787e362
--- /dev/null
+++ b/cmake/FindOracle.cmake
@@ -0,0 +1,48 @@
+#.rst:
+# FindOracle
+# ---------
+#
+# Try to locate the oracle client library.
+# If found, this will define the following variables:
+#
+# ``Oracle_FOUND``
+# True if the oracle library is available
+# ``Oracle_INCLUDE_DIRS``
+# The oracle include directories
+# ``Oracle_LIBRARIES``
+# The oracle libraries for linking
+#
+# If ``Oracle_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``Oracle::Oracle``
+# The oracle instant client library
+
+find_path(Oracle_INCLUDE_DIRS
+ NAMES oci.h
+ HINTS ${Oracle_INCLUDE_DIR})
+
+set(ORACLE_OCI_NAMES clntsh ociei oraociei12)
+
+find_library(Oracle_LIBRARIES
+ NAMES NAMES ${ORACLE_OCI_NAMES}
+ HINTS ${Oracle_LIBRARY_DIR})
+
+if (NOT Oracle_INCLUDE_DIRS STREQUAL "Oracle_INCLUDE_DIRS-NOTFOUND" AND NOT Oracle_LIBRARIES STREQUAL "Oracle_LIBRARIES-NOTFOUND")
+ set(Oracle_FOUND ON)
+endif()
+
+if(Oracle_FOUND AND NOT TARGET Oracle::OCI)
+ add_library(Oracle::OCI UNKNOWN IMPORTED)
+ set_target_properties(Oracle::OCI PROPERTIES
+ IMPORTED_LOCATION "${Oracle_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Oracle_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(Oracle_INCLUDE_DIRS Oracle_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(Oracle PROPERTIES
+ URL "https://www.oracle.com"
+ DESCRIPTION "Oracle client library")
+
diff --git a/cmake/FindPPS.cmake b/cmake/FindPPS.cmake
new file mode 100644
index 0000000000..c3360fa82c
--- /dev/null
+++ b/cmake/FindPPS.cmake
@@ -0,0 +1,19 @@
+# Find the PPS library
+
+# Will make the target PPS::PPS available when found.
+
+find_library(PPS_LIBRARY NAMES "pps")
+find_path(PPS_INCLUDE_DIR NAMES "sys/pps.h" DOC "The PPS Include path")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PPS DEFAULT_MSG PPS_INCLUDE_DIR PPS_LIBRARY)
+
+mark_as_advanced(PPS_INCLUDE_DIR PPS_LIBRARY)
+
+if(PPS_FOUND)
+ add_library(__PPS INTERFACE IMPORTED)
+ target_link_libraries(__PPS INTERFACE ${PPS_LIBRARY})
+ target_include_directories(__PPS INTERFACE ${PPS_INCLUDE_DIR})
+
+ add_library(PPS::PPS ALIAS __PPS)
+endif()
diff --git a/cmake/FindSlog2.cmake b/cmake/FindSlog2.cmake
new file mode 100644
index 0000000000..dfb6635a39
--- /dev/null
+++ b/cmake/FindSlog2.cmake
@@ -0,0 +1,19 @@
+# Find the Slog2 library
+
+# Will make the target Slog2::Slog2 available when found.
+
+find_library(Slog2_LIBRARY NAMES "slog2")
+find_path(Slog2_INCLUDE_DIR NAMES "sys/slog2.h" DOC "The Slog2 Include path")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Slog2 DEFAULT_MSG Slog2_INCLUDE_DIR Slog2_LIBRARY)
+
+mark_as_advanced(Slog2_INCLUDE_DIR Slog2_LIBRARY)
+
+if(Slog2_FOUND)
+ add_library(__Slog2 INTERFACE IMPORTED)
+ target_link_libraries(__Slog2 INTERFACE ${Slog2_LIBRARY})
+ target_include_directories(__Slog2 INTERFACE ${Slog2_INCLUDE_DIR})
+
+ add_library(Slog2::Slog2 ALIAS __Slog2)
+endif()
diff --git a/cmake/FindTslib.cmake b/cmake/FindTslib.cmake
new file mode 100644
index 0000000000..3c50116d0a
--- /dev/null
+++ b/cmake/FindTslib.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Tslib tslib IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::Tslib)
+ set(Tslib_FOUND 0)
+endif()
diff --git a/cmake/FindWrapDBus1.cmake b/cmake/FindWrapDBus1.cmake
new file mode 100644
index 0000000000..c2668d6cc8
--- /dev/null
+++ b/cmake/FindWrapDBus1.cmake
@@ -0,0 +1,35 @@
+# DBus1 is buggy and breaks PKG_CONFIG environment.
+# Work around that:-/
+# See https://gitlab.freedesktop.org/dbus/dbus/issues/267 for more information
+
+if(DEFINED ENV{PKG_CONFIG_DIR})
+ set(__qt_dbus_pcd "$ENV{PKG_CONFIG_DIR}")
+endif()
+if(DEFINED ENV{PKG_CONFIG_PATH})
+ set(__qt_dbus_pcp "$ENV{PKG_CONFIG_PATH}")
+endif()
+if(DEFINED ENV{PKG_CONFIG_LIBDIR})
+ set(__qt_dbus_pcl "$ENV{PKG_CONFIG_LIBDIR}")
+endif()
+
+find_package(DBus1)
+
+if(DEFINED __qt_dbus_pcd)
+ set(ENV{PKG_CONFIG_DIR} "${__qt_dbus_pcd}")
+else()
+ unset(ENV{PKG_CONFIG_DIR})
+endif()
+if(DEFINED __qt_dbus_pcp)
+ set(ENV{PKG_CONFIG_PATH} "${__qt_dbus_pcp}")
+else()
+ unset(ENV{PKG_CONFIG_PATH})
+endif()
+if(DEFINED __qt_dbus_pcl)
+ set(ENV{PKG_CONFIG_LIBDIR} "${__qt_dbus_pcl}")
+else()
+ unset(ENV{PKG_CONFIG_LIBDIR})
+endif()
+
+if(DBus1_FOUND)
+ set(WrapDBus1_FOUND 1)
+endif()
diff --git a/cmake/FindWrapDoubleConversion.cmake b/cmake/FindWrapDoubleConversion.cmake
new file mode 100644
index 0000000000..9c804a3eec
--- /dev/null
+++ b/cmake/FindWrapDoubleConversion.cmake
@@ -0,0 +1,61 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapDoubleConversion::WrapDoubleConversion)
+ set(WrapDoubleConversion_FOUND ON)
+ return()
+endif()
+
+add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
+
+find_package(double-conversion)
+if (double-conversion_FOUND)
+ include(FeatureSummary)
+ set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
+ target_link_libraries(WrapDoubleConversion::WrapDoubleConversion
+ INTERFACE double-conversion::double-conversion)
+ set(WrapDoubleConversion_FOUND 1)
+ return()
+endif()
+
+include(CheckCXXSourceCompiles)
+
+check_cxx_source_compiles("
+#include <stdio.h>
+#include <locale.h>
+
+int main(int argc, char *argv[]) {
+ _locale_t invalidLocale = NULL;
+ double a = 3.14;
+ const char *format = \"invalid format\";
+ _sscanf_l(argv[0], invalidLocale, format, &a, &argc);
+ _snprintf_l(argv[0], 1, invalidLocale, format, a);
+}" HAVE__SPRINTF_L)
+
+check_cxx_source_compiles("
+#include <stdio.h>
+#include <xlocale.h>
+
+int main(int argc, char *argv[]) {
+ locale_t invalidLocale = NULL;
+ double a = 3.14;
+ const char *format = \"invalid format\";
+ snprintf_l(argv[0], 1, invalidLocale, format, a);
+ sscanf_l(argv[0], invalidLocale, format, &a, &argc);
+ return 0;
+}" HAVE_SPRINTF_L)
+
+# In a static build, we need to find the package to bring the target into scope.
+find_package(QtDoubleConversion QUIET)
+
+if (HAVE__SPRINTF_L OR HAVE_SPRINTF_L)
+ target_compile_definitions(WrapDoubleConversion::WrapDoubleConversion
+ INTERFACE QT_NO_DOUBLECONVERSION)
+ set(WrapDoubleConversion_FOUND 1)
+elseif(TARGET QtDoubleConversion)
+ # If a Config package wasn't found, and the C++ library doesn't contain the necessary functions,
+ # use the library bundled with Qt.
+ target_link_libraries(WrapDoubleConversion::WrapDoubleConversion INTERFACE QtDoubleConversion)
+ set(WrapDoubleConversion_FOUND 1)
+else()
+ set(WrapDoubleConversion_FOUND 0)
+endif()
diff --git a/cmake/FindWrapFreetype.cmake b/cmake/FindWrapFreetype.cmake
new file mode 100644
index 0000000000..ec7d2a8d24
--- /dev/null
+++ b/cmake/FindWrapFreetype.cmake
@@ -0,0 +1,33 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapFreetype::WrapFreetype)
+ set(WrapFreetype_FOUND ON)
+ return()
+endif()
+
+set(WrapFreetype_FOUND OFF)
+
+# Hunter has the package named freetype, but exports the Freetype::Freetype target as upstream
+# First try the CONFIG package, and afterwards the MODULE if not found
+
+find_package(Freetype CONFIG NAMES Freetype freetype QUIET)
+if(NOT Freetype_FOUND)
+ find_package(Freetype MODULE)
+endif()
+
+if(Freetype_FOUND)
+ # vcpkg defines a lower case target name, while upstream Find module defines a prefixed
+ # upper case name.
+ set(potential_target_names Freetype::Freetype freetype)
+ foreach(target_name ${potential_target_names})
+ if(TARGET ${target_name})
+ set(WrapFreetype_FOUND ON)
+ set(final_target_name ${target_name})
+
+ add_library(WrapFreetype::WrapFreetype INTERFACE IMPORTED)
+ target_link_libraries(WrapFreetype::WrapFreetype INTERFACE ${final_target_name})
+
+ break()
+ endif()
+ endforeach()
+endif()
diff --git a/cmake/FindWrapHarfbuzz.cmake b/cmake/FindWrapHarfbuzz.cmake
new file mode 100644
index 0000000000..f7845b28bd
--- /dev/null
+++ b/cmake/FindWrapHarfbuzz.cmake
@@ -0,0 +1,45 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapHarfbuzz::WrapHarfbuzz)
+ set(WrapHarfbuzz_FOUND ON)
+ return()
+endif()
+
+set(WrapHarfbuzz_FOUND OFF)
+
+find_package(harfbuzz)
+
+# Gentoo has some buggy version of a harfbuzz Config file. Check if include paths are valid.
+set(__harfbuzz_target_name "harfbuzz::harfbuzz")
+if(harfbuzz_FOUND AND TARGET "${__harfbuzz_target_name}")
+ get_property(__harfbuzz_include_paths TARGET "${__harfbuzz_target_name}"
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ foreach(__harfbuzz_include_dir ${__harfbuzz_include_paths})
+ if(NOT EXISTS "${__harfbuzz_include_dir}")
+ # Must be the broken Gentoo harfbuzzConfig.cmake file. Try to use pkg-config instead.
+ set(__harfbuzz_broken_config_file TRUE)
+ break()
+ endif()
+ endforeach()
+endif()
+
+if(__harfbuzz_broken_config_file)
+ find_package(PkgConfig)
+
+ pkg_check_modules(harfbuzz harfbuzz IMPORTED_TARGET)
+ set(__harfbuzz_target_name "PkgConfig::harfbuzz")
+
+ if (NOT TARGET "${__harfbuzz_target_name}")
+ set(harfbuzz_FOUND 0)
+ endif()
+endif()
+
+if(TARGET "${__harfbuzz_target_name}")
+ set(WrapHarfbuzz_FOUND ON)
+
+ add_library(WrapHarfbuzz::WrapHarfbuzz INTERFACE IMPORTED)
+ target_link_libraries(WrapHarfbuzz::WrapHarfbuzz INTERFACE ${__harfbuzz_target_name})
+endif()
+unset(__harfbuzz_target_name)
+unset(__harfbuzz_include_dir)
+unset(__harfbuzz_broken_config_file)
diff --git a/cmake/FindWrapPCRE2.cmake b/cmake/FindWrapPCRE2.cmake
new file mode 100644
index 0000000000..08f660bdfc
--- /dev/null
+++ b/cmake/FindWrapPCRE2.cmake
@@ -0,0 +1,23 @@
+if(TARGET WrapPCRE2::WrapPCRE2)
+ set(WrapPCRE2_FOUND TRUE)
+ return()
+endif()
+
+find_package(PCRE2 CONFIG QUIET)
+
+if(PCRE2_FOUND AND TARGET PCRE2::pcre2-16)
+ # Hunter case.
+ add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
+ target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE PCRE2::pcre2-16)
+ set(WrapPCRE2_FOUND TRUE)
+else()
+ find_library(PCRE2_LIBRARIES NAMES pcre2-16)
+ find_path(PCRE2_INCLUDE_DIRS pcre2.h)
+
+ if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
+ add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
+ target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_LIBRARIES})
+ target_include_directories(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
+ set(WrapPCRE2_FOUND TRUE)
+ endif()
+endif()
diff --git a/cmake/FindWrapRt.cmake b/cmake/FindWrapRt.cmake
new file mode 100644
index 0000000000..d14b922062
--- /dev/null
+++ b/cmake/FindWrapRt.cmake
@@ -0,0 +1,34 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapRt)
+ set(WrapRt_FOUND ON)
+ return()
+endif()
+
+include(CheckCXXSourceCompiles)
+include(CMakePushCheckState)
+
+find_library(LIBRT rt)
+
+cmake_push_check_state()
+if(LIBRT_FOUND)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}")
+endif()
+
+check_cxx_source_compiles("
+#include <unistd.h>
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ timespec ts; clock_gettime(CLOCK_REALTIME, &ts);
+}" HAVE_GETTIME)
+
+cmake_pop_check_state()
+
+add_library(WrapRt INTERFACE IMPORTED)
+if (LIBRT_FOUND)
+ target_link_libraries(WrapRt INTERFACE "${LIBRT}")
+endif()
+
+set(WrapRt_FOUND "${HAVE_GETTIME}")
+
diff --git a/cmake/FindXKB_COMMON_X11.cmake b/cmake/FindXKB_COMMON_X11.cmake
new file mode 100644
index 0000000000..61b4ba82e7
--- /dev/null
+++ b/cmake/FindXKB_COMMON_X11.cmake
@@ -0,0 +1,7 @@
+include(FindPkgConfig)
+
+pkg_check_modules(XKB_COMMON_X11 "xkbcommon-x11>=0.4.1" IMPORTED_TARGET)
+
+if (NOT TARGET PkgConfig::XKB_COMMON_X11)
+ set(XKB_COMMON_X11_FOUND 0)
+endif()
diff --git a/cmake/FindXRender.cmake b/cmake/FindXRender.cmake
new file mode 100644
index 0000000000..246a47e18c
--- /dev/null
+++ b/cmake/FindXRender.cmake
@@ -0,0 +1,11 @@
+include(FindPkgConfig)
+
+if(NOT TARGET PkgConfig::XRender)
+ pkg_check_modules(XRender xrender IMPORTED_TARGET)
+
+ if (NOT TARGET PkgConfig::XRender)
+ set(XRender_FOUND 0)
+ endif()
+else()
+ set(XRender_FOUND 1)
+endif()
diff --git a/cmake/FindZSTD.cmake b/cmake/FindZSTD.cmake
new file mode 100644
index 0000000000..90d667dc29
--- /dev/null
+++ b/cmake/FindZSTD.cmake
@@ -0,0 +1,50 @@
+#.rst:
+# FindZstd
+# ---------
+#
+# Try to locate the Zstd library.
+# If found, this will define the following variables:
+#
+# ``ZSTD_FOUND``
+# True if the zstd library is available
+# ``ZSTD_INCLUDE_DIRS``
+# The zstd include directories
+# ``ZSTD_LIBRARIES``
+# The zstd libraries for linking
+#
+# If ``ZSTD_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``ZSTD::ZSTD``
+# The zstd library
+
+find_package(PkgConfig)
+pkg_check_modules(PC_ZSTD QUIET libzstd)
+
+find_path(ZSTD_INCLUDE_DIRS
+ NAMES zstd.h
+ HINTS ${PC_ZSTD_INCLUDEDIR}
+ PATH_SUFFIXES zstd)
+
+find_library(ZSTD_LIBRARIES
+ NAMES zstd zstd_static
+ HINTS ${PC_ZSTD_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS)
+
+if(ZSTD_FOUND AND NOT TARGET ZSTD::ZSTD)
+ add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ IMPORTED_LOCATION "${ZSTD_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(ZSTD PROPERTIES
+ URL "https://github.com/facebook/zstd"
+ DESCRIPTION "ZSTD compression library")
+
diff --git a/cmake/Finddouble-conversion.cmake b/cmake/Finddouble-conversion.cmake
new file mode 100644
index 0000000000..43d2076289
--- /dev/null
+++ b/cmake/Finddouble-conversion.cmake
@@ -0,0 +1,32 @@
+# Fallback find module for double-conversion
+# if double-conversion is built with CMake it'll install a config module, which we prefer
+# if it's built with Scons (their default), we search ourselves
+
+find_package(double-conversion CONFIG)
+if (double-conversion_FOUND)
+ if(TARGET double-conversion::double-conversion)
+ return()
+ endif()
+endif()
+
+find_path(DOUBLE_CONVERSION_INCLUDE_DIR
+ NAMES
+ double-conversion.h
+ PATH_SUFFIXES
+ double-conversion
+)
+find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ double-conversion DEFAULT_MSG
+ DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR)
+
+if(double-conversion_FOUND AND NOT TARGET double-conversion::double-conversion)
+ add_library(double-conversion::double-conversion UNKNOWN IMPORTED)
+ set_target_properties(double-conversion::double-conversion PROPERTIES
+ IMPORTED_LOCATION "${DOUBLE_CONVERSION_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${DOUBLE_CONVERSION_INCLUDE_DIR}")
+endif()
+
+mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
diff --git a/cmake/ModuleDescription.json.in b/cmake/ModuleDescription.json.in
new file mode 100644
index 0000000000..e29f3f176d
--- /dev/null
+++ b/cmake/ModuleDescription.json.in
@@ -0,0 +1,11 @@
+{
+ "module_name": "${target}",
+ "version": "${CMAKE_PROJECT_VERSION}",
+ "built_with": {
+ "compiler_id": "${CMAKE_CXX_COMPILER_ID}",
+ "compiler_target": "${CMAKE_CXX_COMPILER_TARGET}",
+ "compiler_version": "${CMAKE_CXX_COMPILER_VERSION}",
+ "cross_compiled": ${cross_compilation},
+ "target_system": "${CMAKE_SYSTEM_NAME}"
+ }
+}
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
new file mode 100644
index 0000000000..95ace249ad
--- /dev/null
+++ b/cmake/QtAutoDetect.cmake
@@ -0,0 +1,179 @@
+#
+# Collection of auto dection routines to improve the user eperience when
+# building Qt from source.
+#
+# Make sure to not run detection when building standalone tests, because the detection was already
+# done when initially configuring qtbase.
+
+function(qt_auto_detect_android)
+ if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID
+ AND NOT QT_BUILD_STANDALONE_TESTS)
+
+ file(READ ${CMAKE_TOOLCHAIN_FILE} toolchain_file_content OFFSET 0 LIMIT 80)
+ string(FIND ${toolchain_file_content} "The Android Open Source Project" find_result REVERSE)
+ if (NOT ${find_result} EQUAL -1)
+ set(android_detected TRUE)
+ else()
+ set(android_detected FALSE)
+ endif()
+
+ if(android_detected)
+ message(STATUS "Android toolchain file detected, checking configuration defaults...")
+ if(NOT DEFINED ANDROID_NATIVE_API_LEVEL)
+ message(STATUS "ANDROID_NATIVE_API_LEVEL was not specified, using API level 21 as default")
+ set(ANDROID_NATIVE_API_LEVEL 21 CACHE STRING "")
+ endif()
+ if(NOT DEFINED ANDROID_STL)
+ set(ANDROID_STL "c++_shared" CACHE STRING "")
+ endif()
+ endif()
+ set(QT_AUTODETECT_ANDROID ${android_detected} CACHE STRING "")
+ elseif (QT_AUTODETECT_ANDROID)
+ message(STATUS "Android toolchain file detected")
+ endif()
+endfunction()
+
+function(qt_auto_detect_vpckg)
+ if(DEFINED ENV{VCPKG_ROOT} AND NOT QT_BUILD_STANDALONE_TESTS)
+ set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
+ get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE)
+
+ if(DEFINED CMAKE_TOOLCHAIN_FILE)
+ get_filename_component(supplied_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
+ if(NOT supplied_toolchain_file STREQUAL vcpkg_toolchain_file)
+ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" CACHE STRING "")
+ endif()
+ unset(supplied_toolchain_file)
+ endif()
+ set(CMAKE_TOOLCHAIN_FILE "${vcpkg_toolchain_file}" CACHE STRING "" FORCE)
+ message(STATUS "Using vcpkg from $ENV{VCPKG_ROOT}")
+ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
+ set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
+ message(STATUS "Using vcpkg triplet ${VCPKG_TARGET_TRIPLET}")
+ endif()
+ unset(vcpkg_toolchain_file)
+ message(STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}")
+ if(DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ message(STATUS "VCPKG_CHAINLOAD_TOOLCHAIN_FILE is: ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
+ endif()
+ endif()
+endfunction()
+
+function(qt_auto_detect_ios)
+ if(CMAKE_SYSTEM_NAME STREQUAL iOS
+ OR CMAKE_SYSTEM_NAME STREQUAL watchOS
+ OR CMAKE_SYSTEM_NAME STREQUAL tvOS)
+ message(STATUS "Using internal CMake ${CMAKE_SYSTEM_NAME} toolchain file.")
+
+ # The QT_UIKIT_SDK check simulates the input.sdk condition for simulator_and_device in
+ # configure.json.
+ # If the variable is explicitly provided, assume simulator_and_device to be off.
+ if(QT_UIKIT_SDK)
+ set(simulator_and_device OFF)
+ elseif(QT_FORCE_SIMULATOR_AND_DEVICE)
+ # TODO: Once we get simulator_and_device support in upstream CMake, only then allow
+ # usage of simulator_and_device without forcing.
+ set(simulator_and_device ON)
+ else()
+ # If QT_UIKIT_SDK is not provided, default to simulator.
+ set(simulator_and_device OFF)
+ set(QT_UIKIT_SDK "iphonesimulator" CACHE "STRING" "Chosen uikit SDK.")
+ endif()
+
+ message(STATUS "simulator_and_device set to: \"${simulator_and_device}\".")
+
+ # Choose relevant architectures.
+ # Using a non xcode generator requires explicit setting of the
+ # architectures, otherwise compilation fails with unknown defines.
+ if(CMAKE_SYSTEM_NAME STREQUAL iOS)
+ if(simulator_and_device)
+ set(osx_architectures "arm64;x86_64")
+ elseif(QT_UIKIT_SDK STREQUAL "iphoneos")
+ set(osx_architectures "arm64")
+ elseif(QT_UIKIT_SDK STREQUAL "iphonesimulator")
+ set(osx_architectures "x86_64")
+ else()
+ if(NOT DEFINED QT_UIKIT_SDK)
+ message(FATAL_ERROR "Please proviude a value for -DQT_UIKIT_SDK."
+ " Possible values: iphoneos, iphonesimulator.")
+ else()
+ message(FATAL_ERROR
+ "Unknown SDK argument given to QT_UIKIT_SDK: ${QT_UIKIT_SDK}.")
+ endif()
+ endif()
+ elseif(CMAKE_SYSTEM_NAME STREQUAL tvOS)
+ if(simulator_and_device)
+ set(osx_architectures "arm64;x86_64")
+ elseif(QT_UIKIT_SDK STREQUAL "appletvos")
+ set(osx_architectures "arm64")
+ elseif(QT_UIKIT_SDK STREQUAL "appletvsimulator")
+ set(osx_architectures "x86_64")
+ else()
+ if(NOT DEFINED QT_UIKIT_SDK)
+ message(FATAL_ERROR "Please proviude a value for -DQT_UIKIT_SDK."
+ " Possible values: appletvos, appletvsimulator.")
+ else()
+ message(FATAL_ERROR
+ "Unknown SDK argument given to QT_UIKIT_SDK: ${QT_UIKIT_SDK}.")
+ endif()
+ endif()
+ elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS)
+ if(simulator_and_device)
+ set(osx_architectures "armv7k;i386")
+ elseif(QT_UIKIT_SDK STREQUAL "watchos")
+ set(osx_architectures "armv7k")
+ elseif(QT_UIKIT_SDK STREQUAL "watchsimulator")
+ set(osx_architectures "i386")
+ else()
+ if(NOT DEFINED QT_UIKIT_SDK)
+ message(FATAL_ERROR "Please proviude a value for -DQT_UIKIT_SDK."
+ " Possible values: watchos, watchsimulator.")
+ else()
+ message(FATAL_ERROR
+ "Unknown SDK argument given to QT_UIKIT_SDK: ${QT_UIKIT_SDK}.")
+ endif()
+ endif()
+ endif()
+
+ # For non simulator_and_device builds, we need to explicitly set the SYSROOT aka the sdk
+ # value.
+ if(QT_UIKIT_SDK)
+ set(CMAKE_OSX_SYSROOT "${QT_UIKIT_SDK}" CACHE STRING "")
+ endif()
+ message(STATUS "CMAKE_OSX_SYSROOT set to: \"${CMAKE_OSX_SYSROOT}\".")
+
+ message(STATUS "CMAKE_OSX_ARCHITECTURES set to: \"${osx_architectures}\".")
+ set(CMAKE_OSX_ARCHITECTURES "${osx_architectures}" CACHE STRING "")
+
+ if(NOT DEFINED BUILD_SHARED_LIBS)
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Qt statically or dynamically" FORCE)
+ endif()
+
+ if(BUILD_SHARED_LIBS)
+ message(FATAL_ERROR
+ "Building Qt for ${CMAKE_SYSTEM_NAME} as shared libraries is not supported.")
+ endif()
+ endif()
+endfunction()
+
+function(qt_auto_detect_cmake_config)
+ if(CMAKE_CONFIGURATION_TYPES)
+ # Allow users to specify this option.
+ if(NOT QT_MULTI_CONFIG_FIRST_CONFIG)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 first_config_type)
+ set(QT_MULTI_CONFIG_FIRST_CONFIG "${first_config_type}")
+ set(QT_MULTI_CONFIG_FIRST_CONFIG "${first_config_type}" PARENT_SCOPE)
+ endif()
+
+ set(CMAKE_TRY_COMPILE_CONFIGURATION "${QT_MULTI_CONFIG_FIRST_CONFIG}" PARENT_SCOPE)
+ if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
+ set(CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE ON PARENT_SCOPE)
+ set(CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE "${QT_MULTI_CONFIG_FIRST_CONFIG}" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction()
+
+qt_auto_detect_cmake_config()
+qt_auto_detect_ios()
+qt_auto_detect_android()
+qt_auto_detect_vpckg()
diff --git a/cmake/QtBaseCMakeTesting.cmake b/cmake/QtBaseCMakeTesting.cmake
new file mode 100644
index 0000000000..662ac8f498
--- /dev/null
+++ b/cmake/QtBaseCMakeTesting.cmake
@@ -0,0 +1,9 @@
+## Test the cmake build system:
+option(BUILD_CMAKE_TESTING "Build tests for the Qt build system" OFF)
+mark_as_advanced(BUILD_CMAKE_TESTING)
+
+if(BUILD_CMAKE_TESTING)
+ add_subdirectory("${PROJECT_SOURCE_DIR}/cmake/tests")
+endif()
+
+
diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake
new file mode 100644
index 0000000000..0d6bb1407b
--- /dev/null
+++ b/cmake/QtBaseConfigureTests.cmake
@@ -0,0 +1,198 @@
+include(CheckCXXSourceCompiles)
+
+function(qt_run_config_test_architecture)
+ set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT
+ "" CACHE INTERNAL "Test variables that should be exported" FORCE)
+
+ # Compile test to find the target architecture and sub-architectures.
+ set(flags "")
+ qt_get_platform_try_compile_vars(platform_try_compile_vars)
+ list(APPEND flags ${platform_try_compile_vars})
+
+ try_compile(
+ _arch_result
+ "${CMAKE_CURRENT_BINARY_DIR}/config.tests/arch"
+ "${CMAKE_CURRENT_SOURCE_DIR}/config.tests/arch"
+ arch
+ CMAKE_FLAGS ${flags}
+ )
+
+ if (NOT _arch_result)
+ message(FATAL_ERROR "Failed to compile architecture detection file.")
+ endif()
+
+ set(_arch_file_suffix "${CMAKE_EXECUTABLE_SUFFIX}")
+ # With emscripten the application entry point is a .js file (to be run with node for example),
+ # but the real "data" is in the .wasm file, so that's where we need to look for the ABI, etc.
+ # information.
+ if (EMSCRIPTEN)
+ set(_arch_file_suffix ".wasm")
+ endif()
+
+ set(arch_test_location "config.tests/arch")
+ if(QT_MULTI_CONFIG_FIRST_CONFIG)
+ string(APPEND arch_test_location "/${QT_MULTI_CONFIG_FIRST_CONFIG}")
+ endif()
+
+ set(_arch_file
+ "${CMAKE_CURRENT_BINARY_DIR}/${arch_test_location}/architecture_test${_arch_file_suffix}")
+ if (NOT EXISTS "${_arch_file}")
+ message(FATAL_ERROR
+ "Failed to find compiled architecture detection executable at ${_arch_file}.")
+ endif()
+ message(STATUS "Extracting architecture info from ${_arch_file}.")
+
+ file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8)
+
+ foreach (_line ${_arch_lines})
+ string(LENGTH "${_line}" lineLength)
+ string(FIND "${_line}" "==Qt=magic=Qt== Architecture:" _pos)
+ if (_pos GREATER -1)
+ math(EXPR _pos "${_pos}+29")
+ string(SUBSTRING "${_line}" ${_pos} -1 _architecture)
+ endif()
+ string(FIND "${_line}" "==Qt=magic=Qt== Sub-architecture:" _pos)
+ if (_pos GREATER -1 AND ${lineLength} GREATER 33)
+ math(EXPR _pos "${_pos}+34")
+ string(SUBSTRING "${_line}" ${_pos} -1 _sub_architecture)
+ string(REPLACE " " ";" _sub_architecture "${_sub_architecture}")
+ endif()
+ string(FIND "${_line}" "==Qt=magic=Qt== Build-ABI:" _pos)
+ if (_pos GREATER -1)
+ math(EXPR _pos "${_pos}+26")
+ string(SUBSTRING "${_line}" ${_pos} -1 _build_abi)
+ endif()
+ endforeach()
+
+ if (NOT _architecture OR NOT _build_abi)
+ message(FATAL_ERROR "Failed to extract architecture data from file.")
+ endif()
+
+ set(TEST_architecture 1 CACHE INTERNAL "Ran the architecture test")
+ set(TEST_architecture_arch "${_architecture}" CACHE INTERNAL "Target machine architecture")
+ list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_architecture_arch)
+ set(TEST_subarch 1 CACHE INTERNAL "Ran machine subArchitecture test")
+ foreach(it ${_sub_architecture})
+ # Equivalent to qmake's QT_CPU_FEATURES.$arch.
+ set(TEST_arch_${TEST_architecture_arch}_subarch_${it} 1 CACHE INTERNAL "Target sub architecture result")
+ list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_arch_${TEST_architecture_arch}_subarch_${it})
+ endforeach()
+ set(TEST_buildAbi "${_build_abi}" CACHE INTERNAL "Target machine buildAbi")
+ list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_buildAbi)
+ set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
+
+ list(JOIN _sub_architecture " " subarch_summary)
+ message(STATUS "Building for: ${QT_QMAKE_TARGET_MKSPEC} (${TEST_architecture_arch}, CPU features: ${subarch_summary})")
+endfunction()
+
+
+function(qt_run_config_test_posix_iconv)
+ set(source "#include <iconv.h>
+
+int main(int, char **)
+{
+ iconv_t x = iconv_open(\"\", \"\");
+
+ char *inp;
+ char *outp;
+ size_t inbytes, outbytes;
+ iconv(x, &inp, &inbytes, &outp, &outbytes);
+
+ iconv_close(x);
+
+ return 0;
+}")
+ check_cxx_source_compiles("${source}" HAVE_POSIX_ICONV)
+
+ if(NOT HAVE_POSIX_ICONV)
+ set(_req_libraries "${CMAKE_REQUIRE_LIBRARIES}")
+ set(CMAKE_REQUIRE_LIBRARIES "iconv")
+ check_cxx_source_compiles("${source}" HAVE_POSIX_ICONV)
+ set(CMAKE_REQUIRE_LIBRARIES "${_req_libraries}")
+ if(HAVE_POSIX_ICONV)
+ set(TEST_iconv_needlib 1 CACHE INTERNAL "Need to link against libiconv")
+ endif()
+ endif()
+
+ set(TEST_posix_iconv "${HAVE_POSIX_ICONV}" CACHE INTERNAL "POSIX iconv")
+endfunction()
+
+
+function(qt_run_config_test_sun_iconv)
+ set(source "#include <iconv.h>
+
+int main(int, char **)
+{
+ iconv_t x = iconv_open(\"\", \"\");
+
+ const char *inp;
+ char *outp;
+ size_t inbytes, outbytes;
+ iconv(x, &inp, &inbytes, &outp, &outbytes);
+
+ iconv_close(x);
+
+ return 0;
+}")
+ if(DARWIN)
+ # as per !config.darwin in configure.json
+ set(HAVE_SUN_ICONV OFF)
+ else()
+ check_cxx_source_compiles("${source}" HAVE_SUN_ICONV)
+ endif()
+
+ set(TEST_sun_iconv "${HAVE_SUN_ICONV}" CACHE INTERNAL "SUN libiconv")
+endfunction()
+
+function(qt_run_linker_version_script_support)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; };
+VERS_2 { global: sym; }
+VERS_1;
+")
+ if(DEFINED CMAKE_REQUIRED_FLAGS)
+ set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
+ else()
+ set(CMAKE_REQUIRED_FLAGS "")
+ endif()
+ set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
+ check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
+ if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE)
+ set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
+ endif()
+ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
+
+ # For some reason the linker command line written by the XCode generator, which is
+ # subsequently executed by xcodebuild, ignores the linker flag, and thus the test
+ # seemingly succeeds. Explicitly disable the version script test on darwin platforms.
+ if(APPLE)
+ set(HAVE_LD_VERSION_SCRIPT OFF)
+ endif()
+
+ set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support")
+endfunction()
+
+function(qt_run_qtbase_config_tests)
+ qt_run_config_test_posix_iconv()
+
+ add_library(Iconv INTERFACE)
+ if(TEST_iconv_needlib)
+ target_link_libraries(Iconv PUBLIC iconv)
+ endif()
+
+ if(NOT TEST_posix_iconv)
+ qt_run_config_test_sun_iconv()
+ endif()
+ qt_run_config_test_architecture()
+ qt_run_linker_version_script_support()
+endfunction()
+
+# The qmake build of android does not perform the right architecture tests and
+# forcefully disables sse4 on android x86. We have to mimic this behavior
+# for now
+if (CMAKE_ANDROID_ARCH_ABI STREQUAL x86)
+ set(QT_FEATURE_sse4_1 OFF CACHE BOOL INTERNAL FORCE)
+ set(QT_FEATURE_sse4_2 OFF CACHE BOOL INTERNAL FORCE)
+ set(TEST_subarch_sse4_1 FALSE CACHE BOOL INTERNAL FORCE)
+ set(TEST_subarch_sse4_2 FALSE CACHE BOOL INTERNAL FORCE)
+endif()
+qt_run_qtbase_config_tests()
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
new file mode 100644
index 0000000000..a8189dad5f
--- /dev/null
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -0,0 +1,287 @@
+## QtPlatform Target:
+add_library(Platform INTERFACE)
+add_library(Qt::Platform ALIAS Platform)
+target_include_directories(Platform
+ INTERFACE
+ $<BUILD_INTERFACE:${QT_PLATFORM_DEFINITION_DIR_ABSOLUTE}>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ $<INSTALL_INTERFACE:${QT_PLATFORM_DEFINITION_DIR}>
+ $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
+ )
+target_compile_definitions(Platform INTERFACE ${QT_PLATFORM_DEFINITIONS})
+
+# When building on android we need to link against the logging library
+# in order to satisfy linker dependencies. Both of these libraries are part of
+# the NDK.
+if (ANDROID)
+ target_link_libraries(Platform INTERFACE log)
+endif()
+
+set(__GlobalConfig_path_suffix "${INSTALL_CMAKE_NAMESPACE}")
+qt_path_join(__GlobalConfig_build_dir ${QT_CONFIG_BUILD_DIR} ${__GlobalConfig_path_suffix})
+qt_path_join(__GlobalConfig_install_dir ${QT_CONFIG_INSTALL_DIR} ${__GlobalConfig_path_suffix})
+set(__GlobalConfig_install_dir_absolute "${__GlobalConfig_install_dir}")
+if(QT_WILL_INSTALL)
+ # Need to prepend the install prefix when doing prefix builds, because the config install dir
+ # is relative then.
+ qt_path_join(__GlobalConfig_install_dir_absolute
+ ${CMAKE_INSTALL_PREFIX} ${__GlobalConfig_install_dir_absolute})
+endif()
+
+# Generate and install Qt6 config file.
+configure_package_config_file(
+ "${PROJECT_SOURCE_DIR}/cmake/QtConfig.cmake.in"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
+ INSTALL_DESTINATION "${__GlobalConfig_install_dir}"
+)
+
+write_basic_package_version_file(
+ ${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+# Generate and install Qt6Tools config file.
+configure_package_config_file(
+ "${PROJECT_SOURCE_DIR}/cmake/QtToolsConfig.cmake.in"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
+ INSTALL_DESTINATION "${__GlobalConfig_install_dir}"
+)
+write_basic_package_version_file(
+ ${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+qt_install(FILES
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake"
+ DESTINATION "${__GlobalConfig_install_dir}"
+ COMPONENT Devel
+)
+
+qt_install(FILES
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake"
+ DESTINATION "${__GlobalConfig_install_dir}Tools"
+ COMPONENT Devel
+)
+
+# Generate toolchain file for convenience
+if(QT_HOST_PATH)
+ get_filename_component(init_qt_host_path "${QT_HOST_PATH}" ABSOLUTE)
+ set(init_qt_host_path "set(QT_HOST_PATH \"${init_qt_host_path}\" CACHE PATH \"\" FORCE)")
+endif()
+
+if(CMAKE_TOOLCHAIN_FILE)
+ set(init_original_toolchain_file "set(qt_chainload_toolchain_file \"${CMAKE_TOOLCHAIN_FILE}\")")
+endif()
+
+if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ list(APPEND init_vcpkg "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}\")")
+endif()
+
+if(VCPKG_TARGET_TRIPLET)
+ list(APPEND init_vcpkg "set(VCPKG_TARGET_TRIPLET \"${VCPKG_TARGET_TRIPLET}\" CACHE STRING \"\")")
+endif()
+
+# On Windows compilers aren't easily mixed. Avoid that qtbase is built using cl.exe for example and then for another
+# build gcc is picked up from %PATH%. The same goes when using a custom compiler on other platforms, such as ICC.
+list(APPEND init_platform "set(CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\" CACHE STRING \"\")")
+list(APPEND init_platform "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\" CACHE STRING \"\")")
+
+if(APPLE)
+ # For simulator_and_device build, we should not explicitly set the sysroot.
+ list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count)
+ if(CMAKE_OSX_SYSROOT AND NOT _qt_osx_architectures_count GREATER 1 AND APPLE_UIKIT)
+ list(APPEND init_platform "set(CMAKE_OSX_SYSROOT \"${CMAKE_OSX_SYSROOT}\" CACHE PATH \"\")")
+ endif()
+ unset(_qt_osx_architectures_count)
+
+ if(CMAKE_OSX_DEPLOYMENT_TARGET)
+ list(APPEND init_platform
+ "set(CMAKE_OSX_DEPLOYMENT_TARGET \"${CMAKE_OSX_DEPLOYMENT_TARGET}\" CACHE STRING \"\")")
+ endif()
+
+ if(APPLE_UIKIT)
+ list(APPEND init_platform
+ "set(CMAKE_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\" CACHE STRING \"\")")
+ set(_qt_osx_architectures_escaped "${CMAKE_OSX_ARCHITECTURES}")
+ string(REPLACE ";" "LITERAL_SEMICOLON"
+ _qt_osx_architectures_escaped "${_qt_osx_architectures_escaped}")
+ list(APPEND init_platform
+ "set(CMAKE_OSX_ARCHITECTURES \"${_qt_osx_architectures_escaped}\" CACHE STRING \"\")")
+ unset(_qt_osx_architectures_escaped)
+ endif()
+elseif(ANDROID)
+ list(APPEND init_platform "set(ANDROID_NATIVE_API_LEVEL \"${ANDROID_NATIVE_API_LEVEL}\" CACHE STRING \"\")")
+ list(APPEND init_platform "set(ANDROID_STL \"${ANDROID_STL}\" CACHE STRING \"\")")
+ list(APPEND init_platform "set(ANDROID_ABI \"${ANDROID_ABI}\" CACHE STRING \"\")")
+ list(APPEND init_platform "if (NOT DEFINED ANDROID_SDK_ROOT)")
+ list(APPEND init_platform " set(ANDROID_SDK_ROOT \"${ANDROID_SDK_ROOT}\" CACHE STRING \"\")")
+ list(APPEND init_platform "endif()")
+endif()
+
+string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}")
+string(REPLACE ";" "\n" init_platform "${init_platform}")
+string(REPLACE "LITERAL_SEMICOLON" ";" init_platform "${init_platform}")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt.toolchain.cmake.in" "${__GlobalConfig_build_dir}/qt.toolchain.cmake" @ONLY)
+qt_install(FILES "${__GlobalConfig_build_dir}/qt.toolchain.cmake" DESTINATION "${__GlobalConfig_install_dir}" COMPONENT Devel)
+
+# Also provide a convenience cmake wrapper
+if(UNIX)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.in" "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake" @ONLY)
+ qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake" DESTINATION "${INSTALL_BINDIR}")
+else()
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.bat.in" "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake.bat" @ONLY)
+ qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake.bat" DESTINATION "${INSTALL_BINDIR}")
+endif()
+
+# Provide a private convenience wrapper with options which should not be propagated via the public
+# qt-cmake wrapper e.g. CMAKE_GENERATOR.
+# These options can not be set in a toolchain file, but only on the command line.
+# These options should not be in the public wrapper, because a consumer of Qt might want to build
+# their CMake app with the Unix Makefiles generator, while Qt should be built with the Ninja
+# generator.
+# The private wrapper is more conveient for building Qt itself, because a developer doesn't need
+# to specify the same options for each qt module built.
+set(__qt_cmake_extra "-G\"${CMAKE_GENERATOR}\"")
+if(UNIX)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.in"
+ "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-private" @ONLY)
+qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-private" DESTINATION "${INSTALL_BINDIR}")
+else()
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.bat.in"
+ "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-private.bat" @ONLY)
+qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-private.bat" DESTINATION "${INSTALL_BINDIR}")
+endif()
+unset(__qt_cmake_extra)
+
+## Library to hold global features:
+## These features are stored and accessed via Qt::GlobalConfig, but the
+## files always lived in Qt::Core, so we keep it that way
+add_library(GlobalConfig INTERFACE)
+target_include_directories(GlobalConfig INTERFACE
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore>
+ $<INSTALL_INTERFACE:include>
+ $<INSTALL_INTERFACE:include/QtCore>
+)
+qt_feature_module_begin(NO_MODULE
+ PUBLIC_FILE src/corelib/global/qconfig.h
+ PRIVATE_FILE src/corelib/global/qconfig_p.h
+)
+include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
+
+# Do what mkspecs/features/uikit/default_pre.prf does, aka enable sse2 for
+# simulator_and_device_builds.
+if(APPLE_UIKIT AND NOT QT_UIKIT_SDK)
+ set(__QtFeature_custom_enabled_cache_variables
+ TEST_subarch_sse2
+ FEATURE_sse2
+ QT_FEATURE_sse2)
+endif()
+
+qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_")
+
+qt_generate_global_config_pri_file()
+
+add_library(Qt::GlobalConfig ALIAS GlobalConfig)
+
+add_library(GlobalConfigPrivate INTERFACE)
+target_link_libraries(GlobalConfigPrivate INTERFACE GlobalConfig)
+target_include_directories(GlobalConfigPrivate INTERFACE
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}/QtCore>
+ $<INSTALL_INTERFACE:include/QtCore/${PROJECT_VERSION}>
+ $<INSTALL_INTERFACE:include/QtCore/${PROJECT_VERSION}/QtCore>
+)
+add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
+
+# defines PlatformCommonInternal PlatformModuleInternal PlatformPluginInternal PlatformToolInternal
+include(QtInternalTargets)
+
+set(__export_targets Platform
+ GlobalConfig
+ GlobalConfigPrivate
+ PlatformCommonInternal
+ PlatformModuleInternal
+ PlatformPluginInternal
+ PlatformToolInternal)
+set(__export_name "${INSTALL_CMAKE_NAMESPACE}Targets")
+qt_install(TARGETS ${__export_targets} EXPORT "${__export_name}")
+qt_install(EXPORT ${__export_name}
+ NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
+ DESTINATION "${__GlobalConfig_install_dir}")
+
+qt_internal_export_modern_cmake_config_targets_file(TARGETS ${__export_targets}
+ EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}
+ CONFIG_INSTALL_DIR
+ ${__GlobalConfig_install_dir})
+
+## Install some QtBase specific CMake files:
+qt_copy_or_install(FILES
+ cmake/ModuleDescription.json.in
+ cmake/QtBuild.cmake
+ cmake/QtBuildInformation.cmake
+ cmake/QtCompilerFlags.cmake
+ cmake/QtCompilerOptimization.cmake
+ cmake/QtFeature.cmake
+ cmake/QtPlatformSupport.cmake
+ cmake/QtPlatformAndroid.cmake
+ cmake/QtPostProcess.cmake
+ cmake/QtSetup.cmake
+ cmake/QtModuleConfig.cmake.in
+ cmake/QtModuleDependencies.cmake.in
+ cmake/QtModuleToolsDependencies.cmake.in
+ cmake/QtModuleToolsConfig.cmake.in
+ cmake/QtModuleToolsVersionlessTargets.cmake.in
+ cmake/QtStandaloneTestsConfig.cmake.in
+ cmake/QtPlugins.cmake.in
+ cmake/QtPluginConfig.cmake.in
+ cmake/QtPluginDependencies.cmake.in
+ DESTINATION "${__GlobalConfig_install_dir}"
+)
+
+file(COPY cmake/QtFeature.cmake DESTINATION "${__GlobalConfig_build_dir}")
+
+# TODO: Check whether this is the right place to install these
+qt_copy_or_install(DIRECTORY cmake/3rdparty DESTINATION "${__GlobalConfig_install_dir}")
+
+# Install our custom Find modules, which will be used by the find_dependency() calls
+# inside the generated ModuleDependencies cmake files.
+qt_copy_or_install(DIRECTORY cmake/
+ DESTINATION "${__GlobalConfig_install_dir}"
+ FILES_MATCHING PATTERN "Find*.cmake"
+ PATTERN "tests" EXCLUDE
+ PATTERN "3rdparty" EXCLUDE
+)
+
+# Configure and install the QtBuildInternals package.
+set(__build_internals_path_suffix "${INSTALL_CMAKE_NAMESPACE}BuildInternals")
+qt_path_join(__build_internals_build_dir ${QT_CONFIG_BUILD_DIR} ${__build_internals_path_suffix})
+qt_path_join(__build_internals_install_dir ${QT_CONFIG_INSTALL_DIR}
+ ${__build_internals_path_suffix})
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake"
+ "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
+ @ONLY
+ )
+
+qt_install(FILES
+ "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
+ "${__build_internals_build_dir}/QtBuildInternalsExtra.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake"
+ DESTINATION "${__build_internals_install_dir}"
+ COMPONENT Devel
+)
+
+# Generate the new resource API
+set(QT_CORE_RESOURCE_GENERATED_FILE_NAME "${INSTALL_CMAKE_NAMESPACE}CoreResource.cmake" CACHE INTERNAL "")
+set(QT_CORE_RESOURCE_GENERATED_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${QT_CORE_RESOURCE_GENERATED_FILE_NAME}" CACHE INTERNAL "")
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtResource.cmake.in"
+ "${QT_CORE_RESOURCE_GENERATED_FILE_PATH}"
+ @ONLY
+)
+include(${QT_CORE_RESOURCE_GENERATED_FILE_PATH})
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
new file mode 100644
index 0000000000..e23d0e93d1
--- /dev/null
+++ b/cmake/QtBuild.cmake
@@ -0,0 +1,4056 @@
+include(CMakePackageConfigHelpers)
+
+# Install locations:
+set(INSTALL_BINDIR "bin" CACHE STRING "Executables [PREFIX/bin]")
+set(INSTALL_INCLUDEDIR "include" CACHE STRING "Header files [PREFIX/include]")
+set(INSTALL_LIBDIR "lib" CACHE STRING "Libraries [PREFIX/lib]")
+set(INSTALL_MKSPECSDIR "mkspecs" CACHE STRING "Mkspecs files [PREFIX/mkspecs]")
+set(INSTALL_ARCHDATADIR "." CACHE STRING "Arch-dependent data [PREFIX]")
+set(INSTALL_PLUGINSDIR "${INSTALL_ARCHDATADIR}/plugins" CACHE STRING
+ "Plugins [ARCHDATADIR/plugins]")
+
+set(INSTALL_TARGETS_DEFAULT_ARGS
+ RUNTIME DESTINATION "${INSTALL_BINDIR}"
+ LIBRARY DESTINATION "${INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${INSTALL_LIBDIR}" COMPONENT Devel
+ INCLUDES DESTINATION "${INSTALL_INCLUDEDIR}"
+)
+
+if (WIN32)
+ set(_default_libexec "${INSTALL_ARCHDATADIR}/bin")
+else()
+ set(_default_libexec "${INSTALL_ARCHDATADIR}/libexec")
+endif()
+
+set(INSTALL_LIBEXECDIR "${_default_libexec}" CACHE STRING
+ "Helper programs [ARCHDATADIR/bin on Windows, ARCHDATADIR/libexec otherwise]")
+set(INSTALL_QMLDIR "${INSTALL_ARCHDATADIR}/qml" CACHE STRING
+ "QML2 imports [ARCHDATADIR/qml]")
+set(INSTALL_DATADIR "." CACHE STRING "Arch-independent data [PREFIX]")
+set(INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" CACHE STRING "Documentation [DATADIR/doc]")
+set(INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations" CACHE STRING
+ "Translations [DATADIR/translations]")
+set(INSTALL_SYSCONFDIR "etc/xdg" CACHE STRING
+ "Settings used by Qt programs [PREFIX/etc/xdg]")
+set(INSTALL_EXAMPLESDIR "examples" CACHE STRING "Examples [PREFIX/examples]")
+set(INSTALL_TESTSDIR "tests" CACHE STRING "Tests [PREFIX/tests]")
+set(INSTALL_DESCRIPTIONSDIR "${INSTALL_DATADIR}/modules" CACHE STRING
+ "Module description files directory")
+
+# The variables might have already been set in QtBuildInternalsExtra.cmake if the file is included
+# while building a new module and not QtBase. In that case, stop overriding the value.
+if(NOT INSTALL_CMAKE_NAMESPACE)
+ set(INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
+ CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]")
+endif()
+if(NOT QT_CMAKE_EXPORT_NAMESPACE)
+ set(QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
+ CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]")
+endif()
+
+set(QT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
+
+# Find the path to mkspecs/, depending on whether we are building as part of a standard qtbuild,
+# or a module against an already installed version of qt.
+if(NOT QT_MKSPECS_DIR)
+ if("${QT_BUILD_INTERNALS_PATH}" STREQUAL "")
+ get_filename_component(QT_MKSPECS_DIR "${CMAKE_CURRENT_LIST_DIR}/../mkspecs" ABSOLUTE)
+ else()
+ # We can rely on CMAKE_INSTALL_PREFIX being set by QtBuildInternalsExtra.cmake
+ get_filename_component(QT_MKSPECS_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_MKSPECSDIR}" ABSOLUTE)
+ endif()
+ set(QT_MKSPECS_DIR "${QT_MKSPECS_DIR}" CACHE INTERNAL "")
+endif()
+
+# the default RPATH to be used when installing, but only if it's not a system directory
+LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
+IF("${isSystemDir}" STREQUAL "-1")
+ SET(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
+ENDIF("${isSystemDir}" STREQUAL "-1")
+
+# Default rpath settings: Use rpath for build tree as well as a full path for the installed binaries.
+# For origin builds, one needs to override CMAKE_INSTALL_RPATH for example with $ORIGIN/../lib
+SET(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for installed binaries")
+
+# add the automatically determined parts of the RPATH
+# which point to directories outside the build tree to the install RPATH
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+# Generate a module description file based on the template in ModuleDescription.json.in
+function(qt_describe_module target)
+ set(path_suffix "${INSTALL_DESCRIPTIONSDIR}")
+ qt_path_join(build_dir ${QT_BUILD_DIR} ${path_suffix})
+ qt_path_join(install_dir ${QT_INSTALL_DIR} ${path_suffix})
+
+ set(descfile_in "${QT_CMAKE_DIR}/ModuleDescription.json.in")
+ set(descfile_out "${build_dir}/${target}.json")
+ set(cross_compilation "false")
+ if(CMAKE_CROSSCOMPILE)
+ set(cross_compilation "true")
+ endif()
+ configure_file("${descfile_in}" "${descfile_out}")
+
+ qt_install(FILES "${descfile_out}" DESTINATION "${install_dir}")
+endfunction()
+
+function(qt_setup_tool_path_command)
+ if(NOT WIN32)
+ return()
+ endif()
+ set(bindir "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
+ file(TO_NATIVE_PATH "${bindir}" bindir)
+ list(APPEND command COMMAND)
+ list(APPEND command set PATH=${bindir}$<SEMICOLON>%PATH%)
+ set(QT_TOOL_PATH_SETUP_COMMAND "${command}" CACHE INTERNAL "internal command prefix for tool invocations" FORCE)
+endfunction()
+qt_setup_tool_path_command()
+
+# Platform define path, etc.
+set(QT_QMAKE_TARGET_MKSPEC "")
+if(WIN32)
+ set(QT_DEFAULT_PLATFORM_DEFINITIONS UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS WIN64 _WIN64)
+ endif()
+ if(MSVC)
+ set(QT_QMAKE_TARGET_MKSPEC win32-msvc)
+ elseif(CLANG AND MINGW)
+ set(QT_QMAKE_TARGET_MKSPEC win32-clang-g++)
+ elseif(MINGW)
+ set(QT_QMAKE_TARGET_MKSPEC win32-g++)
+ endif()
+
+ if (MINGW)
+ list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601)
+ endif()
+elseif(LINUX)
+ if(GCC)
+ set(QT_QMAKE_TARGET_MKSPEC linux-g++)
+ elseif(CLANG)
+ set(QT_QMAKE_TARGET_MKSPEC linux-clang)
+ elseif(ICC)
+ set(QT_QMAKE_TARGET_MKSPEC linux-icc-64)
+ endif()
+elseif(ANDROID)
+ if(GCC)
+ set(QT_QMAKE_TARGET_MKSPEC android-g++)
+ elseif(CLANG)
+ set(QT_QMAKE_TARGET_MKSPEC android-clang)
+ endif()
+elseif(APPLE)
+ set(QT_QMAKE_TARGET_MKSPEC macx-clang)
+elseif(EMSCRIPTEN)
+ set(QT_QMAKE_TARGET_MKSPEC wasm-emscripten)
+endif()
+
+# TODO: Fixme to be correct.
+set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
+
+# Platform definition dir provided by user on command line.
+# Derive the absolute one relative to the current source dir.
+if(QT_PLATFORM_DEFINITION_DIR)
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR "${QT_PLATFORM_DEFINITION_DIR}")
+ get_filename_component(
+ QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE
+ "${QT_PLATFORM_DEFINITION_DIR}"
+ ABSOLUTE)
+elseif(QT_QMAKE_TARGET_MKSPEC)
+ # Used by consumers of prefix builds via INSTALL_INTERFACE (relative path).
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR "${INSTALL_MKSPECSDIR}/${QT_QMAKE_TARGET_MKSPEC}")
+ # Used by qtbase itself and consumers of non-prefix builds via BUILD_INTERFACE (absolute path).
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}")
+endif()
+
+if(NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS)
+ set(QT_DEFAULT_PLATFORM_DEFINITIONS "")
+endif()
+
+set(QT_PLATFORM_DEFINITIONS ${QT_DEFAULT_PLATFORM_DEFINITIONS}
+ CACHE STRING "Qt platform specific pre-processor defines")
+set(QT_PLATFORM_DEFINITION_DIR "${QT_DEFAULT_PLATFORM_DEFINITION_DIR}"
+ CACHE PATH "Path to directory that contains qplatformdefs.h")
+set(QT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE}"
+ CACHE INTERNAL "Path to directory that contains qplatformdefs.h")
+set(QT_NAMESPACE "" CACHE STRING "Qt Namespace")
+if(QT_NAMESPACE STREQUAL "")
+ set(QT_HAS_NAMESPACE OFF)
+else()
+ set(QT_HAS_NAMESPACE ON)
+endif()
+
+
+function(qt_internal_clear_qt_repo_known_modules)
+ set(QT_REPO_KNOWN_MODULES "" CACHE INTERNAL "Known current repo Qt modules" FORCE)
+endfunction()
+
+function(qt_internal_add_qt_repo_known_module)
+ set(QT_REPO_KNOWN_MODULES ${QT_REPO_KNOWN_MODULES} ${ARGN}
+ CACHE INTERNAL "Known current repo Qt modules" FORCE)
+endfunction()
+
+function(qt_internal_get_qt_repo_known_modules out_var)
+ set("${out_var}" "${QT_REPO_KNOWN_MODULES}" PARENT_SCOPE)
+endfunction()
+
+# Gets the list of all known Qt modules both found and that were built as part of the
+# current project.
+function(qt_internal_get_qt_all_known_modules out_var)
+ qt_internal_get_qt_repo_known_modules(repo_known_modules)
+ set(known_modules ${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE} ${repo_known_modules})
+ list(REMOVE_DUPLICATES known_modules)
+ set("${out_var}" "${known_modules}" PARENT_SCOPE)
+endfunction()
+
+macro(qt_internal_set_qt_known_plugins)
+ set(QT_KNOWN_PLUGINS ${ARGN} CACHE INTERNAL "Known Qt plugins" FORCE)
+endmacro()
+
+### Global plug-in types handling ###
+# QT_REPO_KNOWN_PLUGIN_TYPES and QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE
+# hold a list of plug-in types (e.G. "imageformats;bearer")
+function(qt_internal_clear_qt_repo_known_plugin_types)
+ set(QT_REPO_KNOWN_PLUGIN_TYPES "" CACHE INTERNAL "Known current repo Qt plug-in types" FORCE)
+endfunction()
+
+function(qt_internal_add_qt_repo_known_plugin_types)
+ set(QT_REPO_KNOWN_PLUGIN_TYPES ${QT_REPO_KNOWN_PLUGIN_TYPES} ${ARGN}
+ CACHE INTERNAL "Known current repo Qt plug-in types" FORCE)
+endfunction()
+
+function(qt_internal_get_qt_repo_known_plugin_types out_var)
+ set("${out_var}" "${QT_REPO_KNOWN_PLUGIN_TYPES}" PARENT_SCOPE)
+endfunction()
+
+function(qt_internal_get_qt_all_known_plugin_types out_var)
+ qt_internal_get_qt_repo_known_plugin_types(repo_known_plugin_types)
+ set(known ${QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE} ${repo_known_plugin_types})
+ list(REMOVE_DUPLICATES known)
+ set("${out_var}" "${known}" PARENT_SCOPE)
+endfunction()
+
+# Reset:
+qt_internal_clear_qt_repo_known_modules()
+qt_internal_clear_qt_repo_known_plugin_types()
+qt_internal_set_qt_known_plugins("")
+
+set(QT_KNOWN_MODULES_WITH_TOOLS "" CACHE INTERNAL "Known Qt modules with tools" FORCE)
+macro(qt_internal_append_known_modules_with_tools module)
+ if(NOT ${module} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
+ set(QT_KNOWN_MODULES_WITH_TOOLS "${QT_KNOWN_MODULES_WITH_TOOLS};${module}"
+ CACHE INTERNAL "Known Qt modules with tools" FORCE)
+ set(QT_KNOWN_MODULE_${module}_TOOLS ""
+ CACHE INTERNAL "Known Qt module ${module} tools" FORCE)
+ endif()
+endmacro()
+
+macro(qt_internal_append_known_module_tool module tool)
+ if(NOT ${tool} IN_LIST QT_KNOWN_MODULE_${module}_TOOLS)
+ list(APPEND QT_KNOWN_MODULE_${module}_TOOLS "${tool}")
+ set(QT_KNOWN_MODULE_${module}_TOOLS "${QT_KNOWN_MODULE_${module}_TOOLS}"
+ CACHE INTERNAL "Known Qt module ${module} tools" FORCE)
+ endif()
+endmacro()
+
+# Reset syncqt cache variable, to make sure it gets recomputed on reconfiguration, otherwise
+# it might not get installed.
+unset(QT_SYNCQT CACHE)
+
+# For adjusting variables when running tests, we need to know what
+# the correct variable is for separating entries in PATH-alike
+# variables.
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ set(QT_PATH_SEPARATOR "\\;")
+else()
+ set(QT_PATH_SEPARATOR ":")
+endif()
+
+# Compute the values of QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR
+# taking into account whether the current build is a prefix build or a non-prefix build,
+# and whether it is a superbuild or non-superbuild.
+#
+# These values should be prepended to file paths in commands or properties,
+# in order to correctly place generated Config files, generated Targets files,
+# excutables / libraries, when copying / installing files, etc.
+#
+# The build dir variables will always be absolute paths.
+# The QT_INSTALL_DIR variable will have a relative path in a prefix build,
+# which means that it can be empty, so use qt_join_path to prevent accidental absolute paths.
+if(QT_SUPERBUILD)
+ # In this case, we always copy all the build products in qtbase/{bin,lib,...}
+ if(QT_WILL_INSTALL)
+ set(QT_BUILD_DIR "${QtBase_BINARY_DIR}")
+ set(QT_INSTALL_DIR "")
+ else()
+ set(QT_BUILD_DIR "${QtBase_BINARY_DIR}")
+ set(QT_INSTALL_DIR "${QtBase_BINARY_DIR}")
+ endif()
+else()
+ if(QT_WILL_INSTALL)
+ # In the usual prefix build case, the build dir is the current module build dir,
+ # and the install dir is the prefix, so we don't set it.
+ set(QT_BUILD_DIR "${CMAKE_BINARY_DIR}")
+ set(QT_INSTALL_DIR "")
+ else()
+ # When doing a non-prefix build, both the build dir and install dir are the same,
+ # pointing to the qtbase build dir.
+ set(QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
+ set(QT_INSTALL_DIR "${QT_BUILD_DIR}")
+ endif()
+endif()
+
+set(__config_path_part "${INSTALL_LIBDIR}/cmake")
+set(QT_CONFIG_BUILD_DIR "${QT_BUILD_DIR}/${__config_path_part}")
+set(QT_CONFIG_INSTALL_DIR "${QT_INSTALL_DIR}")
+if(QT_CONFIG_INSTALL_DIR)
+ string(APPEND QT_CONFIG_INSTALL_DIR "/")
+endif()
+string(APPEND QT_CONFIG_INSTALL_DIR ${__config_path_part})
+unset(__config_path_part)
+
+# This is used to hold extra cmake code that should be put into QtBuildInternalsExtra.cmake file
+# at the QtPostProcess stage.
+set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "")
+
+# Save the value of the current first project source dir.
+# This will be /path/to/qtbase for qtbase both in a super-build and a non super-build.
+# This will be /path/to/qtbase/tests when building standalone tests.
+set(QT_TOP_LEVEL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+
+# Prevent warnings about object files without any symbols. This is a common
+# thing in Qt as we tend to build files unconditionally, and then use ifdefs
+# to compile out parts that are not relevant.
+if(CMAKE_HOST_APPLE AND APPLE)
+ foreach(lang ASM C CXX)
+ # We have to tell 'ar' to not run ranlib by itself, by passing the 'S' option
+ set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qcS <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> qS <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols <TARGET>")
+ endforeach()
+endif()
+
+# Functions and macros:
+
+# qt_remove_args can remove arguments from an existing list of function
+# arguments in order to pass a filtered list of arguments to a different function.
+# Parameters:
+# out_var: result of remove all arguments specified by ARGS_TO_REMOVE from ALL_ARGS
+# ARGS_TO_REMOVE: Arguments to remove.
+# ALL_ARGS: All arguments supplied to cmake_parse_arguments or
+# qt_parse_all_arguments
+# from which ARGS_TO_REMOVE should be removed from. We require all the
+# arguments or we can't properly identify the range of the arguments detailed
+# in ARGS_TO_REMOVE.
+# ARGS: Arguments passed into the function, usually ${ARGV}
+#
+# E.g.:
+# We want to forward all arguments from foo to bar, execpt ZZZ since it will
+# trigger an error in bar.
+#
+# foo(target BAR .... ZZZ .... WWW ...)
+# bar(target BAR.... WWW...)
+#
+# function(foo target)
+# qt_parse_all_arguments(arg "" "" "BAR;ZZZ;WWW ${ARGV})
+# qt_remove_args(forward_args
+# ARGS_TO_REMOVE ${target} ZZZ
+# ALL_ARGS ${target} BAR ZZZ WWW
+# ARGS ${ARGV}
+# )
+# bar(${target} ${forward_args})
+# endfunction()
+#
+function(qt_remove_args out_var)
+ cmake_parse_arguments(arg "" "" "ARGS_TO_REMOVE;ALL_ARGS;ARGS" ${ARGN})
+ set(result ${arg_ARGS})
+ foreach(arg IN LISTS arg_ARGS_TO_REMOVE)
+ # find arg
+ list(FIND result ${arg} find_result)
+ if (NOT find_result EQUAL -1)
+ # remove arg
+ list(REMOVE_AT result ${find_result})
+ list(LENGTH result result_len)
+ list(GET result ${find_result} arg_current)
+ # remove values until we hit another arg
+ while(NOT ${arg_current} IN_LIST arg_ALL_ARGS AND find_result LESS result_len)
+ list(REMOVE_AT result ${find_result})
+ list(GET result ${find_result} arg_current)
+ list(LENGTH result result_len)
+ endwhile()
+ endif()
+ endforeach()
+ set(${out_var} "${result}" PARENT_SCOPE)
+endfunction()
+# Wraps install() command. In a prefix build, simply passes along arguments to install().
+# In a non-prefix build, handles association of targets to export names, and also calls export().
+function(qt_install)
+ set(flags)
+ set(options EXPORT DESTINATION NAMESPACE)
+ set(multiopts TARGETS)
+ cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN})
+
+ if(arg_TARGETS)
+ set(is_install_targets TRUE)
+ endif()
+
+ # In a prefix build, always invoke install() without modification.
+ # In a non-prefix build, pass install(TARGETS) commands to allow
+ # association of targets to export names, so we can later use the export names
+ # in export() commands.
+ if(QT_WILL_INSTALL OR is_install_targets)
+ install(${ARGV})
+ endif()
+
+ # Exit early if this is a prefix build.
+ if(QT_WILL_INSTALL)
+ return()
+ endif()
+
+ # In a non-prefix build, when install(EXPORT) is called,
+ # also call export(EXPORT) to generate build tree target files.
+ if(NOT is_install_targets AND arg_EXPORT)
+ set(namespace_option "")
+ if(arg_NAMESPACE)
+ set(namespace_option NAMESPACE ${arg_NAMESPACE})
+ endif()
+ export(EXPORT ${arg_EXPORT}
+ ${namespace_option}
+ FILE "${arg_DESTINATION}/${arg_EXPORT}.cmake")
+ endif()
+endfunction()
+
+# Copies files using file(COPY) signature in non-prefix builds.
+function(qt_non_prefix_copy)
+ if(NOT QT_WILL_INSTALL)
+ file(${ARGV})
+ endif()
+endfunction()
+
+# Use case is installing files in a prefix build, or copying them to the correct build dir
+# in a non-prefix build.
+# Pass along arguments as you would pass them to install().
+# Only supports FILES, PROGRAMS and DIRECTORY signature, and without fancy things
+# like OPTIONAL or RENAME or COMPONENT.
+function(qt_copy_or_install)
+ set(flags FILES PROGRAMS DIRECTORY)
+ set(options)
+ set(multiopts)
+ cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN})
+
+ # Remember which option has to be passed to the install command.
+ set(argv_copy ${ARGV})
+ if(arg_FILES)
+ set(install_option "FILES")
+ elseif(arg_PROGRAMS)
+ set(install_option "PROGRAMS")
+ elseif(arg_DIRECTORY)
+ set(install_option "DIRECTORY")
+ endif()
+
+ list(REMOVE_AT argv_copy 0)
+ qt_install(${install_option} ${argv_copy})
+ qt_non_prefix_copy(COPY ${argv_copy})
+endfunction()
+
+# Hacky way to remove the install target in non-prefix builds.
+# We need to associate targets with export names, and that is only possible to do with the
+# install(TARGETS) command. But in a non-prefix build, we don't want to install anything.
+# To make sure that developers don't accidentally run make install, replace the generated
+# cmake_install.cmake file with an empty file. To do this, always create a new temporary file
+# at CMake configuration step, and use it as an input to a custom command that replaces the
+# cmake_install.cmake file with an empty one. This means we will always replace the file on
+# every reconfiguration, but not when doing null builds.
+function(qt_remove_install_target)
+ # On superbuilds we only do this for qtbase - it will correctly remove the
+ # cmake_install.cmake at the root of the repository.
+ if(QT_SUPERBUILD)
+ if(NOT (PROJECT_NAME STREQUAL "QtBase"))
+ return()
+ endif()
+ endif()
+
+ set(file_in "${CMAKE_BINARY_DIR}/.remove_cmake_install_in.txt")
+ set(file_generated "${CMAKE_BINARY_DIR}/.remove_cmake_install_generated.txt")
+ set(cmake_install_file "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ file(WRITE ${file_in} "")
+
+ add_custom_command(OUTPUT ${file_generated}
+ COMMAND ${CMAKE_COMMAND} -E copy ${file_in} ${file_generated}
+ COMMAND ${CMAKE_COMMAND} -E remove ${cmake_install_file}
+ COMMAND ${CMAKE_COMMAND} -E touch ${cmake_install_file}
+ COMMENT "Removing cmake_install.cmake"
+ MAIN_DEPENDENCY ${file_in})
+
+ add_custom_target(remove_cmake_install ALL DEPENDS ${file_generated})
+endfunction()
+
+function(qt_set_up_nonprefix_build)
+ if(NOT QT_WILL_INSTALL)
+ qt_remove_install_target()
+ endif()
+endfunction()
+
+function(qt_is_imported_target target out_var)
+ if(NOT TARGET "${target}")
+ set(target "${QT_CMAKE_EXPORT_NAMESPACE}::${target}")
+ endif()
+ if(NOT TARGET "${target}")
+ message(FATAL_ERROR "Invalid target given to qt_is_imported_target: ${target}")
+ endif()
+ get_target_property(is_imported "${target}" IMPORTED)
+ set(${out_var} "${is_imported}" PARENT_SCOPE)
+endfunction()
+
+# Generates module .pri files for consumption by qmake
+function(qt_generate_module_pri_file target target_path pri_files_var)
+ set(flags INTERNAL_MODULE HEADER_MODULE)
+ set(options)
+ set(multiopts QMAKE_MODULE_CONFIG)
+ cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN})
+
+ qt_internal_module_info(module "${target}")
+ set(pri_files)
+
+ set(property_prefix)
+ if(arg_HEADER_MODULE)
+ set(property_prefix "interface_")
+ endif()
+
+ get_target_property(enabled_features "${target}"
+ "${property_prefix}QT_ENABLED_PUBLIC_FEATURES")
+ get_target_property(disabled_features "${target}"
+ "${property_prefix}QT_DISABLED_PUBLIC_FEATURES")
+ get_target_property(enabled_private_features "${target}"
+ "${property_prefix}QT_ENABLED_PRIVATE_FEATURES")
+ get_target_property(disabled_private_features "${target}"
+ "${property_prefix}QT_DISABLED_PRIVATE_FEATURES")
+
+ foreach(var enabled_features disabled_features enabled_private_features disabled_private_features)
+ if(${var} STREQUAL "${var}-NOTFOUND")
+ set(${var} "")
+ else()
+ string (REPLACE ";" " " ${var} "${${var}}")
+ endif()
+ endforeach()
+
+ if(arg_QMAKE_MODULE_CONFIG)
+ string(REPLACE ";" " " module_config "${arg_QMAKE_MODULE_CONFIG}")
+ set(module_config "\nQT.${module_lower}.CONFIG = ${module_config}")
+ else()
+ set(module_config "")
+ endif()
+
+ if (NOT ${arg_INTERNAL_MODULE})
+ qt_path_join(pri_file_name "${target_path}" "qt_lib_${module_lower}.pri")
+ list(APPEND pri_files "${pri_file_name}")
+
+ file(GENERATE
+ OUTPUT "${pri_file_name}"
+ CONTENT
+ "QT.${module_lower}.VERSION = ${PROJECT_VERSION}
+QT.${module_lower}.name = ${module}
+QT.${module_lower}.module = ${module_versioned}
+QT.${module_lower}.libs = $$QT_MODULE_LIB_BASE
+QT.${module_lower}.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/${module}
+QT.${module_lower}.frameworks =
+QT.${module_lower}.bins = $$QT_MODULE_BIN_BASE
+QT.${module_lower}.depends =
+QT.${module_lower}.uses =
+QT.${module_lower}.module_config = v2
+QT.${module_lower}.DEFINES = QT_${module_define}_LIB
+QT.${module_lower}.enabled_features = ${enabled_features}
+QT.${module_lower}.disabled_features = ${disabled_features}${module_config}
+QT_MODULES += ${module_lower}
+"
+ )
+ endif()
+
+ qt_path_join(private_pri_file "${target_path}" "qt_lib_${module_lower}_private.pri")
+ list(APPEND pri_files "${private_pri_file}")
+
+ file(GENERATE
+ OUTPUT "${private_pri_file}"
+ CONTENT
+ "QT.${module_lower}_private.VERSION = ${PROJECT_VERSION}
+QT.${module_lower}_private.name = ${module}
+QT.${module_lower}_private.module =
+QT.${module_lower}_private.libs = $$QT_MODULE_LIB_BASE
+QT.${module_lower}_private.includes = $$QT_MODULE_INCLUDE_BASE/${module}/${PROJECT_VERSION} $$QT_MODULE_INCLUDE_BASE/${module}/${PROJECT_VERSION}/${module}
+QT.${module_lower}_private.frameworks =
+QT.${module_lower}_private.depends = ${module_lower}
+QT.${module_lower}_private.uses =
+QT.${module_lower}_private.module_config = v2
+QT.${module_lower}_private.enabled_features = ${enabled_private_features}
+QT.${module_lower}_private.disabled_features = ${disabled_private_features}
+"
+ )
+
+ set("${pri_files_var}" "${pri_files}" PARENT_SCOPE)
+endfunction()
+
+function(qt_generate_global_config_pri_file)
+ qt_path_join(qconfig_pri_target_path ${PROJECT_BINARY_DIR} ${INSTALL_MKSPECSDIR})
+ qt_path_join(qconfig_pri_target_path "${qconfig_pri_target_path}" "qconfig.pri")
+
+ get_target_property(enabled_features GlobalConfig INTERFACE_QT_ENABLED_PUBLIC_FEATURES)
+ get_target_property(disabled_features GlobalConfig INTERFACE_QT_DISABLED_PUBLIC_FEATURES)
+
+ # configure2cmake skips the "static" feature, so emulate it here for qmake support:
+ if(QT_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
+ list(APPEND enabled_features shared)
+ list(APPEND disabled_features static)
+ set(qt_build_config_type "shared")
+ else()
+ list(APPEND enabled_features static)
+ list(APPEND disabled_features shared)
+ set(qt_build_config_type "static")
+ endif()
+
+ # configure2cmake skips the "rpath" feature, so emulate it here for qmake support:
+ if(CMAKE_SKIP_RPATH)
+ list(APPEND disabled_features rpath)
+ elseif(LINUX OR APPLE)
+ list(APPEND enabled_features rpath)
+ endif()
+
+ string (REPLACE ";" " " enabled_features "${enabled_features}")
+ string (REPLACE ";" " " disabled_features "${disabled_features}")
+
+ # Add some required CONFIG entries.
+ set(config_entries "")
+ if(CMAKE_BUILD_TYPE STREQUAL Debug)
+ list(APPEND config_entries "debug")
+ elseif(CMAKE_BUILD_TYPE STREQUAL Release)
+ list(APPEND config_entries "release")
+ endif()
+ list(APPEND config_entries "${qt_build_config_type}")
+ string (REPLACE ";" " " config_entries "${config_entries}")
+
+ file(GENERATE
+ OUTPUT "${qconfig_pri_target_path}"
+ CONTENT
+ "QT_ARCH = ${TEST_architecture_arch}
+QT_BUILDABI = ${TEST_buildAbi}
+QT.global.enabled_features = ${enabled_features}
+QT.global.disabled_features = ${disabled_features}
+QT_VERSION = ${PROJECT_VERSION}
+QT_MAJOR_VERSION = ${PROJECT_VERSION_MAJOR}
+QT_MINOR_VERSION = ${PROJECT_VERSION_MINOR}
+QT_PATCH_VERSION = ${PROJECT_VERSION_PATCH}
+CONFIG -= link_prl # we do not create prl files right now
+CONFIG += ${config_entries}
+"
+ )
+ qt_install(FILES "${qconfig_pri_target_path}" DESTINATION ${INSTALL_MKSPECSDIR})
+endfunction()
+
+# Takes a list of path components and joins them into one path separated by forward slashes "/",
+# and saves the path in out_var.
+function(qt_path_join out_var)
+ # Remove output variable.
+ set(argv ${ARGV})
+ list(REMOVE_AT argv 0)
+
+ # Join the path components.
+ string(JOIN "/" path ${argv})
+ set(${out_var} ${path} PARENT_SCOPE)
+endfunction()
+
+function(qt_internal_export_modern_cmake_config_targets_file)
+ cmake_parse_arguments(__arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR" "TARGETS" ${ARGN})
+
+ set(export_name "${__arg_EXPORT_NAME_PREFIX}VersionlessTargets")
+ foreach(target ${__arg_TARGETS})
+ if (TARGET "${target}Versionless")
+ continue()
+ endif()
+
+ add_library("${target}Versionless" INTERFACE)
+ target_link_libraries("${target}Versionless" INTERFACE "${target}")
+ set_target_properties("${target}Versionless" PROPERTIES EXPORT_NAME "${target}")
+ qt_install(TARGETS "${target}Versionless" EXPORT ${export_name})
+ endforeach()
+ qt_install(EXPORT ${export_name} NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}")
+endfunction()
+
+# Print all variables defined in the current scope.
+macro(qt_debug_print_variables)
+ cmake_parse_arguments(__arg "DEDUP" "" "MATCH;IGNORE" ${ARGN})
+ message("Known Variables:")
+ get_cmake_property(__variableNames VARIABLES)
+ list (SORT __variableNames)
+ if (__arg_DEDUP)
+ list(REMOVE_DUPLICATES __variableNames)
+ endif()
+
+ foreach(__var ${__variableNames})
+ set(__ignore OFF)
+ foreach(__i ${__arg_IGNORE})
+ if(__var MATCHES "${__i}")
+ set(__ignore ON)
+ break()
+ endif()
+ endforeach()
+
+ if (__ignore)
+ continue()
+ endif()
+
+ set(__show OFF)
+ foreach(__i ${__arg_MATCH})
+ if(__var MATCHES "${__i}")
+ set(__show ON)
+ break()
+ endif()
+ endforeach()
+
+ if (__show)
+ message(" ${__var}=${${__var}}.")
+ endif()
+ endforeach()
+endmacro()
+
+
+macro(assert)
+ if (${ARGN})
+ else()
+ message(FATAL_ERROR "ASSERT: ${ARGN}.")
+ endif()
+endmacro()
+
+
+function(qt_create_nolink_target target dependee_target)
+ if(NOT TARGET "${target}")
+ message(FATAL_ERROR "${target} does not exist when trying to build a nolink target.")
+ endif()
+ get_target_property(type "${target}" TYPE)
+ if(type STREQUAL EXECUTABLE)
+ message(FATAL_ERROR "${target} must be a library of some kind.")
+ endif()
+ if(type STREQUAL OBJECT_LIBRARY)
+ message(FATAL_ERROR "${target} must not be an object library.")
+ endif()
+
+ # Strip off the namespace prefix, so from Vulkan::Vulkan to Vulkan, and then append _nolink.
+ string(REGEX REPLACE "^.*::" "" non_prefixed_target ${target})
+ set(nolink_target "${non_prefixed_target}_nolink")
+
+ # Create the nolink interface target, assign the properties from the original target,
+ # associate the nolink target with the same export which contains
+ # the target that uses the _nolink target.
+ # Also create a namespaced alias of the form ${target}::${target}_nolink which is used by
+ # our modules.
+ # Also create a Qt namespaced alias target, because when exporting via install(EXPORT)
+ # Vulkan::Vulkan_nolink transforms into Qt6::Vulkan_nolink, and the latter needs to be an
+ # accessible alias for standalone tests.
+ if(NOT TARGET "${nolink_target}")
+ add_library("${nolink_target}" INTERFACE)
+ set(prefixed_nolink_target "${target}_nolink")
+ set_target_properties("${nolink_target}" PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:${target},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
+ INTERFACE_COMPILE_DEFINITIONS
+ $<TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS>
+ INTERFACE_COMPILE_OPTIONS
+ $<TARGET_PROPERTY:${target},INTERFACE_COMPILE_OPTIONS>
+ INTERFACE_COMPILE_FEATURES
+ $<TARGET_PROPERTY:${target},INTERFACE_COMPILE_FEATURES>)
+
+ add_library(${prefixed_nolink_target} ALIAS ${nolink_target})
+ add_library("${INSTALL_CMAKE_NAMESPACE}::${nolink_target}" ALIAS ${nolink_target})
+
+ set(export_name "${INSTALL_CMAKE_NAMESPACE}${dependee_target}Targets")
+ qt_install(TARGETS ${nolink_target} EXPORT ${export_name})
+ endif()
+endfunction()
+
+function(qt_ensure_perl)
+ if(DEFINED HOST_PERL)
+ return()
+ endif()
+ find_program(HOST_PERL "perl" DOC "Perl binary")
+ if (NOT HOST_PERL)
+ message(FATAL_ERROR "Perl needs to be available to build Qt.")
+ endif()
+endfunction()
+
+
+function(qt_ensure_sync_qt)
+ qt_ensure_perl()
+ if(DEFINED QT_SYNCQT)
+ return()
+ endif()
+
+ # When building qtbase, use the source syncqt, otherwise use the installed one.
+ set(SYNCQT_FROM_SOURCE "${QtBase_SOURCE_DIR}/bin/syncqt.pl")
+ if(NOT ("${QtBase_SOURCE_DIR}" STREQUAL "") AND EXISTS "${SYNCQT_FROM_SOURCE}")
+ set(QT_SYNCQT "${SYNCQT_FROM_SOURCE}" CACHE FILEPATH "syncqt script")
+ message(STATUS "Using source syncqt found at: ${QT_SYNCQT}")
+
+ qt_path_join(syncqt_install_dir ${QT_INSTALL_DIR} ${INSTALL_LIBEXECDIR})
+ qt_copy_or_install(PROGRAMS "${SYNCQT_FROM_SOURCE}"
+ DESTINATION "${syncqt_install_dir}")
+ else()
+ get_filename_component(syncqt_absolute_path
+ "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}/syncqt.pl"
+ ABSOLUTE)
+ set(QT_SYNCQT "${syncqt_absolute_path}" CACHE FILEPATH "syncqt script")
+ message(STATUS "Using installed syncqt found at: ${QT_SYNCQT}")
+ endif()
+endfunction()
+
+# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out
+# with a message about ${type} having received unknown arguments.
+macro(qt_parse_all_arguments result type flags options multiopts)
+ cmake_parse_arguments(${result} "${flags}" "${options}" "${multiopts}" ${ARGN})
+ if(DEFINED ${result}_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown arguments were passed to ${type} (${${result}_UNPARSED_ARGUMENTS}).")
+ endif()
+endmacro()
+
+include(CheckCXXSourceCompiles)
+
+function(qt_internal_add_link_flags_no_undefined target)
+ if (NOT QT_BUILD_SHARED_LIBS)
+ return()
+ endif()
+ if (GCC OR CLANG)
+ set(previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+
+ set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error")
+ check_cxx_source_compiles("int main() {}" HAVE_DASH_UNDEFINED_ERROR)
+ if(HAVE_DASH_UNDEFINED_ERROR)
+ set(no_undefined_flag "-Wl,-undefined,error")
+ endif()
+
+ set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined")
+ check_cxx_source_compiles("int main() {}" HAVE_DASH_DASH_NO_UNDEFINED)
+ if(HAVE_DASH_DASH_NO_UNDEFINED)
+ set(no_undefined_flag "-Wl,--no-undefined")
+ endif()
+
+ set(CMAKE_REQUIRED_LINK_OPTIONS ${previous_CMAKE_REQUIRED_LINK_OPTIONS})
+
+ if (NOT HAVE_DASH_UNDEFINED_ERROR AND NOT HAVE_DASH_DASH_NO_UNDEFINED)
+ message(FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\"${target}\".")
+ endif()
+ target_link_options("${target}" PRIVATE "${no_undefined_flag}")
+ endif()
+endfunction()
+
+function(qt_internal_add_link_flags_gc_sections target visibility)
+ set(possible_visibilities PRIVATE INTERFACE PUBLIC)
+ list(FIND possible_visibilities "${visibility}" known_visibility)
+ if (known_visibility EQUAL "-1")
+ message(FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC.")
+ endif()
+
+ if ((GCC OR CLANG) AND NOT EMSCRIPTEN)
+ if(APPLE)
+ set(gc_sections_flag "-Wl,-dead_strip")
+ elseif(LINUX OR BSD OR SOLARIS OR WIN32 OR ANDROID)
+ set(gc_sections_flag "-Wl,--gc-sections")
+ else()
+ message(FATAL_ERROR "Platform linker doesn't support gc sections. Target:\"${target}\".")
+ endif()
+ target_link_options("${target}" ${visibility} "${gc_sections_flag}")
+ endif()
+endfunction()
+
+function(qt_internal_add_linker_version_script target)
+ qt_parse_all_arguments(arg "qt_internal_add_linker" "INTERNAL" "" "PRIVATE_HEADERS" ${ARGN})
+
+ if (TEST_ld_version_script)
+ if (arg_INTERNAL)
+ set(contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API { *; };")
+ else()
+ set(contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API {\n qt_private_api_tag*;\n")
+ foreach(ph ${arg_PRIVATE_HEADERS})
+ string(APPEND contents " @FILE:${ph}@\n")
+ endforeach()
+ string(APPEND contents "};\n")
+ set(current "Qt_${PROJECT_VERSION_MAJOR}")
+ if (QT_NAMESPACE STREQUAL "")
+ set(tag_symbol "qt_version_tag")
+ else()
+ set(tag_symbol "qt_version_tag_${QT_NAMESPACE}")
+ endif()
+ string(APPEND contents "${current} { *; };\n")
+
+ foreach(minor_version RANGE ${PROJECT_VERSION_MINOR})
+ set(previous "${current}")
+ set(current "Qt_${PROJECT_VERSION_MAJOR}.${minor_version}")
+ if (minor_version EQUAL ${PROJECT_VERSION_MINOR})
+ string(APPEND contents "${current} { ${tag_symbol}; } ${previous};\n")
+ else()
+ string(APPEND contents "${current} {} ${previous};\n")
+ endif()
+ endforeach()
+
+ set(infile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version.in")
+ set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version")
+
+ file(GENERATE OUTPUT "${infile}" CONTENT "${contents}")
+
+ qt_ensure_perl()
+
+ add_custom_command(TARGET "${target}" PRE_LINK
+ COMMAND "${HOST_PERL}" "${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl" < "${infile}" > "${outfile}"
+ BYPRODUCTS "${outfile}" DEPENDS "${infile}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ COMMENT "Generating version linker script"
+ )
+ target_link_options("${target}" PRIVATE "-Wl,--version-script,${outfile}")
+ endif()
+ endif()
+endfunction()
+
+
+# Get a set of Qt module related values based on the target name.
+# When doing qt_internal_module_info(foo Core) this method will set
+# the following variables in the caller's scope:
+# * foo with the value "QtCore"
+# * foo_versioned with the value "Qt6Core" (based on major Qt version)
+# * foo_upper with the value "CORE"
+# * foo_lower with the value "core"
+# * foo_repo_include_dir with the module's include directory
+# e.g for QtQuick it would be qtdeclarative_build_dir/include for a prefix build or
+# qtbase_build_dir/include for a non-prefix build
+# * foo_include_dir with the module's include directory
+# e.g for QtQuick it would be qtdeclarative_build_dir/include/QtQuick for a prefix build or
+# qtbase_build_dir/include/QtQuick for a non-prefix build
+# * foo_define same as foo_uper but with - replaced as _
+function(qt_internal_module_info result target)
+ set(module "Qt${target}")
+ set("${result}" "${module}" PARENT_SCOPE)
+ set("${result}_versioned" "Qt${PROJECT_VERSION_MAJOR}${target}" PARENT_SCOPE)
+ string(TOUPPER "${target}" upper)
+ string(TOLOWER "${target}" lower)# * foo_upper with the value "CORE"
+ string(REPLACE "-" "_" define "${upper}")
+ string(REPLACE "." "_" define "${define}")
+ set("${result}_upper" "${upper}" PARENT_SCOPE)
+ set("${result}_lower" "${lower}" PARENT_SCOPE)
+ set("${result}_repo_include_dir" "${QT_BUILD_DIR}/include" PARENT_SCOPE)
+ set("${result}_include_dir" "${QT_BUILD_DIR}/include/${module}" PARENT_SCOPE)
+ set("${result}_define" "${define}" PARENT_SCOPE)
+endfunction()
+
+
+set(__default_private_args "SOURCES;LIBRARIES;INCLUDE_DIRECTORIES;DEFINES;DBUS_ADAPTOR_BASENAME;DBUS_ADAPTOR_FLAGS;DBUS_ADAPTOR_SOURCES;DBUS_INTERFACE_BASENAME;DBUS_INTERFACE_FLAGS;DBUS_INTERFACE_SOURCES;FEATURE_DEPENDENCIES;COMPILE_OPTIONS;LINK_OPTIONS;MOC_OPTIONS;DISABLE_AUTOGEN_TOOLS;ENABLE_AUTOGEN_TOOLS;PLUGIN_TYPES")
+
+set(__default_public_args "PUBLIC_LIBRARIES;PUBLIC_INCLUDE_DIRECTORIES;PUBLIC_DEFINES;PUBLIC_COMPILE_OPTIONS;PUBLIC_LINK_OPTIONS")
+
+
+option(QT_CMAKE_DEBUG_EXTEND_TARGET "Debug extend_target calls in Qt's build system" OFF)
+
+# Initial autogen setup for a target to specify certain CMake properties which are common
+# to all autogen tools. Also enable AUTOMOC by default.
+function(qt_autogen_tools_initial_setup target)
+ set_property(TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
+ set_property(TARGET "${target}" APPEND PROPERTY COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION)
+
+ set_directory_properties(PROPERTIES
+ QT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
+ QT_VERSION_MINOR ${PROJECT_VERSION_MINOR}
+ QT_VERSION_PATCH ${PROJECT_VERSION_PATCH}
+ )
+
+ qt_enable_autogen_tool(${target} "moc" ON)
+endfunction()
+
+# Enables or disables an autogen tool like moc, uic or rcc on ${target}.
+function(qt_enable_autogen_tool target tool enable)
+ string(TOUPPER "${tool}" captitalAutogenTool)
+
+ get_target_property(tool_enabled ${target} AUTO${captitalAutogenTool})
+ get_target_property(autogen_target_depends ${target} AUTOGEN_TARGET_DEPENDS)
+
+ if(NOT autogen_target_depends)
+ set(autogen_target_depends "")
+ endif()
+ set(tool_executable "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::${tool}>")
+ set(tool_target_name ${QT_CMAKE_EXPORT_NAMESPACE}::${tool})
+
+ if(enable)
+ list(APPEND autogen_target_depends ${tool_target_name})
+ else()
+ list(REMOVE_ITEM autogen_target_depends ${tool_target_name})
+ endif()
+
+ # f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96 in qtbase introduced a new macro
+ # that the moc scanner has to look for. Inform the CMake moc scanner about it.
+ if(tool STREQUAL "moc" AND enable)
+ set_target_properties("${target}" PROPERTIES
+ AUTOMOC_MACRO_NAMES "Q_OBJECT;Q_GADGET;Q_NAMESPACE;Q_NAMESPACE_EXPORT;Q_ENUM_NS")
+ endif()
+
+ set_target_properties("${target}"
+ PROPERTIES
+ AUTO${captitalAutogenTool} "${enable}"
+ AUTO${captitalAutogenTool}_EXECUTABLE "${tool_executable}"
+ AUTOGEN_TARGET_DEPENDS "${autogen_target_depends}"
+ )
+endfunction()
+
+# This function adds or removes additional AUTOGEN tools to a target: AUTOMOC/UIC/RCC
+function(qt_autogen_tools target)
+ qt_parse_all_arguments(arg "qt_autogen_tools" "" "" "${__default_private_args}" ${ARGN})
+
+ if (arg_ENABLE_AUTOGEN_TOOLS)
+ foreach(tool ${arg_ENABLE_AUTOGEN_TOOLS})
+ qt_enable_autogen_tool(${target} ${tool} ON)
+ endforeach()
+ endif()
+
+ if (arg_DISABLE_AUTOGEN_TOOLS)
+ foreach(tool ${arg_DISABLE_AUTOGEN_TOOLS})
+ qt_enable_autogen_tool(${target} ${tool} OFF)
+ endforeach()
+ endif()
+endfunction()
+
+# This function stores the list of Qt modules a library depend on,
+# along with their version info, for usage in ${target}Depends.cmake file
+function(qt_register_target_dependencies target public_libs private_libs)
+ get_target_property(target_deps "${target}" _qt_target_deps)
+ if(NOT target_deps)
+ set(target_deps "")
+ endif()
+
+ foreach(lib IN LISTS public_libs private_libs)
+ if ("${lib}" MATCHES "^Qt::(.*)")
+ set(lib "${CMAKE_MATCH_1}")
+ if (lib STREQUAL Platform
+ OR lib STREQUAL GlobalConfig
+ OR lib STREQUAL GlobalConfigPrivate
+ OR lib STREQUAL PlatformModuleInternal
+ OR lib STREQUAL PlatformPluginInternal
+ OR lib STREQUAL PlatformToolInternal)
+ list(APPEND target_deps "Qt6\;${PROJECT_VERSION}")
+ elseif ("${lib}" MATCHES "(.*)Private")
+ list(APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${CMAKE_MATCH_1}\;${PROJECT_VERSION}")
+ else()
+ list(APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${lib}\;${PROJECT_VERSION}")
+ endif()
+ endif()
+ endforeach()
+
+ set_target_properties("${target}" PROPERTIES _qt_target_deps "${target_deps}")
+endfunction()
+
+function(qt_update_precompiled_header target precompiled_header)
+ if (precompiled_header AND BUILD_WITH_PCH)
+ set_property(TARGET "${target}" APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<COMPILE_LANGUAGE:CXX>:${precompiled_header}>")
+ endif()
+endfunction()
+
+function(qt_update_precompiled_header_with_library target library)
+ if (TARGET "${library}")
+ get_target_property(TARGET_TYPE "${library}" TYPE)
+ if (NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(HEADER "${library}" MODULE_HEADER)
+ qt_update_precompiled_header("${target}" "${HEADER}")
+ endif()
+ endif()
+endfunction()
+
+function(qt_update_ignore_pch_source target sources)
+ if (sources)
+ set_source_files_properties(${sources} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+ endif()
+endfunction()
+
+function(qt_ignore_pch_obj_c_sources target sources)
+ list(FILTER sources INCLUDE REGEX "\\.mm$")
+ qt_update_ignore_pch_source("${target}" "${sources}")
+endfunction()
+
+# This function can be used to add sources/libraries/etc. to the specified CMake target
+# if the provided CONDITION evaluates to true.
+function(qt_extend_target target)
+ # Don't try to extend_target when cross compiling an imported host target (like a tool).
+ qt_is_imported_target("${target}" is_imported)
+ if(is_imported)
+ return()
+ endif()
+
+ if (NOT TARGET "${target}")
+ message(FATAL_ERROR "Trying to extend non-existing target \"${target}\".")
+ endif()
+ qt_parse_all_arguments(arg "qt_extend_target" "HEADER_MODULE" "PRECOMPILED_HEADER"
+ "CONDITION;${__default_public_args};${__default_private_args};COMPILE_FLAGS;NO_PCH_SOURCES" ${ARGN})
+ if ("x${arg_CONDITION}" STREQUAL x)
+ set(arg_CONDITION ON)
+ endif()
+
+ qt_evaluate_config_expression(result ${arg_CONDITION})
+ if (${result})
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("qt_extend_target(${target} CONDITION ${arg_CONDITION} ...): Evaluated")
+ endif()
+ set(dbus_sources "")
+ foreach(adaptor ${arg_DBUS_ADAPTOR_SOURCES})
+ qt_create_qdbusxml2cpp_command("${target}" "${adaptor}" ADAPTOR BASENAME "${arg_DBUS_ADAPTOR_BASENAME}" FLAGS "${arg_DBUS_ADAPTOR_FLAGS}")
+ list(APPEND dbus_sources "${sources}")
+ endforeach()
+
+ foreach(interface ${arg_DBUS_INTERFACE_SOURCES})
+ qt_create_qdbusxml2cpp_command("${target}" "${interface}" INTERFACE BASENAME "${arg_DBUS_INTERFACE_BASENAME}" FLAGS "${arg_DBUS_INTERFACE_FLAGS}")
+ list(APPEND dbus_sources "${sources}")
+ endforeach()
+
+ get_target_property(target_type ${target} TYPE)
+ set(is_library FALSE)
+ if (${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "SHARED_LIBRARY")
+ set(is_library TRUE)
+ endif()
+ foreach(lib ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES})
+ # Automatically generate PCH for 'target' using dependencies
+ # if 'target' is a library/module!
+ if (${is_library})
+ qt_update_precompiled_header_with_library("${target}" "${lib}")
+ endif()
+
+ string(REGEX REPLACE "_nolink$" "" base_lib "${lib}")
+ if(NOT base_lib STREQUAL lib)
+ qt_create_nolink_target("${base_lib}" ${target})
+ endif()
+ endforeach()
+
+ # Find dependencies to internal libraries
+ get_target_property(target_deps "${target}" _qt_target_deps)
+ if(NOT target_deps)
+ set(target_deps "")
+ endif()
+
+ foreach(lib ${arg_LIBRARIES})
+ if (TARGET "${lib}")
+ get_target_property(_is_exported "${lib}" INTERFACE_QT_EXPORTED_LIBRARY)
+ if("${_is_exported}")
+ list(APPEND target_deps "${lib}\;${PROJECT_VERSION}")
+ endif()
+ endif()
+ endforeach()
+ # Set-up the target
+ target_sources("${target}" PRIVATE ${arg_SOURCES} ${dbus_sources})
+ if (arg_COMPILE_FLAGS)
+ set_source_files_properties(${arg_SOURCES} PROPERTIES COMPILE_FLAGS "${arg_COMPILE_FLAGS}")
+ endif()
+
+ set(public_visibility_option "PUBLIC")
+ set(private_visibility_option "PRIVATE")
+ if(arg_HEADER_MODULE)
+ set(public_visibility_option "INTERFACE")
+ set(private_visibility_option "INTERFACE")
+ endif()
+ target_include_directories("${target}"
+ ${public_visibility_option} ${arg_PUBLIC_INCLUDE_DIRECTORIES}
+ ${private_visibility_option} ${arg_INCLUDE_DIRECTORIES})
+ target_compile_definitions("${target}"
+ ${public_visibility_option} ${arg_PUBLIC_DEFINES}
+ ${private_visibility_option} ${arg_DEFINES})
+ target_link_libraries("${target}"
+ ${public_visibility_option} ${arg_PUBLIC_LIBRARIES}
+ ${private_visibility_option} ${arg_LIBRARIES})
+ target_compile_options("${target}"
+ ${public_visibility_option} ${arg_PUBLIC_COMPILE_OPTIONS}
+ ${private_visibility_option} ${arg_COMPILE_OPTIONS})
+ target_link_options("${target}"
+ ${public_visibility_option} ${arg_PUBLIC_LINK_OPTIONS}
+ ${private_visibility_option} ${arg_LINK_OPTIONS})
+
+ if(NOT arg_HEADER_MODULE)
+ set_property (TARGET "${target}" APPEND PROPERTY
+ AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}"
+ )
+ set_property(TARGET "${target}" PROPERTY
+ _qt_target_deps "${target_deps}"
+ )
+ endif()
+
+ # When computing the private library dependencies, we need to check not only the known
+ # modules added by this repo's qt_build_repo(), but also all module dependencies that
+ # were found via find_package().
+ qt_internal_get_qt_all_known_modules(known_modules)
+
+ # When a public module depends on a private module (Gui on CorePrivate)
+ # make its private module depend on the other private module (GuiPrivate will depend on
+ # CorePrivate).
+ set(qt_libs_private "")
+ foreach(it ${known_modules})
+ list(FIND arg_LIBRARIES "Qt::${it}Private" pos)
+ if(pos GREATER -1)
+ list(APPEND qt_libs_private "Qt::${it}Private")
+ endif()
+ endforeach()
+
+ set(target_private "${target}Private")
+ if(TARGET "${target_private}")
+ target_link_libraries("${target_private}" INTERFACE "${target}" "${qt_libs_private}")
+ endif()
+ qt_register_target_dependencies("${target}"
+ "${arg_PUBLIC_LIBRARIES}"
+ "${qt_libs_private};${arg_LIBRARIES}")
+
+
+ qt_autogen_tools(${target}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS})
+
+ qt_update_precompiled_header("${target}" "${arg_PRECOMPILED_HEADER}")
+ qt_update_ignore_pch_source("${target}" "${arg_NO_PCH_SOURCES}")
+ ## Ignore objective-c files for PCH (not supported atm)
+ qt_ignore_pch_obj_c_sources("${target}" "${arg_SOURCES}")
+
+ else()
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("qt_extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped")
+ endif()
+ endif()
+endfunction()
+
+
+function(qt_internal_library_deprecation_level result)
+ if(WIN32)
+ # On Windows, due to the way DLLs work, we need to export all functions,
+ # including the inlines
+ list(APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x040800")
+ else()
+ # On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
+ list(APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x050000")
+ endif()
+ list(APPEND deprecations "QT_DEPRECATED_WARNINGS_SINCE=0x060000")
+ set("${result}" deprecations PARENT_SCOPE)
+endfunction()
+
+
+function(qt_install_injections target build_dir install_dir)
+ set(injections ${ARGN})
+ set(module "Qt${target}")
+ get_target_property(target_type ${target} TYPE)
+ if (target_type STREQUAL "INTERFACE_LIBRARY")
+ set(is_framework FALSE)
+ else()
+ get_target_property(is_framework ${target} FRAMEWORK)
+ endif()
+ # examples:
+ # SYNCQT.INJECTIONS = src/corelib/global/qconfig.h:qconfig.h:QtConfig src/corelib/global/qconfig_p.h:5.12.0/QtCore/private/qconfig_p.h
+ # SYNCQT.INJECTIONS = src/gui/vulkan/qvulkanfunctions.h:^qvulkanfunctions.h:QVulkanFunctions:QVulkanDeviceFunctions src/gui/vulkan/qvulkanfunctions_p.h:^5.12.0/QtGui/private/qvulkanfunctions_p.h
+ # The are 3 parts to the assignment, divded by colons ':'.
+ # The first part contains a path to a generated file in a build folder.
+ # The second part contains the file name that the forwarding header should have, which points
+ # to the file in the first part.
+ # The third part contains multiple UpperCaseFileNames that should be forwarding headers to the
+ # header specified in the second part.
+ separate_arguments(injections UNIX_COMMAND "${injections}")
+ foreach(injection ${injections})
+ string(REPLACE ":" ";" injection ${injection})
+ # Part 1.
+ list(GET injection 0 file)
+ # Part 2.
+ list(GET injection 1 destination)
+ string(REGEX REPLACE "^\\^" "" destination "${destination}")
+ list(REMOVE_AT injection 0 1)
+ # Part 3.
+ set(fwd_hdrs ${injection})
+ get_filename_component(destinationdir ${destination} DIRECTORY)
+ get_filename_component(destinationname ${destination} NAME)
+ get_filename_component(original_file_name ${file} NAME)
+
+ # This describes a concrete example for easier comprehension:
+ # A file 'qtqml-config.h' is generated by qt_internal_feature_write_file into
+ # ${qtdeclarative_build_dir}/src/{module}/qtqml-config.h (part 1).
+ #
+ # Generate a lower case forwarding header (part 2) 'qtqml-config.h' at the following
+ # location:
+ # ${some_prefix}/include/${module}/qtqml-config.h.
+ #
+ # Inside this file, we #include the originally generated file,
+ # ${qtdeclarative_build_dir}/src/{module}/qtqml-config.h.
+ #
+ # ${some_prefix}'s value depends on the build type.
+ # If doing a prefix build, it should point to
+ # ${current_repo_build_dir} which is ${qtdeclarative_build_dir}.
+ # If doing a non-prefix build, it should point to
+ # ${qtbase_build_dir}.
+ #
+ # In the code below, ${some_prefix} == ${build_dir}.
+ set(lower_case_forwarding_header_path "${build_dir}/${INSTALL_INCLUDEDIR}/${module}")
+ if(destinationdir)
+ string(APPEND lower_case_forwarding_header_path "/${destinationdir}")
+ endif()
+ set(current_repo_build_dir "${PROJECT_BINARY_DIR}")
+
+ file(RELATIVE_PATH relpath
+ "${lower_case_forwarding_header_path}"
+ "${current_repo_build_dir}/${file}")
+ set(main_contents "#include \"${relpath}\"")
+ file(GENERATE OUTPUT "${lower_case_forwarding_header_path}/${original_file_name}"
+ CONTENT "${main_contents}")
+
+ if(is_framework)
+ if(file MATCHES "_p\\.h$")
+ set(header_type PRIVATE)
+ else()
+ set(header_type PUBLIC)
+ endif()
+ qt_copy_framework_headers(${target} ${header_type}
+ ${current_repo_build_dir}/${file})
+ else()
+ # Copy the actual injected (generated) header file (not the just created forwarding one)
+ # to its install location when doing a prefix build. In an non-prefix build, the qt_install
+ # will be a no-op.
+ qt_path_join(install_destination
+ ${install_dir} ${INSTALL_INCLUDEDIR} ${module} ${destinationdir})
+ qt_install(FILES ${current_repo_build_dir}/${file}
+ DESTINATION ${install_destination}
+ RENAME ${destinationname} OPTIONAL)
+ endif()
+
+ # Generate UpperCaseNamed forwarding headers (part 3).
+ foreach(fwd_hdr ${fwd_hdrs})
+ set(upper_case_forwarding_header_path "${INSTALL_INCLUDEDIR}/${module}")
+ if(destinationdir)
+ string(APPEND upper_case_forwarding_header_path "/${destinationdir}")
+ endif()
+
+ # Generate upper case forwarding header like QVulkanFunctions or QtConfig.
+ file(GENERATE OUTPUT "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
+ CONTENT "#include \"${destinationname}\"\n")
+
+ if(is_framework)
+ # Copy the forwarding header to the framework's Headers directory.
+ qt_copy_framework_headers(${target} PUBLIC
+ "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}")
+ else()
+ # Install the forwarding header.
+ qt_path_join(install_destination
+ ${install_dir} ${upper_case_forwarding_header_path})
+ qt_install(FILES "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
+ DESTINATION ${install_destination} OPTIONAL)
+ endif()
+ endforeach()
+ endforeach()
+endfunction()
+
+
+function(qt_read_headers_pri target resultVarPrefix)
+ qt_internal_module_info(module "${target}")
+ file(STRINGS "${module_include_dir}/headers.pri" headers_pri_contents)
+ foreach(line ${headers_pri_contents})
+ if("${line}" MATCHES "SYNCQT.HEADER_FILES = (.*)")
+ set(public_module_headers "${CMAKE_MATCH_1}")
+ separate_arguments(public_module_headers UNIX_COMMAND "${public_module_headers}")
+ elseif("${line}" MATCHES "SYNCQT.PRIVATE_HEADER_FILES = (.*)")
+ set(private_module_headers "${CMAKE_MATCH_1}")
+ separate_arguments(private_module_headers UNIX_COMMAND "${private_module_headers}")
+ elseif("${line}" MATCHES "SYNCQT.GENERATED_HEADER_FILES = (.*)")
+ set(generated_module_headers "${CMAKE_MATCH_1}")
+ separate_arguments(generated_module_headers UNIX_COMMAND "${generated_module_headers}")
+ foreach(generated_header ${generated_module_headers})
+ list(APPEND public_module_headers "${module_include_dir}/${generated_header}")
+ endforeach()
+ elseif("${line}" MATCHES "SYNCQT.INJECTIONS = (.*)")
+ set(injections "${CMAKE_MATCH_1}")
+ elseif("${line}" MATCHES "SYNCQT.([A-Z_]+)_HEADER_FILES = (.+)")
+ set(prefix "${CMAKE_MATCH_1}")
+ string(TOLOWER "${prefix}" prefix)
+ set(entries "${CMAKE_MATCH_2}")
+ separate_arguments(entries UNIX_COMMAND "${entries}")
+ set("${resultVarPrefix}_${prefix}" "${entries}" PARENT_SCOPE)
+ endif()
+ endforeach()
+ set(${resultVarPrefix}_public "${public_module_headers}" PARENT_SCOPE)
+ set(${resultVarPrefix}_private "${private_module_headers}" PARENT_SCOPE)
+ set(${resultVarPrefix}_injections "${injections}" PARENT_SCOPE)
+endfunction()
+
+
+# Add Qt::target and Qt6::target as aliases for the target
+function(qt_internal_add_target_aliases target)
+ get_target_property(type "${target}" TYPE)
+ if (type STREQUAL EXECUTABLE)
+ add_executable("Qt::${target}" ALIAS "${target}")
+ add_executable("Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}")
+ else()
+ add_library("Qt::${target}" ALIAS "${target}")
+ add_library("Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}")
+ endif()
+endfunction()
+
+# Sets the exceptions flags for the given target
+function(qt_internal_set_no_exceptions_flags target)
+ target_compile_definitions("${target}" PRIVATE "QT_NO_EXCEPTIONS")
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ target_compile_options("${target}" PRIVATE "/wd4530" "/wd4577")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+ target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+ target_compile_options("${target}" PRIVATE "-fno-exceptions")
+ endif()
+endfunction()
+
+function(qt_skip_warnings_are_errors target)
+ get_target_property(target_type "${target}" TYPE)
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ return()
+ endif()
+ set_target_properties("${target}" PROPERTIES QT_SKIP_WARNINGS_ARE_ERRORS ON)
+endfunction()
+
+function(qt_skip_warnings_are_errors_when_repo_unclean target)
+ if(QT_REPO_NOT_WARNINGS_CLEAN)
+ qt_skip_warnings_are_errors("${target}")
+ endif()
+endfunction()
+
+function(qt_get_sanitized_plugin_type plugin_type out_var)
+ # Used to handle some edge cases such as platforms/darwin
+ string(REGEX REPLACE "[-/]" "_" plugin_type "${plugin_type}")
+ set("${out_var}" "${plugin_type}" PARENT_SCOPE)
+endfunction()
+
+# Copy header files to QtXYZ.framework/Versions/6/Headers/
+# Use this function for header files that
+# - are not added as source files to the target
+# - are not marked as PUBLIC_HEADER
+# - or are private and supposed to end up in the 6.7.8/QtXYZ/private subdir.
+function(qt_copy_framework_headers target)
+ get_target_property(is_fw ${target} FRAMEWORK)
+ if(NOT "${is_fw}")
+ return()
+ endif()
+
+ set(options PUBLIC PRIVATE QPA)
+ set(oneValueArgs)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ get_target_property(fw_version ${target} FRAMEWORK_VERSION)
+ get_target_property(fw_bundle_version ${target} MACOSX_FRAMEWORK_BUNDLE_VERSION)
+ get_target_property(fw_dir ${target} LIBRARY_OUTPUT_DIRECTORY)
+ get_target_property(fw_name ${target} OUTPUT_NAME)
+ set(fw_headers_dir ${fw_dir}/${fw_name}.framework/Versions/${fw_version}/Headers/)
+ if(ARG_PRIVATE)
+ string(APPEND fw_headers_dir "${fw_bundle_version}/Qt${target}/private/")
+ elseif(ARG_QPA)
+ string(APPEND fw_headers_dir "${fw_bundle_version}/Qt${target}/qpa/")
+ endif()
+
+ set(out_files)
+ foreach(hdr IN LISTS ARG_UNPARSED_ARGUMENTS)
+ get_filename_component(in_file_path ${hdr} ABSOLUTE)
+ get_filename_component(in_file_name ${hdr} NAME)
+ set(out_file_path ${fw_headers_dir}${in_file_name})
+ add_custom_command(
+ OUTPUT ${out_file_path}
+ DEPENDS ${in_file_path}
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${fw_headers_dir}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${in_file_path}" "${fw_headers_dir}")
+ list(APPEND out_files ${out_file_path})
+ endforeach()
+
+ get_target_property(fw_copied_headers ${target} QT_COPIED_FRAMEWORK_HEADERS)
+ if(NOT fw_copied_headers)
+ set(fw_copied_headers "")
+ endif()
+ list(APPEND fw_copied_headers ${out_files})
+ set_target_properties(${target} PROPERTIES QT_COPIED_FRAMEWORK_HEADERS "${fw_copied_headers}")
+endfunction()
+
+function(qt_finalize_framework_headers_copy target)
+ get_target_property(target_type ${target} TYPE)
+ if(${target_type} STREQUAL "INTERFACE_LIBRARY")
+ return()
+ endif()
+ get_target_property(is_fw ${target} FRAMEWORK)
+ if(NOT "${is_fw}")
+ return()
+ endif()
+ get_target_property(headers ${target} QT_COPIED_FRAMEWORK_HEADERS)
+ if(headers)
+ # Hack to create the "Headers" symlink in the framework:
+ # Create a fake header file and copy it into the framework by marking it as PUBLIC_HEADER.
+ # CMake now takes care of creating the symlink.
+ set(fake_header ${target}_fake_header.h)
+ qt_get_main_cmake_configuration(main_config)
+ file(GENERATE OUTPUT ${fake_header} CONTENT "// ignore this file\n"
+ CONDITION "$<CONFIG:${main_config}>")
+ string(PREPEND fake_header "${CMAKE_CURRENT_BINARY_DIR}/")
+ target_sources(${target} PRIVATE ${fake_header})
+ set_source_files_properties(${fake_header} PROPERTIES GENERATED ON)
+ set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER ${fake_header})
+
+ # Add a target, e.g. Core_framework_headers, that triggers the header copy.
+ add_custom_target(${target}_framework_headers DEPENDS ${headers})
+ add_dependencies(${target} ${target}_framework_headers)
+ endif()
+endfunction()
+
+function(qt_clone_property_for_configs target property configs)
+ get_target_property(value "${target}" "${property}")
+ foreach(config ${configs})
+ string(TOUPPER "${config}" upper_config)
+ set_property(TARGET "${target}" PROPERTY "${property}_${upper_config}" "${value}")
+ endforeach()
+endfunction()
+
+function(qt_handle_multi_config_output_dirs target)
+ set(possible_configs "${CMAKE_BUILD_TYPE}")
+ if(CMAKE_CONFIGURATION_TYPES)
+ set(possible_configs "${CMAKE_CONFIGURATION_TYPES}")
+ endif()
+ qt_clone_property_for_configs(${target} LIBRARY_OUTPUT_DIRECTORY "${possible_configs}")
+ qt_clone_property_for_configs(${target} RUNTIME_OUTPUT_DIRECTORY "${possible_configs}")
+ qt_clone_property_for_configs(${target} ARCHIVE_OUTPUT_DIRECTORY "${possible_configs}")
+endfunction()
+
+# This is the main entry function for creating a Qt module, that typically
+# consists of a library, public header files, private header files and configurable
+# features.
+#
+# A CMake target with the specified target parameter is created. If the current source
+# directory has a configure.cmake file, then that is also processed for feature definition
+# and testing. Any features defined as well as any features coming from dependencies to
+# this module are imported into the scope of the calling feature.
+#
+# Target is without leading "Qt". So e.g. the "QtCore" module has the target "Core".
+function(qt_add_module target)
+ qt_internal_module_info(module "${target}")
+
+ # Process arguments:
+ qt_parse_all_arguments(arg "qt_add_module"
+ "NO_MODULE_HEADERS;STATIC;DISABLE_TOOLS_EXPORT;EXCEPTIONS;INTERNAL_MODULE;NO_SYNC_QT;NO_PRIVATE_MODULE;HEADER_MODULE;GENERATE_METATYPES"
+ "CONFIG_MODULE_NAME;PRECOMPILED_HEADER"
+ "${__default_private_args};${__default_public_args};QMAKE_MODULE_CONFIG;EXTRA_CMAKE_FILES;EXTRA_CMAKE_INCLUDES;NO_PCH_SOURCES" ${ARGN})
+
+ if(NOT DEFINED arg_CONFIG_MODULE_NAME)
+ set(arg_CONFIG_MODULE_NAME "${module_lower}")
+ endif()
+
+ qt_internal_add_qt_repo_known_module("${target}")
+
+ ### Define Targets:
+ set(is_interface_lib 0)
+ if(${arg_HEADER_MODULE})
+ add_library("${target}" INTERFACE)
+ set(is_interface_lib 1)
+ elseif(${arg_STATIC})
+ add_library("${target}" STATIC)
+ elseif(${QT_BUILD_SHARED_LIBS})
+ add_library("${target}" SHARED)
+ else()
+ add_library("${target}" STATIC)
+ endif()
+
+ set(is_framework 0)
+ if(QT_FEATURE_framework AND NOT ${arg_HEADER_MODULE} AND NOT ${arg_STATIC})
+ set(is_framework 1)
+ set_target_properties(${target} PROPERTIES
+ FRAMEWORK TRUE
+ FRAMEWORK_VERSION ${PROJECT_VERSION_MAJOR}
+ MACOSX_FRAMEWORK_IDENTIFIER org.qt-project.Qt${target}
+ MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
+ MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
+ )
+ endif()
+
+ if (ANDROID)
+ qt_android_apply_arch_suffix("${target}")
+ endif()
+ qt_internal_add_target_aliases("${target}")
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
+
+ # Add _private target to link against the private headers:
+ if(NOT ${arg_NO_PRIVATE_MODULE})
+ set(target_private "${target}Private")
+ add_library("${target_private}" INTERFACE)
+ qt_internal_add_target_aliases("${target_private}")
+ endif()
+
+ if(NOT arg_HEADER_MODULE)
+ set_target_properties(${target} PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
+ RUNTIME_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
+ VERSION ${PROJECT_VERSION}
+ SOVERSION ${PROJECT_VERSION_MAJOR}
+ )
+ qt_handle_multi_config_output_dirs("${target}")
+
+ if(is_framework)
+ set_target_properties(${target} PROPERTIES
+ OUTPUT_NAME Qt${target}
+ )
+ else()
+ set_target_properties(${target} PROPERTIES
+ OUTPUT_NAME "${INSTALL_CMAKE_NAMESPACE}${target}"
+ )
+ endif()
+ endif()
+
+ # Module headers:
+ if(${arg_NO_MODULE_HEADERS} OR ${arg_NO_SYNC_QT})
+ set_target_properties("${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS OFF)
+ else()
+ # Use QT_BUILD_DIR for the syncqt call.
+ # So we either write the generated files into the qtbase non-prefix build root, or the
+ # module specific build root.
+ qt_ensure_sync_qt()
+ set(syncqt_full_command "${HOST_PERL}" -w "${QT_SYNCQT}"
+ -quiet
+ -check-includes
+ -module "${module}"
+ -version "${PROJECT_VERSION}"
+ -outdir "${QT_BUILD_DIR}"
+ -builddir "${PROJECT_BINARY_DIR}"
+ "${PROJECT_SOURCE_DIR}")
+ execute_process(COMMAND ${syncqt_full_command})
+
+ set_target_properties("${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS ON)
+
+ ### FIXME: Can we replace headers.pri?
+ qt_read_headers_pri("${target}" "module_headers")
+ set(module_depends_header "${module_include_dir}/${module}Depends")
+ if(is_framework)
+ if(NOT is_interface_lib)
+ set(public_headers_to_copy "${module_headers_public}" "${module_depends_header}")
+ qt_copy_framework_headers(${target} PUBLIC "${public_headers_to_copy}")
+ qt_copy_framework_headers(${target} PRIVATE "${module_headers_private}")
+ endif()
+ else()
+ set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}")
+ set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER ${module_depends_header})
+ set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}")
+ endif()
+ if (NOT ${arg_HEADER_MODULE})
+ set_property(TARGET "${target}" PROPERTY MODULE_HEADER "${module_include_dir}/${module}")
+ endif()
+
+ if(module_headers_qpa)
+ if(is_framework)
+ qt_copy_framework_headers(${target} QPA "${module_headers_qpa}")
+ else()
+ qt_install(
+ FILES ${module_headers_qpa}
+ DESTINATION ${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}/${module}/qpa)
+ endif()
+ endif()
+ endif()
+
+ if(NOT arg_HEADER_MODULE)
+ # This property is used for super builds with static libraries. We use
+ # it in QtPlugins.cmake.in to avoid "polluting" the dependency chain
+ # for the target in it's project directory.
+ # E.g: When we process find_package(Qt6 ... Gui) in QtDeclarative, the
+ # rules in QtPugins.cmake add all the known Gui plugins as interface
+ # dependencies. This in turn causes circular dependencies on every
+ # plugin which links against Gui. Plugin A -> GUI -> Plugin A ....
+
+ set_target_properties(${target} PROPERTIES QT_BUILD_PROJECT_NAME ${PROJECT_NAME})
+ # Plugin types associated to a module
+ if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x")
+ # Reset the variable containing the list of plugins for the given plugin type
+ foreach(plugin_type ${arg_PLUGIN_TYPES})
+ qt_get_sanitized_plugin_type("${plugin_type}" plugin_type)
+ set_property(TARGET "${target}" APPEND PROPERTY MODULE_PLUGIN_TYPES "${plugin_type}")
+ qt_internal_add_qt_repo_known_plugin_types("${plugin_type}")
+ endforeach()
+ endif()
+ endif()
+
+ qt_internal_library_deprecation_level(deprecation_define)
+
+ if(NOT arg_HEADER_MODULE)
+ qt_autogen_tools_initial_setup(${target})
+ endif()
+
+ set(private_includes
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
+ ${arg_INCLUDE_DIRECTORIES}
+ )
+
+ set(public_includes "")
+ set(public_headers_list "public_includes")
+ if(is_framework)
+ set(public_headers_list "private_includes")
+ set(fw_bundle_subdir "${INSTALL_LIBDIR}/Qt${target}.framework")
+ set(fw_headers_subdir "Versions/${PROJECT_VERSION_MAJOR}/Headers")
+ list(APPEND public_includes
+ # Add the lib/Foo.framework dir as include path to let CMake generate
+ # the -F compiler flag.
+ "$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}>"
+ "$<INSTALL_INTERFACE:${fw_bundle_subdir}>"
+
+ # Add the fully resolved Headers subdir, because the Headers symlink might
+ # not be there yet.
+ "$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}/${fw_headers_subdir}>"
+
+ # After installing, the Headers symlink is guaranteed to exist.
+ "$<INSTALL_INTERFACE:${fw_bundle_subdir}/Headers>"
+ )
+ endif()
+
+ # Handle cases like QmlDevTools which do not have their own headers, but rather borrow them
+ # from another module.
+ if(NOT arg_NO_SYNC_QT AND NOT arg_NO_MODULE_HEADERS)
+ # Don't include private headers unless they exist, aka syncqt created them.
+ if(module_headers_private)
+ list(APPEND private_includes
+ "$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}>"
+ "$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")
+ endif()
+
+ list(APPEND ${public_headers_list}
+ # For the syncqt headers
+ "$<BUILD_INTERFACE:${module_repo_include_dir}>"
+ "$<BUILD_INTERFACE:${module_include_dir}>")
+ endif()
+
+ if(NOT arg_NO_MODULE_HEADERS AND NOT arg_NO_SYNC_QT)
+ # For the syncqt headers
+ list(APPEND ${public_headers_list} "$<INSTALL_INTERFACE:include/${module}>")
+ endif()
+ list(APPEND ${public_headers_list} ${arg_PUBLIC_INCLUDE_DIRECTORIES})
+
+ set(header_module)
+ if(arg_HEADER_MODULE)
+ set(header_module "HEADER_MODULE")
+ endif()
+
+ qt_extend_target("${target}"
+ ${header_module}
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ ${private_includes}
+ PUBLIC_INCLUDE_DIRECTORIES
+ ${public_includes}
+ PUBLIC_DEFINES
+ ${arg_PUBLIC_DEFINES}
+ QT_${module_define}_LIB
+ DEFINES
+ ${arg_DEFINES}
+ QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS
+ QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code
+ QT_USE_QSTRINGBUILDER
+ QT_DEPRECATED_WARNINGS
+ QT_BUILDING_QT
+ QT_BUILD_${module_define}_LIB ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
+ "${deprecation_define}"
+ PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
+ LIBRARIES ${arg_LIBRARIES} Qt::PlatformModuleInternal
+ FEATURE_DEPENDENCIES ${arg_FEATURE_DEPENDENCIES}
+ DBUS_ADAPTOR_SOURCES ${arg_DBUS_ADAPTOR_SOURCES}
+ DBUS_ADAPTOR_FLAGS ${arg_DBUS_ADAPTOR_FLAGS}
+ DBUS_INTERFACE_SOURCES ${arg_DBUS_INTERFACE_SOURCES}
+ DBUS_INTERFACE_FLAGS ${arg_DBUS_INTERFACE_FLAGS}
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ PUBLIC_LINK_OPTIONS ${arg_PUBLIC_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
+ PRECOMPILED_HEADER ${arg_PRECOMPILED_HEADER}
+ NO_PCH_SOURCES ${arg_NO_PCH_SOURCES}
+ )
+
+ if(NOT ${arg_EXCEPTIONS} AND NOT ${arg_HEADER_MODULE})
+ qt_internal_set_no_exceptions_flags("${target}")
+ endif()
+
+ set(configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
+ if(EXISTS "${configureFile}")
+ qt_feature_module_begin(
+ LIBRARY "${target}"
+ PUBLIC_FILE "qt${arg_CONFIG_MODULE_NAME}-config.h"
+ PRIVATE_FILE "qt${arg_CONFIG_MODULE_NAME}-config_p.h"
+ PUBLIC_DEPENDENCIES ${arg_FEATURE_DEPENDENCIES}
+ PRIVATE_DEPENDENCIES ${arg_FEATURE_DEPENDENCIES}
+ )
+ include(${configureFile})
+ qt_feature_module_end("${target}")
+
+ set_property(TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config.h")
+ set_property(TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config_p.h")
+ endif()
+
+ if(NOT arg_HEADER_MODULE)
+ if(DEFINED module_headers_private)
+ qt_internal_add_linker_version_script("${target}" PRIVATE_HEADERS ${module_headers_private} ${module_headers_qpa})
+ else()
+ qt_internal_add_linker_version_script("${target}")
+ endif()
+ endif()
+
+ # Handle injections. Aka create forwarding headers for certain headers that have been
+ # automatically generated in the build dir (for example qconfig.h, qtcore-config.h,
+ # qvulkanfunctions.h, etc)
+ # module_headers_injections come from the qt_read_headers_pri() call.
+ # extra_library_injections come from the qt_feature_module_end() call.
+ set(final_injections "")
+ if(module_headers_injections)
+ string(APPEND final_injections "${module_headers_injections} ")
+ endif()
+ if(extra_library_injections)
+ string(APPEND final_injections "${extra_library_injections} ")
+ endif()
+
+ if(final_injections)
+ qt_install_injections(${target} "${QT_BUILD_DIR}" "${QT_INSTALL_DIR}" ${final_injections})
+ endif()
+
+ # Handle creation of cmake files for consumers of find_package().
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ set(extra_cmake_files)
+ set(extra_cmake_includes)
+ if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
+ list(APPEND extra_cmake_files "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
+ list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
+ endif()
+ if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in")
+ configure_file("${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake"
+ @ONLY)
+ list(APPEND extra_cmake_files "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake")
+ list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake")
+ endif()
+
+ foreach(cmake_file IN LISTS arg_EXTRA_CMAKE_FILES)
+ get_filename_component(basename ${cmake_file} NAME)
+ file(COPY ${cmake_file} DESTINATION ${config_build_dir})
+ list(APPEND extra_cmake_files "${config_build_dir}/${basename}")
+ endforeach()
+ list(APPEND extra_cmake_includes ${arg_EXTRA_CMAKE_INCLUDES})
+
+ set(extra_cmake_code "")
+
+ if(target STREQUAL Core)
+ # Propagate non-build related variables that are needed for consuming Qt packages.
+ # Do this in CoreConfig instead of Qt6Config, so that consumers can also use
+ # find_package(Qt6Core) instead of find_package(Qt6 COMPONENTS Core)
+ string(APPEND extra_cmake_code "
+set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
+ endif()
+
+ # Generate metatypes
+ set(QT_MODULE_HAS_META_TYPES_FILE FALSE)
+ if (${arg_GENERATE_METATYPES})
+ set(QT_MODULE_HAS_META_TYPES_FILE TRUE)
+ set(metatypes_install_dir ${INSTALL_LIBDIR}/metatypes)
+ set(args)
+ if (NOT QT_WILL_INSTALL)
+ set(args COPY_OVER_INSTALL INSTALL_DIR "${QT_BUILD_DIR}/${metatypes_install_dir}")
+ else()
+ set(args INSTALL_DIR "${metatypes_install_dir}")
+ endif()
+ qt6_generate_meta_types_json_file(${target} ${args})
+ get_target_property(QT_MODULE_META_TYPES_FILE ${target} INTERFACE_QT_META_TYPES_INSTALL_FILE)
+ get_target_property(QT_MODULE_META_TYPES_DEP_FILE ${target} INTERFACE_QT_META_TYPES_INSTALL_DEP_FILE)
+ endif()
+ configure_package_config_file(
+ "${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+ write_basic_package_version_file(
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
+ ${extra_cmake_files}
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ file(COPY ${extra_cmake_files} DESTINATION "${config_build_dir}")
+ set(exported_targets ${target})
+ if(NOT ${arg_NO_PRIVATE_MODULE})
+ list(APPEND exported_targets ${target_private})
+ endif()
+ set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
+ qt_install(TARGETS ${exported_targets}
+ EXPORT ${export_name}
+ RUNTIME DESTINATION ${INSTALL_BINDIR}
+ LIBRARY DESTINATION ${INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${INSTALL_LIBDIR}
+ FRAMEWORK DESTINATION ${INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}
+ PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}/${module}/private
+ )
+
+ if (ANDROID AND NOT arg_HEADER_MODULE)
+ # Record install library location so it can be accessed by
+ # qt_android_dependencies without having to specify it again.
+ set_target_properties(${target} PROPERTIES
+ QT_ANDROID_MODULE_INSTALL_DIR ${INSTALL_LIBDIR})
+ endif()
+
+ qt_install(EXPORT ${export_name}
+ NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
+ DESTINATION ${config_install_dir})
+
+ qt_internal_export_modern_cmake_config_targets_file(
+ TARGETS ${exported_targets}
+ EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
+ CONFIG_INSTALL_DIR "${config_install_dir}")
+
+ if (${arg_INTERNAL_MODULE})
+ set(arg_INTERNAL_MODULE "INTERNAL_MODULE")
+ else()
+ unset(arg_INTERNAL_MODULE)
+ endif()
+
+ qt_path_join(pri_target_path ${PROJECT_BINARY_DIR} ${INSTALL_MKSPECSDIR}/modules)
+ qt_generate_module_pri_file("${target}" "${pri_target_path}" module_pri_files
+ ${arg_INTERNAL_MODULE}
+ ${header_module}
+ QMAKE_MODULE_CONFIG
+ ${arg_QMAKE_MODULE_CONFIG}
+ )
+ qt_install(FILES "${module_pri_files}" DESTINATION ${INSTALL_MKSPECSDIR}/modules)
+
+ ### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
+ # that belong to Qt.
+ if(NOT arg_HEADER_MODULE)
+ qt_internal_add_link_flags_no_undefined("${target}")
+ endif()
+
+ set(interface_includes "")
+
+ # Handle cases like QmlDevTools which do not have their own headers, but rather borrow them
+ # from another module.
+ if(NOT arg_NO_SYNC_QT)
+ list(APPEND interface_includes
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
+ "$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}>"
+ "$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")
+
+ if(NOT arg_NO_MODULE_HEADERS)
+ if(is_framework)
+ set(fw_headers_dir
+ "${INSTALL_LIBDIR}/${module}.framework/Headers/")
+ list(APPEND interface_includes
+ "$<INSTALL_INTERFACE:${fw_headers_dir}${PROJECT_VERSION}>"
+ "$<INSTALL_INTERFACE:${fw_headers_dir}${PROJECT_VERSION}/${module}>")
+ else()
+ list(APPEND interface_includes
+ "$<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}>"
+ "$<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}/${module}>")
+ endif()
+ endif()
+ endif()
+
+ if(NOT ${arg_NO_PRIVATE_MODULE})
+ target_include_directories("${target_private}" INTERFACE ${interface_includes})
+ endif()
+
+ if(is_framework AND NOT is_interface_lib)
+ qt_finalize_framework_headers_copy(${target})
+ endif()
+
+ qt_describe_module(${target})
+
+endfunction()
+
+function(qt_export_tools module_name)
+ # If no tools were defined belonging to this module, don't create a config and targets file.
+ # Guards against the case when doing a cross-build.
+
+ if(NOT "${module_name}" IN_LIST QT_KNOWN_MODULES_WITH_TOOLS OR CMAKE_CROSSCOMPILING)
+ return()
+ endif()
+
+ # The tools target name. For example: CoreTools
+ set(target "${module_name}Tools")
+
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ # Add the extra cmake statements to make the tool targets global, so it doesn't matter where
+ # find_package is called.
+ # Also assemble a list of tool targets to expose in the config file for informational purposes.
+ set(extra_cmake_statements "")
+ set(tool_targets "")
+ set(tool_targets_non_prefixed "")
+
+ # List of package dependencies that need be find_package'd when using the Tools package.
+ set(package_deps "")
+
+ foreach(tool_name ${QT_KNOWN_MODULE_${module_name}_TOOLS})
+ # Specific tools can have package dependencies.
+ # e.g. qtwaylandscanner depends on WaylandScanner (non-qt package).
+ get_target_property(extra_packages "${tool_name}" QT_EXTRA_PACKAGE_DEPENDENCIES)
+ if(extra_packages)
+ list(APPEND package_deps "${extra_packages}")
+ endif()
+
+ set(extra_cmake_statements "${extra_cmake_statements}
+if (NOT QT_NO_CREATE_TARGETS)
+ get_property(is_global TARGET ${INSTALL_CMAKE_NAMESPACE}::${tool_name} PROPERTY IMPORTED_GLOBAL)
+ if(NOT is_global)
+ set_property(TARGET ${INSTALL_CMAKE_NAMESPACE}::${tool_name} PROPERTY IMPORTED_GLOBAL TRUE)
+ endif()
+endif()
+")
+ list(APPEND tool_targets "${QT_CMAKE_EXPORT_NAMESPACE}::${tool_name}")
+ list(APPEND tool_targets_non_prefixed "${tool_name}")
+ endforeach()
+
+ string(APPEND extra_cmake_statements
+"set(${QT_CMAKE_EXPORT_NAMESPACE}${module_name}Tools_TARGETS \"${tool_targets}\")")
+
+ # Extract package dependencies that were determined in QtPostProcess, but only if ${module_name}
+ # is an actual target.
+ # module_name can be a non-existent target, if the tool doesn't have an existing associated
+ # module, e.g. qtwaylandscanner.
+ if(TARGET "${module_name}")
+ get_target_property(module_package_deps "${module_name}" _qt_tools_package_deps)
+ if(module_package_deps)
+ list(APPEND package_deps "${module_package_deps}")
+ endif()
+ endif()
+
+ # Configure and install dependencies file for the ${module_name}Tools package.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtModuleToolsDependencies.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ @ONLY
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ # Configure and install the ${module_name}Tools package Config file.
+ configure_package_config_file(
+ "${QT_CMAKE_DIR}/QtModuleToolsConfig.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+ write_basic_package_version_file(
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
+ qt_install(EXPORT "${export_name}"
+ NAMESPACE "${QT_CMAKE_EXPORT_NAMESPACE}::"
+ DESTINATION "${config_install_dir}")
+
+
+ # Create versionless targets file.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtModuleToolsVersionlessTargets.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}VersionlessTargets.cmake"
+ @ONLY
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}VersionlessTargets.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+endfunction()
+
+# This function records a dependency between ${target_name} and ${dep_package_name}.
+# at the CMake package level.
+# E.g. The Tools package that provides the qtwaylandscanner target
+# needs to call find_package(WaylandScanner) (non-qt-package).
+# main_target_name = qtwaylandscanner
+# dep_package_name = WaylandScanner
+function(qt_record_extra_package_dependency main_target_name dep_package_name dep_package_version)
+ get_target_property(extra_packages "${main_target_name}" QT_EXTRA_PACKAGE_DEPENDENCIES)
+ if(NOT extra_packages)
+ set(extra_packages "")
+ endif()
+
+ list(APPEND extra_packages "${dep_package_name}\;${dep_package_version}")
+ set_target_properties("${main_target_name}" PROPERTIES QT_EXTRA_PACKAGE_DEPENDENCIES
+ "${extra_packages}")
+endfunction()
+
+# This function records a dependency between ${main_target_name} and ${dep_target_name}
+# at the CMake package level.
+# E.g. Qt6CoreConfig.cmake needs to find_package(Qt6WinMain).
+# main_target_name = Core
+# dep_target_name = WinMain
+# This is just a convenience function that deals with Qt targets and their associated packages
+# instead of raw package names.
+function(qt_record_extra_qt_package_dependency main_target_name dep_target_name
+ dep_package_version)
+ # WinMain -> Qt6WinMain.
+ qt_internal_module_info(qtfied_target_name "${dep_target_name}")
+ qt_record_extra_package_dependency("${main_target_name}" "${qtfied_target_name_versioned}"
+ "${dep_package_version}")
+endfunction()
+
+function(qt_internal_check_directory_or_type name dir type default result_var)
+ if ("x${dir}" STREQUAL x)
+ if("x${type}" STREQUAL x)
+ message(FATAL_ERROR "qt_add_plugin called without setting either TYPE or ${name}.")
+ endif()
+ set(${result_var} "${default}" PARENT_SCOPE)
+ else()
+ set(${result_var} "${dir}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Utility function to find the module to which a plug-in belongs.
+# This will set the QT_MODULE target property on the plug-in - e.g. "Gui", "Sql"...
+function(qt_get_module_for_plugin target target_type)
+ qt_internal_get_qt_all_known_modules(known_modules)
+
+ qt_get_sanitized_plugin_type("${target_type}" target_type)
+ foreach(qt_module ${known_modules})
+ get_target_property(module_type "${QT_CMAKE_EXPORT_NAMESPACE}::${qt_module}" TYPE)
+ # Assuming interface libraries can't have plugins. Otherwise we'll need to fix the property
+ # name, because the current one would be invalid for interface libraries.
+ if(module_type STREQUAL "INTERFACE_LIBRARY")
+ continue()
+ endif()
+
+ get_target_property(plugin_types
+ "${QT_CMAKE_EXPORT_NAMESPACE}::${qt_module}"
+ MODULE_PLUGIN_TYPES)
+ if(plugin_types)
+ foreach(plugin_type ${plugin_types})
+ if("${target_type}" STREQUAL "${plugin_type}")
+ set_target_properties("${target}" PROPERTIES QT_MODULE "${qt_module}")
+ return()
+ endif()
+ endforeach()
+ endif()
+ endforeach()
+ message(AUTHOR_WARNING "The plug-in '${target}' does not belong to any Qt module.")
+endfunction()
+
+
+# Collection of qt_add_plugin arguments so they can be shared across different
+# plugin type wrappers
+set(__qt_add_plugin_optional_args
+ "STATIC;EXCEPTIONS;ALLOW_UNDEFINED_SYMBOLS"
+)
+set(__qt_add_plugin_single_args
+ "TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY;QML_TARGET_PATH;OUTPUT_NAME"
+)
+set(__qt_add_plugin_multi_args
+ "${__default_private_args};${__default_public_args};DEFAULT_IF"
+)
+# This is the main entry point for defining Qt plugins.
+# A CMake target is created with the given target. The TYPE parameter is needed to place the
+# plugin into the correct plugins/ sub-directory.
+function(qt_add_plugin target)
+ qt_internal_module_info(module "${target}")
+
+ qt_internal_set_qt_known_plugins("${QT_KNOWN_PLUGINS}" "${target}")
+
+ qt_parse_all_arguments(arg "qt_add_plugin"
+ "${__qt_add_plugin_optional_args};SKIP_INSTALL"
+ "${__qt_add_plugin_single_args}"
+ "${__qt_add_plugin_multi_args}"
+ "${ARGN}"
+ )
+
+ qt_get_sanitized_plugin_type("${arg_TYPE}" arg_TYPE)
+
+ set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}")
+ set(install_directory_default "${INSTALL_PLUGINSDIR}/${arg_TYPE}")
+ set(archive_install_directory_default "${INSTALL_LIBDIR}/${arg_TYPE}")
+
+ if (arg_QML_TARGET_PATH)
+ set(target_path "${arg_QML_TARGET_PATH}")
+ set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${target_path}")
+ set(install_directory_default "${INSTALL_QMLDIR}/${target_path}")
+ set(archive_install_directory_default "${INSTALL_QMLDIR}/${target_path}")
+ endif()
+
+ # Derive the class name from the target name if it's not explicitly specified.
+ # Don't set it for qml plugins though.
+ set(plugin_class_name "")
+ if (NOT arg_CLASS_NAME AND NOT "${arg_TYPE}" STREQUAL "qml_plugin")
+ set(plugin_class_name "${target}")
+ endif()
+
+ qt_internal_check_directory_or_type(OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" "${arg_TYPE}"
+ "${output_directory_default}" output_directory)
+ if (NOT arg_SKIP_INSTALL)
+ qt_internal_check_directory_or_type(INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" "${arg_TYPE}"
+ "${install_directory_default}" install_directory)
+ if (NOT arg_ARCHIVE_INSTALL_DIRECTORY AND arg_INSTALL_DIRECTORY)
+ set(arg_ARCHIVE_INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}")
+ endif()
+ endif()
+
+ if(arg_STATIC OR NOT BUILD_SHARED_LIBS)
+ add_library("${target}" STATIC)
+ else()
+ add_library("${target}" MODULE)
+ if(APPLE)
+ # CMake defaults to using .so extensions for loadable modules, aka plugins,
+ # but Qt plugins are actually suffixed with .dylib.
+ set_property(TARGET "${target}" PROPERTY SUFFIX ".dylib")
+ endif()
+ endif()
+
+ # Make sure the Qt6 plugin library names are like they were in Qt5 qmake land.
+ # Whereas the Qt6 CMake target names are like the Qt5 CMake target names.
+ set(output_name "${target}")
+ if(arg_OUTPUT_NAME)
+ set(output_name "${arg_OUTPUT_NAME}")
+ endif()
+ set_property(TARGET "${target}" PROPERTY OUTPUT_NAME "${output_name}")
+
+ # Add a custom target with the Qt5 qmake name for a more user friendly ninja experience.
+ if(arg_OUTPUT_NAME AND NOT TARGET "${output_name}")
+ add_custom_target("${output_name}")
+ add_dependencies("${output_name}" "${target}")
+ endif()
+
+ if (ANDROID)
+ qt_android_apply_arch_suffix("${target}")
+ set_target_properties(${target}
+ PROPERTIES
+ LIBRARY_OUTPUT_NAME "plugins_${arg_TYPE}_${output_name}"
+ )
+ endif()
+ qt_internal_add_target_aliases("${target}")
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
+
+ # Disable linking of plugins against other plugins during static regular and
+ # super builds. The latter causes cyclic dependencies otherwise.
+ set_target_properties(${target} PROPERTIES QT_DEFAULT_PLUGINS 0)
+
+ set_target_properties("${target}" PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${output_directory}"
+ RUNTIME_OUTPUT_DIRECTORY "${output_directory}"
+ ARCHIVE_OUTPUT_DIRECTORY "${output_directory}"
+ QT_PLUGIN_CLASS_NAME "${plugin_class_name}")
+ qt_handle_multi_config_output_dirs("${target}")
+
+ qt_internal_library_deprecation_level(deprecation_define)
+
+ qt_autogen_tools_initial_setup(${target})
+
+ set(static_plugin_define "")
+ if (arg_STATIC OR NOT QT_BUILD_SHARED_LIBS)
+ set(static_plugin_define "QT_STATICPLUGIN")
+ endif()
+
+ # Save the Qt module in the plug-in's properties
+ if(NOT arg_TYPE STREQUAL "qml_plugin")
+ qt_get_module_for_plugin("${target}" "${arg_TYPE}")
+ get_target_property(qt_module "${target}" QT_MODULE)
+ endif()
+
+ # Add the plug-in to the list of plug-ins of this module
+ if(TARGET "${qt_module}")
+ set_property(TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}")
+ endif()
+
+ set(_default_plugin 1)
+ if (DEFINED arg_DEFAULT_IF)
+ if (NOT ${arg_DEFAULT_IF})
+ set(_default_plugin 0)
+ endif()
+ endif()
+
+ set_property(TARGET "${target}" PROPERTY QT_DEFAULT_PLUGIN "${_default_plugin}")
+ set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;QT_PLUGIN_TYPE;QT_MODULE;QT_DEFAULT_PLUGIN")
+
+ set(private_includes
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ # For the syncqt headers
+ "$<BUILD_INTERFACE:${module_repo_include_dir}>"
+ ${arg_INCLUDE_DIRECTORIES}
+ )
+
+ set(public_includes
+ ${arg_PUBLIC_INCLUDE_DIRECTORIES}
+ )
+
+ qt_extend_target("${target}"
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ ${private_includes}
+ PUBLIC_INCLUDE_DIRECTORIES
+ ${public_includes}
+ LIBRARIES ${arg_LIBRARIES} Qt::PlatformPluginInternal
+ PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
+ DEFINES
+ ${arg_DEFINES}
+ QT_DEPRECATED_WARNINGS
+ "${deprecation_define}"
+ "${static_plugin_define}"
+ QT_PLUGIN
+ PUBLIC_DEFINES
+ QT_${module_define}_LIB
+ ${arg_PUBLIC_DEFINES}
+ FEATURE_DEPENDENCIES ${arg_FEATURE_DEPENDENCIES}
+ DBUS_ADAPTOR_SOURCES "${arg_DBUS_ADAPTOR_SOURCES}"
+ DBUS_ADAPTOR_FLAGS "${arg_DBUS_ADAPTOR_FLAGS}"
+ DBUS_INTERFACE_SOURCES "${arg_DBUS_INTERFACE_SOURCES}"
+ DBUS_INTERFACE_FLAGS "${arg_DBUS_INTERFACE_FLAGS}"
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ PUBLIC_LINK_OPTIONS ${arg_PUBLIC_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
+ )
+ if(NOT ${arg_EXCEPTIONS})
+ qt_internal_set_no_exceptions_flags("${target}")
+ endif()
+
+
+ set(qt_libs_private "")
+ qt_internal_get_qt_all_known_modules(known_modules)
+ foreach(it ${known_modules})
+ list(FIND arg_LIBRARIES "Qt::${it}Private" pos)
+ if(pos GREATER -1)
+ list(APPEND qt_libs_private "Qt::${it}Private")
+ endif()
+ endforeach()
+
+ qt_register_target_dependencies("${target}" "${arg_PUBLIC_LIBRARIES}" "${qt_libs_private}")
+
+ if (NOT arg_SKIP_INSTALL)
+ # Handle creation of cmake files for consumers of find_package().
+ # If we are part of a Qt module, the plugin cmake files are installed as part of that module.
+ if(qt_module)
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}")
+ else()
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
+ endif()
+
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ configure_package_config_file(
+ "${QT_CMAKE_DIR}/QtPluginConfig.cmake.in"
+ "${config_build_dir}/${target}Config.cmake"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+ write_basic_package_version_file(
+ "${config_build_dir}/${target}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${target}Config.cmake"
+ "${config_build_dir}/${target}ConfigVersion.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ # Make the export name of plugins be consistent with modules, so that
+ # qt_add_resource adds its additional targets to the same export set in a static Qt build.
+ set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
+ qt_install(TARGETS "${target}"
+ EXPORT ${export_name}
+ RUNTIME DESTINATION "${install_directory}"
+ LIBRARY DESTINATION "${install_directory}"
+ ARCHIVE DESTINATION "${archive_install_directory}"
+ )
+ qt_install(EXPORT ${export_name}
+ NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
+ DESTINATION "${config_install_dir}"
+ )
+ endif()
+
+ # Store the plug-in type in the target property
+ set_property(TARGET "${target}" PROPERTY QT_PLUGIN_TYPE "${arg_TYPE}")
+
+ if (NOT arg_ALLOW_UNDEFINED_SYMBOLS)
+ ### fixme: cmake is missing a built-in variable for this. We want to apply it only to
+ # modules and plugins that belong to Qt.
+ qt_internal_add_link_flags_no_undefined("${target}")
+ endif()
+
+ qt_internal_add_linker_version_script(${target})
+endfunction()
+
+function(qt_install_qml_files target)
+
+ qt_parse_all_arguments(arg "qt_install_qml_files"
+ "" "" "FILES" ${ARGN}
+ )
+
+ if (NOT arg_FILES)
+ message(FATAL_ERROR "No files specified for qt_install_qml_files. Please specify them using the FILES parameter.")
+ endif()
+
+ get_target_property(target_path ${target} QT_QML_MODULE_TARGET_PATH)
+ if (NOT target_path)
+ message(FATAL_ERROR "Target ${target} is not a qml module.")
+ endif()
+
+ qt_path_join(qml_module_install_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${target_path}")
+ qt_copy_or_install(FILES ${arg_FILES}
+ DESTINATION ${qml_module_install_dir}
+ )
+
+endfunction()
+
+
+function(qt_add_resource target resourceName)
+ # Don't try to add resources when cross compiling, and the target is actually a host target
+ # (like a tool).
+ qt_is_imported_target("${target}" is_imported)
+ if(is_imported)
+ return()
+ endif()
+
+ qt_parse_all_arguments(arg "qt_add_resource" "" "PREFIX;LANG;BASE" "FILES" ${ARGN})
+
+ QT6_PROCESS_RESOURCE(${target} ${resourceName}
+ PREFIX "${arg_PREFIX}"
+ LANG "${arg_LANG}"
+ BASE "${arg_BASE}"
+ FILES ${arg_FILES}
+ OUTPUT_TARGETS out_targets
+ )
+
+ if (out_targets)
+ qt_install(TARGETS ${out_targets}
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
+ DESTINATION ${INSTALL_LIBDIR}
+ )
+ endif()
+
+endfunction()
+
+
+# This function creates a CMake target for qml modules. It will also make
+# sure that if no C++ source are present, that qml files show up in the project
+# in an IDE. Finally, it will also create a custom ${target}_qmltypes which
+# can be used to generate the respective plugin.qmltypes file.
+#
+# CPP_PLUGIN: Whether this qml module has any c++ source files.
+# URI: Module's uri.
+# TARGET_PATH: Expected installation path for the Qml Module. Equivalent
+# to the module's URI where '.' is replaced with '/'. Use this to override the
+# default substitution pattern.
+# VERSION: Version of the qml module
+# QML_PLUGINDUMP_DEPENDENCIES: Path to a dependencies.json file to be consumed
+# with the ${target}_qmltypes target (optional)
+# SKIP_TYPE_REGISTRATION: All qml files are expected to be registered by the
+# c++ plugin code.
+#
+function(qt_add_qml_module target)
+
+ set(qml_module_optional_args
+ GENERATE_QMLTYPES
+ DESIGNER_SUPPORTED
+ DO_NOT_INSTALL
+ SKIP_TYPE_REGISTRATION
+ )
+
+ set(qml_module_single_args
+ URI
+ TARGET_PATH
+ VERSION
+ QML_PLUGINDUMP_DEPENDENCIES
+ CLASSNAME
+ )
+
+ set(qml_module_multi_args
+ IMPORTS
+ TYPEINFO
+ DEPENDENCIES
+ )
+
+ qt_parse_all_arguments(arg "qt_add_qml_module"
+ "${__qt_add_plugin_optional_args};${qml_module_optional_args}"
+ "${__qt_add_plugin_single_args};${qml_module_single_args}"
+ "${__qt_add_plugin_multi_args};${qml_module_multi_args}" ${ARGN})
+
+ if (NOT arg_URI)
+ message(FATAL_ERROR "qt_add_qml_module called without specifying the module's uri. Please specify one using the URI parameter.")
+ endif()
+
+ set(target_path ${arg_TARGET_PATH})
+
+ if (NOT arg_VERSION)
+ message(FATAL_ERROR "qt_add_qml_module called without specifying the module's import version. Please specify one using the VERSION parameter.")
+ endif()
+
+ if (NOT arg_TARGET_PATH)
+ string(REPLACE "." "/" arg_TARGET_PATH ${arg_URI})
+ endif()
+
+ qt_remove_args(plugin_args
+ ARGS_TO_REMOVE
+ ${target}
+ ${qml_module_multi_args}
+ ${qml_module_single_args}
+ ALL_ARGS
+ ${__qt_add_plugin_optional_args}
+ ${__qt_add_plugin_single_args}
+ ${qml_module_single_args}
+ ${__qt_add_plugin_multi_args}
+ ${qml_module_multi_args}
+ ARGS
+ ${ARGV}
+ )
+
+ # If we have no sources, but qml files, create a custom target so the
+ # qml file will be visibile in an IDE.
+ if (arg_SOURCES)
+ qt_add_plugin(${target}
+ TYPE
+ qml_plugin
+ QML_TARGET_PATH
+ "${arg_TARGET_PATH}"
+ ${plugin_args}
+ )
+ endif()
+
+
+ if (arg_CPP_PLUGIN)
+ set(no_create_option DO_NOT_CREATE_TARGET)
+ endif()
+
+ if (arg_CLASSNAME)
+ set(classname_arg CLASSNAME ${arg_CLASSNAME})
+ endif()
+
+ if (arg_DESIGNER_SUPPORTED)
+ set(designer_supported_arg DESIGNER_SUPPORTED)
+ endif()
+
+ if (arg_SKIP_TYPE_REGISTRATION)
+ set(skip_registration_arg SKIP_TYPE_REGISTRATION)
+ endif()
+
+ if (arg_GENERATE_QMLTYPES)
+ set(generate_qmltypes_arg GENERATE_QMLTYPES)
+ endif()
+
+ qt6_add_qml_module(${target}
+ ${designer_supported_arg}
+ ${no_create_option}
+ ${skip_registration_arg}
+ ${classname_arg}
+ ${generate_qmltypes_arg}
+ RESOURCE_PREFIX "/qt-project.org/imports"
+ TARGET_PATH ${arg_TARGET_PATH}
+ URI ${arg_URI}
+ VERSION ${arg_VERSION}
+ QML_FILES ${arg_QML_FILES}
+ IMPORTS "${arg_IMPORTS}"
+ TYPEINFO "${arg_TYPEINFO}"
+ DO_NOT_INSTALL_METADATA
+ DO_NOT_CREATE_TARGET
+ INSTALL_QML_FILES
+ DEPENDENCIES ${arg_DEPENDENCIES}
+ RESOURCE_EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
+ )
+
+ get_target_property(qmldir_file ${target} QT_QML_MODULE_QMLDIR_FILE)
+ get_target_property(plugin_types ${target} QT_QML_MODULE_PLUGIN_TYPES_FILE)
+ qt_path_join(qml_module_install_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${arg_TARGET_PATH}")
+ if (EXISTS ${plugin_types})
+ qt_copy_or_install(FILES ${plugin_types}
+ DESTINATION "${qml_module_install_dir}"
+ )
+
+ if(QT_WILL_INSTALL)
+ # plugin.qmltypes when present should also be copied to the
+ # cmake binary dir when doing prefix builds
+ file(COPY ${plugin_types}
+ DESTINATION "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${arg_TARGET_PATH}"
+ )
+ endif()
+ endif()
+
+ qt_copy_or_install(
+ FILES
+ "${qmldir_file}"
+ DESTINATION
+ "${qml_module_install_dir}"
+ )
+
+ if(QT_WILL_INSTALL)
+ # qmldir should also be copied to the cmake binary dir when doing
+ # prefix builds
+ file(COPY "${qmldir_file}"
+ DESTINATION "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${arg_TARGET_PATH}"
+ )
+ endif()
+
+endfunction()
+
+# Collection of qt_add_executable arguments so they can be shared across qt_add_executable
+# and qt_add_test_helper.
+set(__qt_add_executable_optional_args
+ "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS"
+)
+set(__qt_add_executable_single_args
+ "OUTPUT_DIRECTORY;INSTALL_DIRECTORY"
+)
+set(__qt_add_executable_multi_args
+ "EXE_FLAGS;${__default_private_args};${__default_public_args}"
+)
+
+# This function creates a CMake target for a generic console or GUI binary.
+# Please consider to use a more specific version target like the one created
+# by qt_add_test or qt_add_tool below.
+function(qt_add_executable name)
+ qt_parse_all_arguments(arg "qt_add_executable"
+ "${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ${ARGN})
+
+ if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
+ set(arg_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}")
+ endif()
+
+ get_filename_component(arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ ABSOLUTE BASE_DIR "${QT_BUILD_DIR}")
+
+ if ("x${arg_INSTALL_DIRECTORY}" STREQUAL "x")
+ set(arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}")
+ endif()
+
+ if (ANDROID)
+ add_library("${name}" MODULE)
+ qt_android_apply_arch_suffix("${name}")
+ qt_android_generate_deployment_settings("${name}")
+ qt_android_add_apk_target("${name}")
+ # On our qmake builds we don't compile the executables with
+ # visibility=hidden. Not having this flag set will cause the
+ # executable to have main() hidden and can then no longer be loaded
+ # through dlopen()
+ set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
+ set_property(TARGET ${name} PROPERTY CXX_VISIBILITY_PRESET default)
+ else()
+ add_executable("${name}" ${arg_EXE_FLAGS})
+ endif()
+
+ qt_autogen_tools_initial_setup(${name})
+ qt_skip_warnings_are_errors_when_repo_unclean("${name}")
+
+ set(extra_libraries "")
+ if(NOT arg_BOOTSTRAP AND NOT arg_NO_QT)
+ set(extra_libraries "Qt::Core")
+ endif()
+
+ set(private_includes
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ ${arg_INCLUDE_DIRECTORIES}
+ )
+
+ qt_extend_target("${name}"
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES ${private_includes}
+ DEFINES ${arg_DEFINES}
+ LIBRARIES ${arg_LIBRARIES}
+ PUBLIC_LIBRARIES ${extra_libraries} ${arg_PUBLIC_LIBRARIES}
+ DBUS_ADAPTOR_SOURCES "${arg_DBUS_ADAPTOR_SOURCES}"
+ DBUS_ADAPTOR_FLAGS "${arg_DBUS_ADAPTOR_FLAGS}"
+ DBUS_INTERFACE_SOURCES "${arg_DBUS_INTERFACE_SOURCES}"
+ DBUS_INTERFACE_FLAGS "${arg_DBUS_INTERFACE_FLAGS}"
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
+ )
+ set_target_properties("${name}" PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ WIN32_EXECUTABLE "${arg_GUI}"
+ MACOSX_BUNDLE "${arg_GUI}"
+ )
+ if(NOT ${arg_EXCEPTIONS})
+ qt_internal_set_no_exceptions_flags("${name}")
+ endif()
+
+
+ if(NOT arg_NO_INSTALL)
+ qt_install(TARGETS "${name}"
+ RUNTIME DESTINATION "${arg_INSTALL_DIRECTORY}"
+ LIBRARY DESTINATION "${arg_INSTALL_DIRECTORY}"
+ BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}")
+ endif()
+endfunction()
+
+# Simple wrapper around qt_add_executable for benchmarks which insure that
+# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
+# See qt_add_executable() for more details.
+function(qt_add_benchmark target)
+
+ qt_parse_all_arguments(arg "qt_add_benchmark"
+ "${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ${ARGN}
+ )
+
+ qt_remove_args(exec_args
+ ARGS_TO_REMOVE
+ ${target}
+ OUTPUT_DIRECTORY
+ INSTALL_DIRECTORY
+ ALL_ARGS
+ "${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ARGS
+ ${ARGV}
+ )
+
+ qt_add_executable(${target}
+ NO_INSTALL # we don't install benchmarks
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" # avoid polluting bin directory
+ ${exec_args}
+ )
+
+endfunction()
+
+# Simple wrapper around qt_add_executable for manual tests which insure that
+# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
+# See qt_add_executable() for more details.
+function(qt_add_manual_test target)
+
+ qt_parse_all_arguments(arg "qt_add_manual_test"
+ "${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ${ARGN}
+ )
+
+ qt_remove_args(exec_args
+ ARGS_TO_REMOVE
+ ${target}
+ OUTPUT_DIRECTORY
+ INSTALL_DIRECTORY
+ ALL_ARGS
+ "${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ARGS
+ ${ARGV}
+ )
+
+ qt_add_executable(${target}
+ NO_INSTALL # we don't install benchmarks
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" # avoid polluting bin directory
+ ${exec_args}
+ )
+
+endfunction()
+
+
+# This function creates a CMake test target with the specified name for use with CTest.
+function(qt_add_test name)
+ qt_parse_all_arguments(arg "qt_add_test"
+ "RUN_SERIAL;EXCEPTIONS;GUI;QMLTEST"
+ "OUTPUT_DIRECTORY;WORKING_DIRECTORY;TIMEOUT"
+ "QML_IMPORTPATH;TESTDATA;${__default_private_args};${__default_public_args}" ${ARGN}
+ )
+
+ if (NOT arg_OUTPUT_DIRECTORY)
+ set(arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ if (${arg_EXCEPTIONS})
+ set(exceptions_text "EXCEPTIONS")
+ endif()
+
+ if (${arg_GUI})
+ set(gui_text "GUI")
+ endif()
+
+ # Handle cases where we have a qml test without source files
+ if (arg_SOURCES)
+ set(private_includes
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ "$<BUILD_INTERFACE:${QT_BUILD_DIR}/include>"
+ ${arg_INCLUDE_DIRECTORIES}
+ )
+
+ qt_add_executable("${name}"
+ ${exceptions_text}
+ ${gui_text}
+ NO_INSTALL
+ OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ SOURCES "${arg_SOURCES}"
+ INCLUDE_DIRECTORIES
+ ${private_includes}
+ DEFINES
+ QT_TESTCASE_BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}"
+ QT_TESTCASE_SOURCEDIR="${CMAKE_CURRENT_SOURCE_DIR}"
+ ${arg_DEFINES}
+ PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Core ${QT_CMAKE_EXPORT_NAMESPACE}::Test ${arg_PUBLIC_LIBRARIES}
+ LIBRARIES ${arg_LIBRARIES}
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
+ )
+
+ # Tests should not be bundles on macOS even if arg_GUI is true, because some tests make
+ # assumptions about the location of helper processes, and those paths would be different
+ # if a test is built as a bundle.
+ set_property(TARGET "${name}" PROPERTY MACOSX_BUNDLE FALSE)
+ # The same goes for WIN32_EXECUTABLE, but because it will detach from the console window
+ # and not print anything.
+ set_property(TARGET "${name}" PROPERTY WIN32_EXECUTABLE FALSE)
+
+ # QMLTest specifics
+
+ qt_extend_target("${name}" CONDITION arg_QMLTEST
+ PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest
+ )
+
+ qt_extend_target("${name}" CONDITION arg_QMLTEST AND NOT ANDROID
+ DEFINES
+ QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
+ )
+
+ qt_extend_target("${name}" CONDITION arg_QMLTEST AND ANDROID
+ DEFINES
+ QUICK_TEST_SOURCE_DIR=":/"
+ )
+ endif()
+
+ foreach(path IN LISTS arg_QML_IMPORTPATH)
+ list(APPEND extra_test_args "-import" "${path}")
+ endforeach()
+
+ # Generate a label in the form tests/auto/foo/bar/tst_baz
+ # and use it also for XML output
+ file(RELATIVE_PATH label "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
+
+ if (ANDROID)
+ qt_android_add_test("${name}")
+ else()
+ if(arg_QMLTEST AND NOT arg_SOURCES)
+ set(test_working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
+ set(test_executable ${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner)
+ else()
+ if (arg_WORKING_DIRECTORY)
+ set(test_working_dir "${arg_WORKING_DIRECTORY}")
+ else()
+ set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+ set(test_executable "${name}")
+ endif()
+
+ add_test(NAME "${name}" COMMAND ${test_executable} ${extra_test_args} -o ${name}.xml,xml -o -,txt WORKING_DIRECTORY "${test_working_dir}")
+ endif()
+ set_tests_properties("${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}" LABELS "${label}")
+ if (arg_TIMEOUT)
+ set_tests_properties(${name} PROPERTIES TIMEOUT ${arg_TIMEOUT})
+ endif()
+ # Get path to qtbase/bin, then prepend this path containing the shared libraries to PATH
+ set(INSTALL_PREFIX_BIN "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
+ set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "PATH=${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}${INSTALL_PREFIX_BIN}${QT_PATH_SEPARATOR}$ENV{PATH}")
+ set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_TEST_RUNNING_IN_CTEST=1")
+
+ # Add the install prefix to list of plugin paths when doing a prefix build
+ if(NOT QT_INSTALL_DIR)
+ list(APPEND plugin_paths "${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}")
+ endif()
+ #TODO: Collect all paths from known repositories when performing a super
+ # build.
+ list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}")
+ list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined)
+ set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}")
+
+ if(ANDROID OR IOS OR WINRT)
+ set(builtin_testdata TRUE)
+ endif()
+
+ if(builtin_testdata)
+ # Safe guard against qml only tests, no source files == no target
+ if (TARGET "${name}")
+ target_compile_definitions("${name}" PRIVATE BUILTIN_TESTDATA)
+
+ foreach(testdata IN LISTS arg_TESTDATA)
+ list(APPEND builtin_files ${testdata})
+ endforeach()
+
+ set(blacklist_path "BLACKLIST")
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}")
+ list(APPEND builtin_files ${blacklist_path})
+ endif()
+
+ list(REMOVE_DUPLICATES builtin_files)
+
+ # Skip Qt quick compiler when embedding test resources
+ foreach(file IN LISTS builtin_files)
+ set_source_files_properties(${file}
+ PROPERTIES QT_SKIP_QUICKCOMPILER TRUE
+ )
+ endforeach()
+
+ if (builtin_files)
+ qt_add_resource(${name} "${name}_testdata_builtin"
+ PREFIX "/"
+ FILES ${builtin_files}
+ BASE ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+ endif()
+ else()
+ # Install test data
+ file(RELATIVE_PATH relative_path_to_test_project
+ "${QT_TOP_LEVEL_SOURCE_DIR}"
+ "${CMAKE_CURRENT_SOURCE_DIR}")
+ qt_path_join(testdata_install_dir ${QT_INSTALL_DIR}
+ "${relative_path_to_test_project}")
+ foreach(testdata IN LISTS arg_TESTDATA)
+ set(testdata "${CMAKE_CURRENT_SOURCE_DIR}/${testdata}")
+ if (IS_DIRECTORY "${testdata}")
+ qt_copy_or_install(
+ DIRECTORY "${testdata}"
+ DESTINATION "${testdata_install_dir}")
+ else()
+ qt_copy_or_install(
+ FILES "${testdata}"
+ DESTINATION "${testdata_install_dir}")
+ endif()
+ endforeach()
+ endif()
+
+endfunction()
+
+
+# This function creates an executable for use as a helper program with tests. Some
+# tests launch separate programs to test certain input/output behavior.
+# Specify OVERRIDE_OUTPUT_DIRECTORY if you dont' want to place the helper in the parent directory,
+# in which case you should specify OUTPUT_DIRECTORY "/foo/bar" manually.
+function(qt_add_test_helper name)
+
+ set(qt_add_test_helper_optional_args
+ "OVERRIDE_OUTPUT_DIRECTORY"
+ )
+
+ qt_parse_all_arguments(arg "qt_add_test_helper"
+ "${qt_add_test_helper_optional_args};${__qt_add_executable_optional_args}"
+ "${__qt_add_executable_single_args}"
+ "${__qt_add_executable_multi_args}"
+ ${ARGN})
+
+ qt_remove_args(forward_args
+ ARGS_TO_REMOVE
+ "${name}"
+ ${qt_add_test_helper_optional_args}
+ ALL_ARGS
+ ${qt_add_test_helper_optional_args}
+ ${__qt_add_executable_optional_args}
+ ${__qt_add_executable_single_args}
+ ${__qt_add_executable_multi_args}
+ ARGS
+ ${ARGV}
+ )
+
+ set(extra_args_to_pass)
+ if(NOT arg_OVERRIDE_OUTPUT_DIRECTORY)
+ set(extra_args_to_pass OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/..")
+ endif()
+
+ qt_add_executable("${name}" NO_INSTALL ${extra_args_to_pass} ${forward_args})
+endfunction()
+
+# Sets QT_WILL_BUILD_TOOLS if tools will be built.
+function(qt_check_if_tools_will_be_built)
+ if(NOT CMAKE_CROSSCOMPILING AND NOT QT_FORCE_FIND_TOOLS)
+ set(will_build_tools TRUE)
+ else()
+ set(will_build_tools FALSE)
+ endif()
+ set(QT_WILL_BUILD_TOOLS ${will_build_tools} CACHE INTERNAL "Are tools going to be built" FORCE)
+endfunction()
+
+# Wrapper function to create a regular cmake target and forward all the
+# arguments collected by the conversion script. This is only meant for tests!
+function(qt_add_cmake_library target)
+ # Process arguments:
+ qt_parse_all_arguments(arg "qt_add_cmake_library"
+ "SHARED;MODULE;STATIC;INTERFACE"
+ "OUTPUT_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY;INSTALL_DIRECTORY"
+ "${__default_private_args};${__default_public_args}"
+ ${ARGN}
+ )
+
+ ### Define Targets:
+ if(${arg_INTERFACE})
+ add_library("${target}" INTERFACE)
+ elseif(${arg_STATIC} OR (${arg_MODULE} AND NOT BUILD_SHARED_LIBS))
+ add_library("${target}" STATIC)
+ elseif(${arg_SHARED})
+ add_library("${target}" SHARED)
+ elseif(${arg_MODULE})
+ add_library("${target}" MODULE)
+ set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
+ set_property(TARGET ${name} PROPERTY CXX_VISIBILITY_PRESET default)
+
+ if(APPLE)
+ # CMake defaults to using .so extensions for loadable modules, aka plugins,
+ # but Qt plugins are actually suffixed with .dylib.
+ set_property(TARGET "${target}" PROPERTY SUFFIX ".dylib")
+ endif()
+ else()
+ add_library("${target}")
+ endif()
+
+ if (NOT arg_ARCHIVE_INSTALL_DIRECTORY AND arg_INSTALL_DIRECTORY)
+ set(arg_ARCHIVE_INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}")
+ endif()
+
+ if (ANDROID)
+ qt_android_apply_arch_suffix("${target}")
+ endif()
+ qt_skip_warnings_are_errors_when_repo_unclean("${target}")
+
+ if (arg_INSTALL_DIRECTORY)
+ set(install_arguments
+ ARCHIVE_INSTALL_DIRECTORY ${arg_ARCHIVE_INSTALL_DIRECTORY}
+ INSTALL_DIRECTORY ${arg_INSTALL_DIRECTORY}
+ )
+ endif()
+
+ if (arg_OUTPUT_DIRECTORY)
+ set_target_properties(${target} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
+ RUNTIME_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
+ LIBRARY_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
+ )
+ endif()
+
+ qt_extend_target("${target}"
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ ${arg_INCLUDE_DIRECTORIES}
+ PUBLIC_INCLUDE_DIRECTORIES
+ ${arg_PUBLIC_INCLUDE_DIRECTORIES}
+ PUBLIC_DEFINES
+ ${arg_PUBLIC_DEFINES}
+ DEFINES
+ ${arg_DEFINES}
+ PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
+ LIBRARIES ${arg_LIBRARIES} Qt::PlatformModuleInternal
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ PUBLIC_LINK_OPTIONS ${arg_PUBLIC_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
+ DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
+ ${install_arguments}
+ )
+
+endfunction()
+
+function(qt_get_tool_cmake_configuration out_var)
+ qt_get_main_cmake_configuration("${out_var}")
+ string(TOUPPER "${${out_var}}" upper_config)
+ set("${out_var}" "${upper_config}" PARENT_SCOPE)
+endfunction()
+
+function(qt_get_main_cmake_configuration out_var)
+ if(CMAKE_BUILD_TYPE)
+ set(config "${CMAKE_BUILD_TYPE}")
+ elseif(QT_MULTI_CONFIG_FIRST_CONFIG)
+ set(config "${QT_MULTI_CONFIG_FIRST_CONFIG}")
+ endif()
+ set("${out_var}" "${config}" PARENT_SCOPE)
+endfunction()
+
+# This function is used to define a "Qt tool", such as moc, uic or rcc.
+# The BOOTSTRAP option allows building it as standalone program, otherwise
+# it will be linked against QtCore.
+function(qt_add_tool name)
+ qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL" "TOOLS_TARGET"
+ "${__default_private_args}" ${ARGN})
+
+ # Handle case when a tool does not belong to a module and it can't be built either (like
+ # during a cross-compile).
+ if(NOT arg_TOOLS_TARGET AND NOT QT_WILL_BUILD_TOOLS)
+ message(FATAL_ERROR "The tool \"${name}\" has not been assigned to a module via"
+ " TOOLS_TARGET (so it can't be found) and it can't be built"
+ " (QT_WILL_BUILD_TOOLS is ${QT_WILL_BUILD_TOOLS}).")
+ endif()
+
+ set(full_name "${QT_CMAKE_EXPORT_NAMESPACE}::${name}")
+ if(TARGET ${full_name})
+ get_property(path TARGET ${full_name} PROPERTY LOCATION)
+ message(STATUS "Tool '${full_name}' was found at ${path}.")
+ return()
+ endif()
+
+ if(arg_TOOLS_TARGET AND NOT QT_WILL_BUILD_TOOLS)
+ set(tools_package_name "Qt6${arg_TOOLS_TARGET}Tools")
+ message(STATUS "Searching for tool '${full_name}' in package ${tools_package_name}.")
+
+ # Only search in path provided by QT_HOST_PATH. We need to do it with CMAKE_PREFIX_PATH
+ # instead of PATHS option, because any find_dependency call inside a Tools package would
+ # not get the proper prefix when using PATHS.
+ set(BACKUP_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
+ set(CMAKE_PREFIX_PATH "${QT_HOST_PATH}")
+
+ # Search both with sysroots prepended as well as in the host system. When cross compiling
+ # the mode_package might be set to ONLY only, and the Qt6 tools packages are actually
+ # in the host system.
+ set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH")
+ set(BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
+ set(CMAKE_SIZEOF_VOID_P "")
+ find_package(
+ ${tools_package_name}
+ ${PROJECT_VERSION}
+ NO_PACKAGE_ROOT_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_PACKAGE_REGISTRY
+ NO_CMAKE_SYSTEM_PATH
+ NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
+ set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}")
+ set(CMAKE_PREFIX_PATH "${BACKUP_CMAKE_PREFIX_PATH}")
+
+ if(${${tools_package_name}_FOUND} AND TARGET ${full_name})
+ # Even if the tool is already visible, make sure that our modules remain associated
+ # with the tools.
+ qt_internal_append_known_modules_with_tools("${arg_TOOLS_TARGET}")
+ get_property(path TARGET ${full_name} PROPERTY LOCATION)
+ message(STATUS "${full_name} was found at ${path} using package ${tools_package_name}.")
+ return()
+ endif()
+ endif()
+
+ if(NOT QT_WILL_BUILD_TOOLS)
+ message(FATAL_ERROR "The tool \"${full_name}\" was not found in the "
+ "${tools_package_name} package. "
+ "Package found: ${${tools_package_name}_FOUND}")
+ else()
+ message(STATUS "Tool '${full_name}' will be built from source.")
+ endif()
+
+ set(disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}")
+ if (arg_NO_QT)
+ # FIXME: Remove NO_QT again once qmake can use a "normal" Qt!
+ if (arg_BOOTSTRAP)
+ message(FATAL_ERROR "Tool can not be NO_QT and BOOTSTRAP at the same time!")
+ endif()
+ set(corelib "")
+ else()
+ if (arg_BOOTSTRAP)
+ set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap)
+ list(APPEND disable_autogen_tools "uic" "moc" "rcc")
+ else()
+ set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Core)
+ endif()
+ endif()
+
+ set(bootstrap "")
+ if(arg_BOOTSTRAP)
+ set(bootstrap BOOTSTRAP)
+ endif()
+
+ set(no_qt "")
+ if(arg_NO_QT)
+ set(no_qt NO_QT)
+ endif()
+
+ set(no_install "")
+ if(arg_NO_INSTALL)
+ set(no_install NO_INSTALL)
+ endif()
+
+ qt_add_executable("${name}" OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ ${bootstrap}
+ ${no_qt}
+ ${no_install}
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ ${arg_INCLUDE_DIRECTORIES}
+ DEFINES ${arg_DEFINES}
+ PUBLIC_LIBRARIES ${corelib}
+ LIBRARIES ${arg_LIBRARIES} Qt::PlatformToolInternal
+ COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
+ LINK_OPTIONS ${arg_LINK_OPTIONS}
+ MOC_OPTIONS ${arg_MOC_OPTIONS}
+ DISABLE_AUTOGEN_TOOLS ${disable_autogen_tools}
+ )
+ qt_internal_add_target_aliases("${name}")
+
+ # If building with a multi-config configuration, the main configuration tool will be placed in
+ # ./bin, while the rest will be in <CONFIG> specific subdirectories.
+ qt_get_tool_cmake_configuration(tool_cmake_configuration)
+ set_target_properties("${name}" PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY_${tool_cmake_configuration} "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ )
+
+ if(NOT arg_NO_INSTALL AND arg_TOOLS_TARGET)
+ # Assign a tool to an export set, and mark the module to which the tool belongs.
+ qt_internal_append_known_modules_with_tools("${arg_TOOLS_TARGET}")
+
+ # Also append the tool to the module list.
+ qt_internal_append_known_module_tool("${arg_TOOLS_TARGET}" "${name}")
+
+ qt_install(TARGETS "${name}"
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}${arg_TOOLS_TARGET}ToolsTargets"
+ DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
+ endif()
+endfunction()
+
+function(qt_create_tracepoints name tracePointsFile)
+ #### TODO
+ string(TOLOWER "${name}" name)
+
+ file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/qt${name}_tracepoints_p.h" CONTENT
+ "#include <private/qtrace_p.h>")
+endfunction()
+
+# Handle files that need special SIMD-related flags.
+# This creates an object library and makes target link
+# to it (privately).
+function(qt_add_simd_part target)
+ qt_parse_all_arguments(arg "qt_add_simd_part" "" ""
+ "NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN})
+ if ("x${arg_SIMD}" STREQUAL x)
+ message(FATAL_ERROR "qt_add_simd_part needs a SIMD type to be set.")
+ endif()
+
+ set(condition "QT_FEATURE_${arg_SIMD}")
+ if("${arg_SIMD}" STREQUAL arch_haswell)
+ set(condition "TEST_subarch_avx2 AND TEST_subarch_bmi AND TEST_subarch_bmi2 AND TEST_subarch_f16c AND TEST_subarch_fma AND TEST_subarch_lzcnt AND TEST_subarch_popcnt")
+ elseif("${arg_SIMD}" STREQUAL avx512common)
+ set(condition "TEST_subarch_avx512cd")
+ elseif("${arg_SIMD}" STREQUAL avx512core)
+ set(condition "TEST_subarch_avx512cd AND TEST_subarch_avx512bw AND TEST_subarch_avx512dq AND TEST_subarch_avx512vl")
+ endif()
+
+ set(name "${arg_NAME}")
+ if("x${name}" STREQUAL x)
+ set(name "${target}_simd_${arg_SIMD}")
+ endif()
+
+ qt_evaluate_config_expression(result ${condition})
+ if(${result})
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("qt_add_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated")
+ endif()
+ string(TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags)
+
+ if (NOT TARGET "${name}")
+ add_library("${name}" OBJECT)
+ endif()
+ target_sources("${name}" PRIVATE ${arg_SOURCES})
+ target_include_directories("${name}" PRIVATE
+ ${arg_INCLUDE_DIRECTORIES}
+ $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
+ target_compile_options("${name}" PRIVATE
+ ${${simd_flags}}
+ ${arg_COMPILE_FLAGS}
+ $<TARGET_PROPERTY:${target},COMPILE_OPTIONS>)
+ target_compile_definitions("${name}" PRIVATE
+ $<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>)
+
+ target_link_libraries("${target}" PRIVATE "${name}")
+
+ # Add a link-only dependency on the parent library, to force copying of framework headers
+ # before trying to compile a source file.
+ target_link_libraries("${name}" PRIVATE
+ $<FILTER:$<TARGET_PROPERTY:${target},LINK_LIBRARIES>,EXCLUDE,^${target}_simd_>)
+
+ if(NOT BUILD_SHARED_LIBS)
+ qt_install(
+ TARGETS ${name}
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets"
+ )
+ endif()
+ else()
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("qt_add_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped")
+ endif()
+ endif()
+endfunction()
+
+# From Qt6CoreMacros
+# Function used to create the names of output files preserving relative dirs
+function(qt_make_output_file infile prefix suffix source_dir binary_dir result)
+ get_filename_component(outfilename "${infile}" NAME_WE)
+
+ set(base_dir "${source_dir}")
+ string(FIND "${infile}" "${binary_dir}/" in_binary)
+ if (in_binary EQUAL 0)
+ set(base_dir "${binary_dir}")
+ endif()
+
+ get_filename_component(abs_infile "${infile}" ABSOLUTE BASE_DIR "${base_dir}")
+ file(RELATIVE_PATH rel_infile "${base_dir}" "${abs_infile}")
+ string(REPLACE "../" "__/" mapped_infile "${rel_infile}")
+
+ get_filename_component(abs_mapped_infile "${mapped_infile}" ABSOLUTE BASE_DIR "${binary_dir}")
+ get_filename_component(outpath "${abs_mapped_infile}" PATH)
+
+ file(MAKE_DIRECTORY "${outpath}")
+ set("${result}" "${outpath}/${prefix}${outfilename}${suffix}" PARENT_SCOPE)
+endfunction()
+
+
+# Complete manual moc invocation with full control.
+# Use AUTOMOC whenever possible.
+function(qt_manual_moc result)
+ cmake_parse_arguments(arg "" "" "FLAGS" ${ARGN})
+ set(moc_files)
+ foreach(infile ${arg_UNPARSED_ARGUMENTS})
+ qt_make_output_file("${infile}" "moc_" ".cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" outfile)
+ list(APPEND moc_files "${outfile}")
+
+ set(moc_parameters_file "${outfile}_parameters$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>")
+ set(moc_parameters ${arg_FLAGS} -o "${outfile}" "${infile}")
+ string (REPLACE ";" "\n" moc_parameters "${moc_parameters}")
+
+ file(GENERATE OUTPUT "${moc_parameters_file}" CONTENT "${moc_parameters}\n")
+
+ add_custom_command(OUTPUT "${outfile}"
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc "@${moc_parameters_file}"
+ DEPENDS "${infile}" ${moc_depends} ${QT_CMAKE_EXPORT_NAMESPACE}::moc
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM)
+ endforeach()
+ set("${result}" ${moc_files} PARENT_SCOPE)
+endfunction()
+
+
+# helper to set up a qdbusxml2cpp rule
+function(qt_create_qdbusxml2cpp_command target infile)
+ qt_parse_all_arguments(arg "qt_create_qdbusxml2cpp_command" "ADAPTOR;INTERFACE" "BASENAME" "FLAGS" ${ARGN})
+ if((arg_ADAPTOR AND arg_INTERFACE) OR (NOT arg_ADAPTOR AND NOT arg_INTERFACE))
+ message(FATAL_ERROR "qt_create_dbusxml2cpp_command needs either ADAPTOR or INTERFACE.")
+ endif()
+
+ set(option "-a")
+ set(type "adaptor")
+ if (arg_INTERFACE)
+ set(option "-p")
+ set(type "interface")
+ endif()
+
+ if ("${arg_BASENAME}" STREQUAL "")
+ get_filename_component(file_dir "${infile}" DIRECTORY)
+ get_filename_component(file_name "${infile}" NAME_WLE)
+ get_filename_component(file_ext "${infile}" LAST_EXT)
+
+ if("${file_ext}" STREQUAL ".xml")
+ else()
+ message(FATAL_ERROR "DBUS ${type} input file is not xml.")
+ endif()
+
+ # use last part of io.qt.something.xml!
+ get_filename_component(file_ext "${file_name}" LAST_EXT)
+ if("x${file_ext}" STREQUAL "x")
+ else()
+ string(SUBSTRING "${file_ext}" 1 -1 file_name) # cut of leading '.'
+ endif()
+
+ string(TOLOWER "${file_name}" file_name)
+ set(file_name "${file_name}_${type}")
+ else()
+ set(file_name ${arg_BASENAME})
+ endif()
+
+ # Use absolute file path for the source file and set the current working directory to the
+ # current binary directory, because setting an absolute path for the header:source combo option
+ # does not work. Splitting on ":" breaks inside the dbus tool when running on Windows
+ # due to ":" being contained in the drive path (e.g C:\foo.h:C:\foo.cpp).
+ get_filename_component(absolute_in_file_path "${infile}" ABSOLUTE)
+
+ set(header_file "${file_name}.h")
+ set(source_file "${file_name}.cpp")
+
+ add_custom_command(OUTPUT "${header_file}" "${source_file}"
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
+ "${header_file}:${source_file}" "${absolute_in_file_path}"
+ DEPENDS "${absolute_in_file_path}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ VERBATIM)
+
+ target_sources("${target}" PRIVATE "${header_file}" "${source_file}")
+endfunction()
+
+function(qt_compute_injection_forwarding_header target)
+ qt_parse_all_arguments(arg "qt_compute_injection_forwarding_header"
+ "PRIVATE" "SOURCE;OUT_VAR" "" ${ARGN})
+ qt_internal_module_info(module "${target}")
+ get_filename_component(file_name "${arg_SOURCE}" NAME)
+
+ set(source_absolute_path "${CMAKE_CURRENT_BINARY_DIR}/${arg_SOURCE}")
+ file(RELATIVE_PATH relpath "${PROJECT_BINARY_DIR}" "${source_absolute_path}")
+
+ if (arg_PRIVATE)
+ set(fwd "${PROJECT_VERSION}/${module}/private/${file_name}")
+ else()
+ set(fwd "${file_name}")
+ endif()
+
+ string(APPEND ${arg_OUT_VAR} " ${relpath}:${fwd}")
+ set(${arg_OUT_VAR} ${${arg_OUT_VAR}} PARENT_SCOPE)
+endfunction()
+
+
+function(qt_add_docs)
+ if(${ARGC} EQUAL 1)
+ # Function called from old generated CMakeLists.txt that was missing the target parameter
+ return()
+ endif()
+ if(NOT ${ARGC} EQUAL 2)
+ message(FATAL_ERROR "qt_add_docs called with the wrong number of arguments. Should be qt_add_docs(target path_to_project.qdocconf).")
+ return()
+ endif()
+ set(target ${ARGV0})
+ set(doc_project ${ARGV1})
+
+ if (NOT QT_SUPERBUILD OR QT_WILL_INSTALL)
+ set(qdoc_bin "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qdoc")
+ set(qtattributionsscanner_bin "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qtattributionsscanner")
+ set(qhelpgenerator_bin "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qhelpgenerator")
+ else()
+ set(qdoc_bin "${CMAKE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qdoc")
+ set(qtattributionsscanner_bin "${CMAKE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qtattributionsscanner")
+ set(qhelpgenerator_bin "${CMAKE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qhelpgenerator")
+ endif()
+
+ get_target_property(target_type ${target} TYPE)
+ if (NOT target_type STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(target_bin_dir ${target} BINARY_DIR)
+ get_target_property(target_source_dir ${target} SOURCE_DIR)
+ else()
+ set(target_bin_dir ${CMAKE_CURRENT_BINARY_DIR})
+ set(target_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+ set(doc_ouput_dir "${target_bin_dir}/.doc")
+
+
+ # Generate include dir list
+ set(target_include_dirs_file "${doc_ouput_dir}/$<CONFIG>/includes.txt")
+
+ set(include_paths_property "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>")
+ if (NOT target_type STREQUAL "INTERFACE_LIBRARY")
+ file(GENERATE
+ OUTPUT ${target_include_dirs_file}
+ CONTENT "-I$<JOIN:${include_paths_property},\n-I>"
+ )
+ set(include_path_args "@${target_include_dirs_file}")
+ else()
+ set(include_path_args "")
+ endif()
+
+ get_filename_component(doc_target "${doc_project}" NAME_WLE)
+ if (QT_WILL_INSTALL)
+ set(qdoc_output_dir "${CMAKE_BINARY_DIR}/doc/${doc_target}")
+ set(index_dir "${CMAKE_BINARY_DIR}/doc")
+ elseif (QT_SUPERBUILD)
+ set(qdoc_output_dir "${CMAKE_INSTALL_PREFIX}/qtbase/doc/${doc_target}")
+ set(index_dir "${CMAKE_INSTALL_PREFIX}/qtbase/doc")
+ else()
+ set(qdoc_output_dir "${CMAKE_INSTALL_PREFIX}/doc/${doc_target}")
+ set(index_dir "${CMAKE_INSTALL_PREFIX}/doc")
+ endif()
+
+ # qtattributionsscanner
+ add_custom_target(qattributionsscanner_${target}
+ COMMAND ${qtattributionsscanner_bin}
+ ${PROJECT_SOURCE_DIR}
+ --filter "QDocModule=${qdoc_target}"
+ -o "${target_bin_dir}/codeattributions.qdoc"
+ )
+
+ # prepare docs target
+ set(prepare_qdoc_args
+ -outputdir "${qdoc_output_dir}"
+ -installdir "${QT_INSTALL_DIR}/doc"
+ "${target_source_dir}/${doc_project}"
+ -prepare
+ -indexdir "${index_dir}"
+ -no-link-errors
+ "${include_path_args}"
+ )
+
+ if (QT_SUPERBUILD AND NOT QT_WILL_INSTALL)
+ set(qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/qtbase/doc")
+ else()
+ set(qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/doc")
+ endif()
+
+ set(qdoc_env_args
+ "QT_INSTALL_DOCS=\"${qt_install_docs_env}\""
+ "QT_VERSION=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
+ "QT_VER=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
+ "QT_VERSION_TAG=${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}"
+ "BUILDDIR=${target_bin_dir}"
+ )
+
+ add_custom_target(prepare_docs_${target}
+ COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
+ ${qdoc_bin}
+ ${prepare_qdoc_args}
+ )
+
+ add_dependencies(prepare_docs_${target} qattributionsscanner_${target})
+
+ # generate docs target
+ set(generate_qdocs_args
+ -outputdir "${qdoc_output_dir}"
+ -installdir "${INSTALL_DOCDIR}"
+ "${target_source_dir}/${doc_project}"
+ -generate
+ -indexdir "${index_dir}"
+ "${include_path_args}"
+ )
+
+ add_custom_target(generate_docs_${target}
+ COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
+ ${qdoc_bin}
+ ${generate_qdocs_args}
+ )
+
+ add_dependencies(generate_docs_${target} prepare_docs_${target})
+
+ # generate html
+ set(html_qdocs_args
+ -outputdir "${qdoc_output_dir}"
+ -installdir "${INSTALL_DOCDIR}"
+ "${target_source_dir}/${doc_project}"
+ -indexdir "${index_dir}"
+ "${include_path_args}"
+ )
+
+ add_custom_target(html_docs_${target}
+ COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
+ ${qdoc_bin}
+ ${html_qdocs_args}
+ )
+
+ add_dependencies(html_docs_${target} generate_docs_${target})
+
+ # generate .qch
+ set(qch_file_name ${doc_target}.qch)
+ set(qch_file_path ${qdoc_output_dir}/${qch_file_name})
+
+ add_custom_target(qch_docs_${target}
+ COMMAND ${qhelpgenerator_bin}
+ "${qdoc_output_dir}/${doc_target}.qhp"
+ -o "${qch_file_path}"
+ )
+ add_dependencies(qch_docs_${target} generate_docs_${target})
+
+ if (QT_WILL_INSTALL)
+ add_custom_target(install_html_docs_${target}
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ "${qdoc_output_dir}"
+ "${CMAKE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${doc_target}"
+ COMMENT "Installing html docs for target {$target}"
+ )
+
+ add_custom_target(install_qch_docs_${target}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${qch_file_path}"
+ "${CMAKE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${qch_file_name}"
+ COMMENT "Installing qch docs for target ${target}"
+ )
+ else()
+ # Don't need to do anything when not installing
+ add_custom_target(install_html_docs_${target})
+ add_custom_target(install_qch_docs_${target})
+ endif()
+
+ add_dependencies(install_html_docs_${target} html_docs_${target})
+ add_dependencies(install_qch_docs_${target} qch_docs_${target})
+
+ add_custom_target(install_docs_${target})
+ add_dependencies(install_docs_${target} install_html_docs_${target} install_qch_docs_${target})
+
+ add_dependencies(${qt_docs_prepare_target_name} prepare_docs_${target})
+ add_dependencies(${qt_docs_generate_target_name} generate_docs_${target})
+ add_dependencies(${qt_docs_html_target_name} html_docs_${target})
+ add_dependencies(${qt_docs_qch_target_name} qch_docs_${target})
+ add_dependencies(${qt_docs_install_html_target_name} install_html_docs_${target})
+ add_dependencies(${qt_docs_install_qch_target_name} install_qch_docs_${target})
+ add_dependencies(${qt_docs_install_target_name} install_docs_${target})
+
+endfunction()
+
+macro(qt_find_package)
+ # Get the target names we expect to be provided by the package.
+ set(options CONFIG NO_MODULE MODULE REQUIRED)
+ set(oneValueArgs)
+ set(multiValueArgs PROVIDED_TARGETS COMPONENTS)
+ cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ # If some Qt internal project calls qt_find_package(WrapFreeType), but WrapFreeType was already
+ # found as part of a find_dependency() call from a ModuleDependencies.cmake file (or similar),
+ # and the provided target is also found, that means this might have been an unnecessary
+ # qt_find_package() call, because the dependency was already found via some other transitive
+ # dependency. Return early, so that CMake doesn't fail wiht an error with trying to promote the
+ # targets to be global. This behavior is not enabled by default, because there are cases
+ # when a regular find_package() (non qt_) can find a package (Freetype -> PNG), and a subsequent
+ # qt_find_package(PNG PROVIDED_TARGET PNG::PNG) still needs to succeed and register the provided
+ # targets. To enable the debugging behavior, set QT_DEBUG_QT_FIND_PACKAGE to 1.
+ set(_qt_find_package_skip_find_package FALSE)
+ if(QT_DEBUG_QT_FIND_PACKAGE AND ${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
+ set(_qt_find_package_skip_find_package TRUE)
+ foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
+ if(NOT TARGET ${qt_find_package_target_name})
+ set(_qt_find_package_skip_find_package FALSE)
+ endif()
+ endforeach()
+
+ if(_qt_find_package_skip_find_package)
+ message(AUTHOR_WARNING "qt_find_package(${ARGV0}) called even though the package "
+ "was already found. Consider removing the call.")
+ endif()
+ endif()
+
+ # Get the version if specified.
+ set(package_version "")
+ if(${ARGC} GREATER_EQUAL 2)
+ if(${ARGV1} MATCHES "^[0-9\.]+$")
+ set(package_version "${ARGV1}")
+ endif()
+ endif()
+
+ if(arg_COMPONENTS)
+ # Re-append components to forward them.
+ list(APPEND arg_UNPARSED_ARGUMENTS "COMPONENTS;${arg_COMPONENTS}")
+ endif()
+
+ if(NOT (arg_CONFIG OR arg_NO_MODULE OR arg_MODULE) AND NOT _qt_find_package_skip_find_package)
+ # Try to find a config package first in quiet mode
+ set(config_package_arg ${arg_UNPARSED_ARGUMENTS})
+ list(APPEND config_package_arg "CONFIG;QUIET")
+ find_package(${config_package_arg})
+
+ # Double check that in config mode the targets become visible. Sometimes
+ # only the module mode creates the targets. For example with vcpkg, the sqlite
+ # package provides sqlite3-config.cmake, which offers multi-config targets but
+ # in their own way. CMake has FindSQLite3.cmake and with the original
+ # qt_find_package(SQLite3) call it is our intention to use the cmake package
+ # in module mode.
+ if (${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
+ unset(any_target_found)
+ foreach(expected_target ${arg_PROVIDED_TARGETS})
+ if (TARGET ${expected_target})
+ set(any_target_found TRUE)
+ break()
+ endif()
+ endforeach()
+ if(NOT any_target_found)
+ unset(${ARGV0}_FOUND)
+ endif()
+ endif()
+ endif()
+
+ # Ensure the options are back in the original unparsed arguments
+ foreach(opt IN LISTS options)
+ if(arg_${opt})
+ list(APPEND arg_UNPARSED_ARGUMENTS ${opt})
+ endif()
+ endforeach()
+
+ if (NOT ${ARGV0}_FOUND AND NOT _qt_find_package_skip_find_package)
+ # Unset the NOTFOUND ${package}_DIR var that might have been set by the previous
+ # find_package call, to get rid of "not found" messagees in the feature summary
+ # if the package is found by the next find_package call.
+ if(DEFINED CACHE{${ARGV0}_DIR} AND NOT ${ARGV0}_DIR)
+ unset(${ARGV0}_DIR CACHE)
+ endif()
+
+ # Call original function without our custom arguments.
+ find_package(${arg_UNPARSED_ARGUMENTS})
+ endif()
+
+ if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS AND NOT _qt_find_package_skip_find_package)
+ # If package was found, associate each target with its package name. This will be used
+ # later when creating Config files for Qt libraries, to generate correct find_dependency()
+ # calls. Also make the provided targets global, so that the properties can be read in
+ # all scopes.
+ foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
+ if(TARGET ${qt_find_package_target_name})
+ # Allow usage of aliased targets by setting properties on the actual target
+ get_target_property(aliased_target ${qt_find_package_target_name} ALIASED_TARGET)
+ if(aliased_target)
+ set(qt_find_package_target_name ${aliased_target})
+ endif()
+
+ set_target_properties(${qt_find_package_target_name}
+ PROPERTIES INTERFACE_QT_PACKAGE_NAME ${ARGV0})
+ if(package_version)
+ set_target_properties(${qt_find_package_target_name}
+ PROPERTIES INTERFACE_QT_PACKAGE_VERSION ${ARGV1})
+ endif()
+
+ if(arg_COMPONENTS)
+ string(REPLACE ";" " " components_as_string "${arg_COMPONENTS}")
+ set_property(TARGET ${qt_find_package_target_name}
+ PROPERTY INTERFACE_QT_PACKAGE_COMPONENTS ${components_as_string})
+ endif()
+
+ get_property(is_global TARGET ${qt_find_package_target_name} PROPERTY
+ IMPORTED_GLOBAL)
+ if(NOT is_global)
+ set_property(TARGET ${qt_find_package_target_name} PROPERTY
+ IMPORTED_GLOBAL TRUE)
+ endif()
+ endif()
+
+ endforeach()
+ endif()
+endmacro()
+
+# Creates a simple export set for the various Find* dependencies
+# which are needed when creating a static build of Qt.
+# This introduces a custom target property: INTERFACE_QT_EXPORTED_LIBRARY
+# This target property indicates that Qt modules / plugins using this 3rd party library
+# must add it to their list of dependencies when creating their own ${qtmodule}Config.cmake
+function(qt_install_static_target_export target)
+ if(BUILD_SHARED_LIBS)
+ return()
+ endif()
+
+ qt_parse_all_arguments(arg "qt_install_3rdparty_config_files" "" "EXPORT" "" ${ARGN})
+ # TODO mark EXPORT as required
+
+ set_target_properties(${target}
+ PROPERTIES
+ INTERFACE_QT_EXPORTED_LIBRARY 1)
+
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${arg_EXPORT})
+
+ set(export_name "${arg_EXPORT}Targets")
+ qt_install(
+ TARGETS ${target}
+ EXPORT ${export_name}
+ LIBRARY DESTINATION ${INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${INSTALL_LIBDIR})
+
+ qt_install(
+ EXPORT ${export_name}
+ DESTINATION "${config_install_dir}"
+ )
+endfunction()
+
+# Create a set of ${target}Config.cmake and ${target}Version.cmake for a
+# third-party library so that it can be found by client code linking statically.
+function(qt_install_3rdparty_config_files target)
+ if(BUILD_SHARED_LIBS)
+ return()
+ endif()
+
+ qt_parse_all_arguments(arg "qt_install_3rdparty_config_files" "" "EXPORT" "PACKAGES;ADDITIONAL_FILES" ${ARGN})
+ # TODO mark EXPORT as required
+
+ set(3RDPARTY_ADDITIONAL_SETUP_CODE)
+ foreach(package ${arg_PACKAGES})
+ list(APPEND 3RDPARTY_ADDITIONAL_SETUP_CODE "find_package(${package})\n")
+ endforeach()
+
+ set(path_suffix "${arg_EXPORT}")
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ configure_package_config_file(
+ "${PROJECT_SOURCE_DIR}/cmake/3rdpartyConfig.cmake.in"
+ "${config_build_dir}/${target}Config.cmake"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+
+ write_basic_package_version_file(
+ "${config_build_dir}/${target}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${target}Config.cmake"
+ "${config_build_dir}/${target}ConfigVersion.cmake"
+ ${arg_ADDITIONAL_FILES}
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+endfunction()
+
+# Call this function in 3rdparty find modules that ought to be installed alongside
+# Qt modules and must be found when linking statically.
+function(qt_install_3rdparty_library target)
+ qt_install_static_target_export(${target} EXPORT ${target})
+ qt_install_3rdparty_config_files(${target} EXPORT ${target} ${ARGN})
+endfunction()
+
+macro(qt_find_apple_system_frameworks)
+ if(APPLE)
+ find_library(FWAppKit AppKit)
+ find_library(FWAssetsLibrary AssetsLibrary)
+ find_library(FWAudioToolbox AudioToolbox)
+ find_library(FWApplicationServices ApplicationServices)
+ find_library(FWCarbon Carbon)
+ find_library(FWCoreFoundation CoreFoundation)
+ find_library(FWCoreServices CoreServices)
+ find_library(FWCoreGraphics CoreGraphics)
+ find_library(FWCoreText CoreText)
+ find_library(FWCoreVideo CoreVideo)
+ find_library(FWcups cups)
+ find_library(FWDiskArbitration DiskArbitration)
+ find_library(FWFoundation Foundation)
+ find_library(FWIOBluetooth IOBluetooth)
+ find_library(FWIOKit IOKit)
+ find_library(FWIOSurface IOSurface)
+ find_library(FWImageIO ImageIO)
+ find_library(FWMetal Metal)
+ find_library(FWMobileCoreServices MobileCoreServices)
+ find_library(FWQuartzCore QuartzCore)
+ find_library(FWSecurity Security)
+ find_library(FWSystemConfiguration SystemConfiguration)
+ find_library(FWUIKit UIKit)
+ find_library(FWWatchKit WatchKit)
+ find_library(FWGameController GameController)
+ endif()
+endmacro()
+
+# Match the pattern 'regex' in 'input_line', replace the match with 'replacement'
+# and set that result in 'out_var' in the parent scope.
+function(qt_regex_match_and_get input_line regex replacement out_var)
+ string(REGEX MATCH "${regex}" match "${input_line}")
+ if(match)
+ string(REGEX REPLACE "${regex}" "${replacement}" match "${input_line}")
+ string(STRIP ${match} match)
+ set(${out_var} "${match}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Match 'regex' in a list of lines. When found, set the value to 'out_var' and break early.
+function(qt_qlalr_find_option_in_list input_list regex out_var)
+ foreach(line ${input_list})
+ qt_regex_match_and_get("${line}" "${regex}" "\\1" option)
+ if(option)
+ string(TOLOWER ${option} option)
+ set(${out_var} "${option}" PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ message(FATAL_ERROR "qt_qlalr_find_option_in_list: Could not extract ${out_var}")
+endfunction()
+
+# Generate a few output files using qlalr, and assign those to 'consuming_target'.
+# 'input_file_list' is a list of 'foo.g' file paths.
+# 'flags' are extra flags to be passed to qlalr.
+function(qt_process_qlalr consuming_target input_file_list flags)
+ foreach(input_file ${input_file_list})
+ file(STRINGS ${input_file} input_file_lines)
+ qt_qlalr_find_option_in_list("${input_file_lines}" "^%parser(.+)" "parser")
+ qt_qlalr_find_option_in_list("${input_file_lines}" "^%decl(.+)" "decl")
+ qt_qlalr_find_option_in_list("${input_file_lines}" "^%impl(.+)" "impl")
+ get_filename_component(base_file_name ${input_file} NAME_WE)
+
+ set(cpp_file "${parser}.cpp")
+ set(private_file "${parser}_p.h")
+ set(decl_file "${decl}")
+ set(impl_file "${impl}")
+ add_custom_command(
+ OUTPUT ${cpp_file} ${private_file} ${decl_file} ${impl_file}
+ COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr ${flags} ${input_file}
+ MAIN_DEPENDENCY ${input_file}
+ )
+ target_sources(${consuming_target} PRIVATE ${cpp_file} ${impl_file})
+ endforeach()
+endfunction()
+
+macro(qt_add_string_to_qconfig_cpp str)
+ string(LENGTH "${str}" length)
+ string(APPEND QT_CONFIG_STRS " \"${str}\\0\"\n")
+ string(APPEND QT_CONFIG_STR_OFFSETS " ${QT_CONFIG_STR_OFFSET},\n")
+ math(EXPR QT_CONFIG_STR_OFFSET "${QT_CONFIG_STR_OFFSET}+${length}+1")
+endmacro()
+
+function(qt_generate_qconfig_cpp)
+ set(QT_CONFIG_STR_OFFSET "0")
+ set(QT_CONFIG_STR_OFFSETS "")
+ set(QT_CONFIG_STRS "")
+
+ # Start first part.
+ qt_add_string_to_qconfig_cpp("doc")
+ qt_add_string_to_qconfig_cpp("include")
+ qt_add_string_to_qconfig_cpp("lib")
+ qt_add_string_to_qconfig_cpp("libexec")
+ qt_add_string_to_qconfig_cpp("bin")
+ qt_add_string_to_qconfig_cpp("plugins")
+ qt_add_string_to_qconfig_cpp("qml")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp("translations")
+ qt_add_string_to_qconfig_cpp("examples")
+ qt_add_string_to_qconfig_cpp("tests")
+
+ # Save first part.
+ set(QT_CONFIG_STR_OFFSETS_FIRST "${QT_CONFIG_STR_OFFSETS}")
+ set(QT_CONFIG_STRS_FIRST "${QT_CONFIG_STRS}")
+
+ # Start second part.
+ set(QT_CONFIG_STR_OFFSETS "")
+ set(QT_CONFIG_STRS "")
+
+ qt_add_string_to_qconfig_cpp("")
+ qt_add_string_to_qconfig_cpp("false")
+ qt_add_string_to_qconfig_cpp("bin")
+ qt_add_string_to_qconfig_cpp("lib")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp("${QT_QMAKE_TARGET_MKSPEC}")
+ qt_add_string_to_qconfig_cpp("${QT_QMAKE_HOST_MKSPEC}")
+
+ # Save second part.
+ set(QT_CONFIG_STR_OFFSETS_SECOND "${QT_CONFIG_STR_OFFSETS}")
+ set(QT_CONFIG_STRS_SECOND "${QT_CONFIG_STRS}")
+
+ # Settings path / sysconf dir.
+ if(APPLE)
+ set(QT_DEFAULT_SYS_CONF_DIR "/Library/Preferences/Qt")
+ else()
+ set(QT_DEFAULT_SYS_CONF_DIR "etc/xdg")
+ endif()
+
+ # Compute and set relocation prefixes.
+ # TODO: Clean this up, there's a bunch of unrealistic assumptions here.
+ # See qtConfOutput_preparePaths in qtbase/configure.pri.
+ if(WIN32)
+ set(lib_location_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
+ else()
+ set(lib_location_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
+ endif()
+ file(RELATIVE_PATH from_lib_location_to_prefix
+ "${lib_location_absolute_path}" "${CMAKE_INSTALL_PREFIX}")
+
+ if(QT_HOST_PATH)
+ set(host_prefix "${QT_HOST_PATH}")
+ set(host_bin_dir_absolute_path "${QT_HOST_PATH}/${INSTALL_BINDIR}")
+ else()
+ set(host_prefix "${CMAKE_INSTALL_PREFIX}")
+ set(host_bin_dir_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
+ endif()
+
+ file(RELATIVE_PATH from_host_bin_dir_to_host_prefix
+ "${host_bin_dir_absolute_path}" "${host_prefix}")
+
+ # TODO: Fix this to use the equivalent of extprefix on CMake (CMAKE_STAGING_PREFIX?)
+ # For now just assume ext prefix is same as regular prefix.
+ file(RELATIVE_PATH from_host_bin_dir_to_ext_prefix
+ "${host_bin_dir_absolute_path}" "${CMAKE_INSTALL_PREFIX}")
+
+
+ set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}")
+ set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_host_bin_dir_to_host_prefix}")
+ set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_host_bin_dir_to_ext_prefix}")
+
+ configure_file(global/qconfig.cpp.in global/qconfig.cpp @ONLY)
+endfunction()
+
+function(qt_set_language_standards)
+ ## Use the latest standard the compiler supports (same as qt_common.prf)
+ if (QT_FEATURE_cxx2a)
+ set(CMAKE_CXX_STANDARD 20 PARENT_SCOPE)
+ elseif (QT_FEATURE_cxx17)
+ set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE)
+ elseif (QT_FEATURE_cxx14)
+ set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
+ elseif (QT_FEATURE_cxx11)
+ set(CMAKE_CXX_STANDARD 11 PARENT_SCOPE)
+ endif()
+
+ if (c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES)
+ set(CMAKE_C_STANDARD 11 PARENT_SCOPE)
+ elseif (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES)
+ set(CMAKE_C_STANDARD 99 PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Compatibility macros that should be removed once all their usages are removed.
+function(extend_target)
+ qt_extend_target(${ARGV})
+endfunction()
+
+function(add_qt_module)
+ qt_add_module(${ARGV})
+endfunction()
+
+function(add_qt_plugin)
+ qt_add_plugin(${ARGV})
+endfunction()
+
+function(add_qt_tool)
+ qt_add_tool(${ARGV})
+endfunction()
+
+function(add_qt_test)
+ qt_add_test(${ARGV})
+endfunction()
+
+function(add_qt_test_helper)
+ qt_add_test_helper(${ARGV})
+endfunction()
+
+function(add_qt_manual_test)
+ qt_add_manual_test(${ARGV})
+endfunction()
+
+function(add_qt_benchmark)
+ qt_add_benchmark(${ARGV})
+endfunction()
+
+function(add_qt_executable)
+ qt_add_executable(${ARGV})
+endfunction()
+
+function(add_qt_simd_part)
+ qt_add_simd_part(${ARGV})
+endfunction()
+
+function(add_qt_docs)
+ qt_add_docs(${ARGV})
+endfunction()
+
+function(add_qt_resource)
+ qt_add_resource(${ARGV})
+endfunction()
+
+function(add_qml_module)
+ qt_add_qml_module(${ARGV})
+endfunction()
+
+function(add_cmake_library)
+ qt_add_cmake_library(${ARGV})
+endfunction()
diff --git a/cmake/QtBuildInformation.cmake b/cmake/QtBuildInformation.cmake
new file mode 100644
index 0000000000..097192b2ab
--- /dev/null
+++ b/cmake/QtBuildInformation.cmake
@@ -0,0 +1,35 @@
+function(qt_print_feature_summary)
+ include(FeatureSummary)
+ feature_summary(WHAT PACKAGES_FOUND
+ REQUIRED_PACKAGES_NOT_FOUND
+ RECOMMENDED_PACKAGES_NOT_FOUND
+ OPTIONAL_PACKAGES_NOT_FOUND
+ RUNTIME_PACKAGES_NOT_FOUND
+ FATAL_ON_MISSING_REQUIRED_PACKAGES)
+endfunction()
+
+function(qt_print_build_instructions)
+ if((NOT PROJECT_NAME STREQUAL "QtBase" AND
+ NOT PROJECT_NAME STREQUAL "Qt") OR
+ QT_BUILD_STANDALONE_TESTS)
+
+ return()
+ endif()
+
+ set(build_command "cmake --build . --parallel")
+ set(install_command "cmake --install .")
+
+ message("Qt is now configured for building. Just run '${build_command}'.")
+ if(QT_WILL_INSTALL)
+ message("Once everything is built, you must run '${install_command}'.")
+ message("Qt will be installed into '${CMAKE_INSTALL_PREFIX}'")
+ else()
+ message("Once everything is built, Qt is installed.")
+ message("You should NOT run '${install_command}'")
+ message("Note that this build cannot be deployed to other machines or devices.")
+ endif()
+ message("To configure and build other modules, you can use the following convenience script:
+ ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qt-cmake")
+ message("\nIf reconfiguration fails for some reason, try to remove 'CMakeCache.txt' \
+from the build directory \n")
+endfunction()
diff --git a/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake b/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake
new file mode 100644
index 0000000000..51645f48d5
--- /dev/null
+++ b/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake
@@ -0,0 +1,217 @@
+#
+# Android specific functions/macros/properties required for building Qt Modules
+#
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_MODULE_INSTALL_DIR
+ BRIEF_DOCS
+ "Recorded install location for a Qt Module."
+ FULL_DOCS
+ "Recorded install location for a Qt Module. Used by qt_android_dependencies()."
+)
+
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_JAR_DEPENDENCIES
+ BRIEF_DOCS
+ "Qt Module Jar dependencies list."
+ FULL_DOCS
+ "Qt Module Jar dependencies list."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_BUNDLED_JAR_DEPENDENCIES
+ BRIEF_DOCS
+ "Qt Module Jars that should be bundled with it during packing."
+ FULL_DOCS
+ "Qt Module Jars that should be bundled with it during packing."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_LIB_DEPENDENCIES
+ BRIEF_DOCS
+ "Qt Module C++ libraries that should be bundled with it during packing."
+ FULL_DOCS
+ "Qt Module C++ libraries that should be bundled with it during packing."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_LIB_DEPENDENCY_REPLACEMENTS
+ BRIEF_DOCS
+ "Qt Module C++ libraries that can replace libraries declared with the QT_ANDROID_LIB_DEPENDENCIES property."
+ FULL_DOCS
+ "Qt Module C++ libraries that can replace libraries declared with the QT_ANDROID_LIB_DEPENDENCIES property."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_BUNDLED_FILES
+ BRIEF_DOCS
+ "Qt Module files that need to be bundled during packing."
+ FULL_DOCS
+ "Qt Module files that need to be bundled during packing."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_PERMISSIONS
+ BRIEF_DOCS
+ "Qt Module android permission list."
+ FULL_DOCS
+ "Qt Module android permission list."
+)
+# Generate Qt Module -android-dependencies.xml required by the
+# androiddeploytoolqt to successfully copy all the plugins and other dependent
+# items into tha APK
+function(qt_android_dependencies target)
+ get_target_property(target_type "${target}" TYPE)
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ return()
+ endif()
+
+ get_target_property(arg_JAR_DEPENDENCIES ${target} QT_ANDROID_JAR_DEPENDENCIES)
+ get_target_property(arg_BUNDLED_JAR_DEPENDENCIES ${target} QT_ANDROID_BUNDLED_JAR_DEPENDENCIES)
+ get_target_property(arg_LIB_DEPENDENCIES ${target} QT_ANDROID_LIB_DEPENDENCIES)
+ get_target_property(arg_LIB_DEPENDENCY_REPLACEMENTS ${target} QT_ANDROID_LIB_DEPENDENCY_REPLACEMENTS)
+ get_target_property(arg_BUNDLED_FILES ${target} QT_ANDROID_BUNDLED_FILES)
+ get_target_property(arg_PERMISSIONS ${target} QT_ANDROID_PERMISSIONS)
+ get_target_property(module_plugins ${target} MODULE_PLUGIN_TYPES)
+
+ if ((NOT module_plugins)
+ AND (NOT arg_JAR_DEPENDENCIES)
+ AND (NOT arg_LIB_DEPENDENCY_REPLACEMENTS)
+ AND (NOT arg_LIB_DEPENDENCIES)
+ AND (NOT arg_BUNDLED_JAR_DEPENDENCIES)
+ AND (NOT arg_PERMISSIONS)
+ AND (NOT arg_BUNDLED_FILES))
+ # None of the values were set, so there's nothing to do
+ return()
+ endif()
+
+
+ get_target_property(target_output_name ${target} OUTPUT_NAME)
+ if (NOT target_output_name)
+ set(target_name ${target})
+ else()
+ set(target_name ${target_output_name})
+ endif()
+
+ # mimic qmake's section and string splitting from
+ # mkspecs/feature/qt_android_deps.prf
+ macro(section string delimiter first second)
+ string(FIND ${string} ${delimiter} delimiter_location)
+ if (NOT ${delimiter_location} EQUAL -1)
+ string(SUBSTRING ${string} 0 ${delimiter_location} ${first})
+ math(EXPR delimiter_location "${delimiter_location} + 1")
+ string(SUBSTRING ${string} ${delimiter_location} -1 ${second})
+ else()
+ set(${first} ${string})
+ set(${second} "")
+ endif()
+ endmacro()
+
+ get_target_property(target_bin_dir ${target} BINARY_DIR)
+ set(dependency_file "${target_bin_dir}/${target_name}_${CMAKE_ANDROID_ARCH_ABI}-android-dependencies.xml")
+
+ set(file_contents "<rules><dependencies>\n")
+ string(APPEND file_contents "<lib name=\"${target_name}_${CMAKE_ANDROID_ARCH_ABI}\"><depends>\n")
+
+ # Jar Dependencies
+ if(arg_JAR_DEPENDENCIES)
+ foreach(jar_dependency IN LISTS arg_JAR_DEPENDENCIES)
+ section(${jar_dependency} ":" jar_file init_class)
+ if (init_class)
+ set(init_class "initClass=\"${init_class}\"")
+ endif()
+ file(TO_NATIVE_PATH ${jar_file} jar_file_native)
+ string(APPEND file_contents "<jar file=\"${jar_file_native}\" ${init_class} />\n")
+ endforeach()
+ endif()
+
+ # Bundled Jar Dependencies
+ if(arg_BUNDLED_JAR_DEPENDENCIES)
+ foreach(jar_bundle IN LISTS arg_BUNDLED_JAR_DEPENDENCIES)
+ section(${jar_bundle} ":" bundle_file init_calss)
+ if (init_class)
+ set(init_class "initClass=\"${init_class}\"")
+ endif()
+ file(TO_NATIVE_PATH ${jar_bundle} jar_bundle_native)
+ string(APPEND file_contents "<jar bundling=\"1\" file=\"${jar_bundle_native}\" ${init_class} />\n")
+ endforeach()
+ endif()
+
+ # Lib Dependencies
+ if(arg_LIB_DEPENDENCIES)
+ foreach(lib IN LISTS arg_LIB_DEPENDENCIES)
+ string(REPLACE ".so" "_${CMAKE_ANDROID_ARCH_ABI}.so" lib ${lib})
+ section(${lib} ":" lib_file lib_extends)
+ if (lib_extends)
+ set(lib_extends "extends=\"${lib_extends}\"")
+ endif()
+ file(TO_NATIVE_PATH ${lib_file} lib_file_native)
+ string(APPEND file_contents "<lib file=\"${lib_file_native}\" ${lib_extends} />\n")
+ endforeach()
+ endif()
+
+ # Lib Dependencies Replacements
+ if(arg_LIB_DEPENDENCY_REPLACEMENTS)
+ foreach(lib IN LISTS arg_LIB_DEPENDENCY_REPLACEMENTS)
+ string(REPLACE ".so" "_${CMAKE_ANDROID_ARCH_ABI}.so" lib ${lib})
+ section(${lib} ":" lib_file lib_replacement)
+ if (lib_replacement)
+ file(TO_NATIVE_PATH ${lib_replacement} lib_replacement_native)
+ set(lib_replacement "replaces=\"${lib_replacement_native}\"")
+ endif()
+ file(TO_NATIVE_PATH ${lib_file} lib_file_native)
+ string(APPEND file_contents "<lib file=\"${lib_file_native}\" ${lib_replacement} />\n")
+ endforeach()
+ endif()
+
+
+ # Bundled files
+ if(arg_BUNDLED_FILES)
+ foreach(file IN LISTS arg_BUNDLED_FILES)
+ file(TO_NATIVE_PATH ${lib_file} file_native)
+ string(APPEND file_contents "<bundled file=\"${file_native}\" />\n")
+ endforeach()
+ endif()
+
+ # Module plugins
+ if(module_plugins)
+ foreach(plugin IN LISTS module_plugins)
+ string(APPEND file_contents "<bundled file=\"plugins/${plugin}\" />\n")
+ endforeach()
+ endif()
+
+ # Android Permissions
+ if(arg_PERMISSIONS)
+ foreach(permission IN LISTS arg_PERMISSIONS)
+ string(APPEND file_contents "<permission name=\"${permission}\" />\n")
+ endforeach()
+ endif()
+
+ string(APPEND file_contents "</depends></lib>")
+ string(APPEND file_contents "</dependencies></rules>\n")
+ file(WRITE ${dependency_file} ${file_contents})
+
+ get_target_property(target_install_dir ${target} QT_ANDROID_MODULE_INSTALL_DIR)
+ if (NOT target_install_dir)
+ message(SEND_ERROR "qt_android_dependencies: Target ${target} is either not a Qt Module or has no recorded install location")
+ return()
+ endif()
+
+ # Copy file into install directory, required by the androiddeployqt tool.
+ qt_install(FILES
+ ${dependency_file}
+ DESTINATION
+ ${target_install_dir}
+ COMPONENT
+ Devel)
+endfunction()
+
+
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
new file mode 100644
index 0000000000..2703e06fe5
--- /dev/null
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -0,0 +1,237 @@
+if (CMAKE_VERSION VERSION_LESS 3.1.0)
+ message(FATAL_ERROR "Qt requires at least CMake version 3.1.0")
+endif()
+
+######################################
+#
+# Macros for building Qt modules
+#
+######################################
+
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake")
+ include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake)
+endif()
+
+macro(qt_set_up_build_internals_paths)
+ # Set up the paths for the cmake modules located in the prefix dir. Prepend, so the paths are
+ # least important compared to the source dir ones, but more important than command line
+ # provided ones.
+ set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}")
+ list(PREPEND CMAKE_MODULE_PATH "${QT_CMAKE_MODULE_PATH}")
+
+ # Prepend the qtbase source cmake directory to CMAKE_MODULE_PATH,
+ # so that if a change is done in cmake/QtBuild.cmake, it gets automatically picked up when
+ # building qtdeclarative, rather than having to build qtbase first (which will copy
+ # QtBuild.cmake to the build dir). This is similar to qmake non-prefix builds, where the
+ # source qtbase/mkspecs directory is used.
+ if(EXISTS "${QT_SOURCE_TREE}/cmake")
+ list(PREPEND CMAKE_MODULE_PATH "${QT_SOURCE_TREE}/cmake")
+ endif()
+
+ # If the repo has its own cmake modules, include those in the module path.
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ endif()
+
+ # Find the cmake files when doing a standalone tests build.
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
+ list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
+ endif()
+endmacro()
+
+# Set up the build internal paths unless explicitly requested not to.
+if(NOT QT_BUILD_INTERNALS_SKIP_CMAKE_MODULE_PATH_ADDITION)
+ qt_set_up_build_internals_paths()
+endif()
+
+# Define some constants to check for certain platforms, etc.
+# Needs to be loaded before qt_repo_build() to handle require() clauses before even starting a repo
+# build.
+include(QtPlatformSupport)
+
+macro(qt_build_repo_begin)
+ # Qt specific setup common for all modules:
+ include(QtSetup)
+ include(FeatureSummary)
+
+ # Optionally include a repo specific Setup module.
+ include(${PROJECT_NAME}Setup OPTIONAL)
+ include(QtRepoSetup OPTIONAL)
+
+ # Find Apple frameworks if needed.
+ qt_find_apple_system_frameworks()
+
+ # Decide whether tools will be built.
+ qt_check_if_tools_will_be_built()
+
+
+ string(TOLOWER ${PROJECT_NAME} project_name_lower)
+
+ set(qt_docs_target_name docs_${project_name_lower})
+ set(qt_docs_prepare_target_name prepare_docs_${project_name_lower})
+ set(qt_docs_generate_target_name generate_docs_${project_name_lower})
+ set(qt_docs_html_target_name html_docs_${project_name_lower})
+ set(qt_docs_qch_target_name qch_docs_${project_name_lower})
+ set(qt_docs_install_html_target_name install_html_docs_${project_name_lower})
+ set(qt_docs_install_qch_target_name install_qch_docs_${project_name_lower})
+ set(qt_docs_install_target_name install_docs_${project_name_lower})
+
+ add_custom_target(${qt_docs_target_name})
+ add_custom_target(${qt_docs_prepare_target_name})
+ add_custom_target(${qt_docs_generate_target_name})
+ add_custom_target(${qt_docs_qch_target_name})
+ add_custom_target(${qt_docs_html_target_name})
+ add_custom_target(${qt_docs_install_html_target_name})
+ add_custom_target(${qt_docs_install_qch_target_name})
+ add_custom_target(${qt_docs_install_target_name})
+
+ add_dependencies(${qt_docs_generate_target_name} ${qt_docs_prepare_target_name})
+ add_dependencies(${qt_docs_html_target_name} ${qt_docs_generate_target_name})
+ add_dependencies(${qt_docs_target_name} ${qt_docs_html_target_name} ${qt_docs_qch_target_name})
+ add_dependencies(${qt_docs_install_html_target_name} ${qt_docs_html_target_name})
+ add_dependencies(${qt_docs_install_qch_target_name} ${qt_docs_qch_target_name})
+ add_dependencies(${qt_docs_install_target_name} ${qt_docs_install_html_target_name} ${qt_docs_install_qch_target_name})
+endmacro()
+
+macro(qt_build_repo_end)
+ include(QtBuildInformation)
+
+ if(NOT QT_BUILD_STANDALONE_TESTS)
+ # Delayed actions on some of the Qt targets:
+ include(QtPostProcess)
+
+ # Install the repo-specific cmake find modules.
+ qt_path_join(__qt_repo_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE})
+
+ if(NOT PROJECT_NAME STREQUAL "QtBase")
+ if (EXISTS cmake)
+ qt_copy_or_install(DIRECTORY cmake/
+ DESTINATION "${__qt_repo_install_dir}"
+ FILES_MATCHING PATTERN "Find*.cmake"
+ )
+ endif()
+ endif()
+
+ if(NOT QT_SUPERBUILD)
+ qt_print_feature_summary()
+ endif()
+ endif()
+
+ if(NOT QT_SUPERBUILD)
+ qt_print_build_instructions()
+ endif()
+endmacro()
+
+macro(qt_build_repo)
+ qt_build_repo_begin(${ARGN})
+
+ # If testing is enabled, try to find the qtbase Test package.
+ # Do this before adding src, because there might be test related conditions
+ # in source.
+ if (BUILD_TESTING AND NOT QT_BUILD_STANDALONE_TESTS)
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
+ endif()
+
+ if(NOT QT_BUILD_STANDALONE_TESTS)
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
+ add_subdirectory(src)
+ endif()
+
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/CMakeLists.txt")
+ add_subdirectory(tools)
+ endif()
+ endif()
+
+ if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
+ add_subdirectory(tests)
+ if(QT_NO_MAKE_TESTS)
+ set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
+ endif()
+
+ qt_build_repo_end()
+
+ if (BUILD_EXAMPLES AND BUILD_SHARED_LIBS
+ AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt"
+ AND NOT QT_BUILD_STANDALONE_TESTS)
+ add_subdirectory(examples)
+ if(QT_NO_MAKE_EXAMPLES)
+ set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
+ endif()
+endmacro()
+
+macro(qt_set_up_standalone_tests_build)
+ # Remove this macro once all usages of it have been removed.
+ # Standalone tests are not handled via the main repo project and qt_build_tests.
+endmacro()
+
+macro(qt_build_tests)
+ if(QT_BUILD_STANDALONE_TESTS)
+ # Find location of TestsConfig.cmake. These contain the modules that need to be
+ # find_package'd when testing.
+ set(_qt_build_tests_install_prefix
+ "${QT_CONFIG_INSTALL_DIR}/${INSTALL_CMAKE_NAMESPACE}BuildInternals/StandaloneTests")
+ if(QT_WILL_INSTALL)
+ qt_path_join(_qt_build_tests_install_prefix
+ ${CMAKE_INSTALL_PREFIX} ${_qt_build_tests_install_prefix})
+ endif()
+ include("${_qt_build_tests_install_prefix}/${PROJECT_NAME}TestsConfig.cmake" OPTIONAL)
+
+ # Of course we always need the test module as well.
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
+ endif()
+
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/auto/CMakeLists.txt")
+ add_subdirectory(auto)
+ endif()
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt" AND QT_BUILD_BENCHMARKS)
+ add_subdirectory(benchmarks)
+ endif()
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/manual/CMakeLists.txt")
+ add_subdirectory(manual)
+ endif()
+endmacro()
+
+macro(qt_examples_build_begin)
+ # Examples that are built as part of the Qt build need to use the CMake config files from the
+ # build dir, because they are not installed yet in a prefix build.
+ # Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake.
+ # Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those
+ # find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored.
+ list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}")
+ list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}")
+ # Also make sure the CMake config files do not recreate the already-existing targets
+ set(QT_NO_CREATE_TARGETS TRUE)
+ set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH")
+endmacro()
+
+macro(qt_examples_build_end)
+ # 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" "rcc")
+ if(TARGET Qt::Widgets)
+ qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "uic")
+ endif()
+ endforeach()
+
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
+endmacro()
+
+if (ANDROID)
+ include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsAndroid.cmake)
+endif()
diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in
new file mode 100644
index 0000000000..5278890337
--- /dev/null
+++ b/cmake/QtBuildInternalsExtra.cmake.in
@@ -0,0 +1,37 @@
+# Propagate common variables via BuildInternals package.
+set(QT_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
+option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" @BUILD_SHARED_LIBS@)
+set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
+set(INSTALL_CMAKE_NAMESPACE @INSTALL_CMAKE_NAMESPACE@)
+set(QT_BUILD_INTERNALS_PATH "${CMAKE_CURRENT_LIST_DIR}")
+
+# Propagate the original install prefix, so that a developer building a child module can
+# specify CMAKE_PREFIX_PATH for finding the Qt modules instead of CMAKE_INSTALL_PREFIX.
+set(CMAKE_INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@ CACHE PATH
+ "Install path prefix, prepended onto install directories." FORCE)
+
+# Propagate developer builds to other modules via BuildInternals package.
+if(@FEATURE_developer_build@)
+ set(FEATURE_developer_build ON CACHE BOOL "Developer build." FORCE)
+endif()
+
+# Propagate non-prefix builds.
+set(QT_WILL_INSTALL @QT_WILL_INSTALL@ CACHE BOOL
+ "Boolean indicating if doing a Qt prefix build (vs non-prefix build)." FORCE)
+
+set(QT_SOURCE_TREE "@QT_SOURCE_TREE@" CACHE PATH
+"A path to the source tree of the previously configured QtBase project." FORCE)
+
+# Propagate decision of building tests and examples to other repositories.
+set(BUILD_TESTING @BUILD_TESTING@ CACHE BOOL "Build the testing tree.")
+set(BUILD_EXAMPLES @BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples")
+set(QT_NO_MAKE_TESTS @QT_NO_MAKE_TESTS@ CACHE BOOL
+ "Should tests be built as part of the default 'all' target.")
+set(QT_NO_MAKE_EXAMPLES @QT_NO_MAKE_EXAMPLES@ CACHE BOOL
+ "Should examples be built as part of the default 'all' target.")
+
+# Propagate usage of ccache.
+set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache")
+
+# Extra set of exported variables
+@QT_EXTRA_BUILD_INTERNALS_VARS@
diff --git a/cmake/QtCompilerFlags.cmake b/cmake/QtCompilerFlags.cmake
new file mode 100644
index 0000000000..35733027f5
--- /dev/null
+++ b/cmake/QtCompilerFlags.cmake
@@ -0,0 +1,6 @@
+# Set warnings. All compilers except MSVC support -Wall -Wextra
+if (MSVC)
+ add_compile_options(/W3)
+else()
+ add_compile_options(-Wall -Wextra)
+endif()
diff --git a/cmake/QtCompilerOptimization.cmake b/cmake/QtCompilerOptimization.cmake
new file mode 100644
index 0000000000..f1ebafc009
--- /dev/null
+++ b/cmake/QtCompilerOptimization.cmake
@@ -0,0 +1,123 @@
+if (QCC)
+ set(QT_CFLAGS_SSE2 "-msse2")
+ set(QT_CFLAGS_SSE3 "-msse3")
+ set(QT_CFLAGS_SSSE3 "-mssse3")
+ set(QT_CFLAGS_SSE4_1 "-msse4.1")
+ set(QT_CFLAGS_SSE4_2 "-msse4.2")
+ set(QT_CFLAGS_AVX "-mavx")
+ set(QT_CFLAGS_AVX2 "-mavx2")
+ set(QT_CFLAGS_AESNI "-maes")
+ set(QT_CFLAGS_SHANI "-msha")
+endif()
+
+if (MSVC)
+ if (QT_64BIT)
+ # SSE2 is mandatory on 64-bit mode, so skip the option. It triggers:
+ # cl : Command line warning D9002 : ignoring unknown option '-arch:SSE2'
+ set(QT_CFLAGS_SSE2 "")
+ else()
+ set(QT_CFLAGS_SSE2 "-arch:SSE2")
+ endif()
+ set(QT_CFLAGS_SSE3 "${QT_CFLAGS_SSE2}")
+ set(QT_CFLAGS_SSSE3 "${QT_CFLAGS_SSE2}")
+ set(QT_CFLAGS_SSE4_1 "${QT_CFLAGS_SSE2}")
+ set(QT_CFLAGS_SSE4_2 "${QT_CFLAGS_SSE2}")
+ set(QT_CFLAGS_AESNI "${QT_CFLAGS_SSE2}")
+ set(QT_CFLAGS_SHANI "${QT_CFLAGS_SSE2}")
+
+ # FIXME to be Visual Studio version specific, like in mkspecs/common/msvc-version.conf
+ set(QT_CFLAGS_AVX "-arch:AVX")
+ set(QT_CFLAGS_AVX2 "-arch:AVX2")
+ set(QT_CFLAGS_F16C "-arch:AVX")
+ set(QT_CFLAGS_RDRND "")
+ set(QT_CFLAGS_AVX512F "-arch:AVX512")
+ set(QT_CFLAGS_AVX512ER "-arch:AVX512")
+ set(QT_CFLAGS_AVX512CD "-arch:AVX512")
+ set(QT_CFLAGS_AVX512PF "-arch:AVX512")
+ set(QT_CFLAGS_AVX512DQ "-arch:AVX512")
+ set(QT_CFLAGS_AVX512BW "-arch:AVX512")
+ set(QT_CFLAGS_AVX512VL "-arch:AVX512")
+ set(QT_CFLAGS_AVX512IFMA "-arch:AVX512")
+ set(QT_CFLAGS_AVX512VBMI "-arch:AVX512")
+endif()
+
+if(GCC OR CLANG)
+ set(QT_CFLAGS_SSE2 "-msse2")
+ set(QT_CFLAGS_SSE3 "-msse3")
+ set(QT_CFLAGS_SSSE3 "-mssse3")
+ set(QT_CFLAGS_SSE4_1 "-msse4.1")
+ set(QT_CFLAGS_SSE4_2 "-msse4.2")
+ set(QT_CFLAGS_F16C "-mf16c")
+ set(QT_CFLAGS_RDRND "-mrdrnd")
+ set(QT_CFLAGS_AVX "-mavx")
+ set(QT_CFLAGS_AVX2 "-mavx2")
+ set(QT_CFLAGS_AVX512F "-mavx512f")
+ set(QT_CFLAGS_AVX512ER "-mavx512er")
+ set(QT_CFLAGS_AVX512CD "-mavx512cd")
+ set(QT_CFLAGS_AVX512PF "-mavx512pf")
+ set(QT_CFLAGS_AVX512DQ "-mavx512dq")
+ set(QT_CFLAGS_AVX512BW "-mavx512bw")
+ set(QT_CFLAGS_AVX512VL "-mavx512vl")
+ set(QT_CFLAGS_AVX512IFMA "-mavx512ifma")
+ set(QT_CFLAGS_AVX512VBMI "-mavx512vbmi")
+ set(QT_CFLAGS_AESNI "-maes")
+ set(QT_CFLAGS_SHANI "-msha")
+ if(NOT APPLE_UIKIT)
+ set(QT_CFLAGS_NEON "-mfpu=neon")
+ endif()
+ set(QT_CFLAGS_MIPS_DSP "-mdsp")
+ set(QT_CFLAGS_MIPS_DSPR2 "-mdspr2")
+endif()
+
+if (winrt) # FIXME: Correct variable
+ set(QT_CFLAGS_SSE2 "-arch:SSE2")
+ set(QT_CFLAGS_SSE3 "-arch:SSE2")
+ set(QT_CFLAGS_SSSE3 "-arch:SSE2")
+ set(QT_CFLAGS_SSE4_1 "-arch:SSE2")
+ set(QT_CFLAGS_SSE4_2 "-arch:SSE2")
+ set(QT_CFLAGS_AVX "-arch:AVX")
+ set(QT_CFLAGS_AVX2 "-arch:AVX")
+ set(QT_CFLAGS_AESNI "-arch:SSE2")
+ set(QT_CFLAGS_SHANI "-arch:SSE2")
+endif()
+
+if (ICC)
+ if (MSVC)
+ set(QT_CFLAGS_SSE2 "-QxSSE2")
+ set(QT_CFLAGS_SSE3 "-QxSSE3")
+ set(QT_CFLAGS_SSSE3 "-QxSSSE3")
+ set(QT_CFLAGS_SSE4_1 "-QxSSE4.1")
+ set(QT_CFLAGS_SSE4_2 "-QxSSE4.2")
+ set(QT_CFLAGS_AVX "-QxAVX")
+ set(QT_CFLAGS_AVX2 "-QxCORE-AVX2")
+ set(QT_CFLAGS_AVX512F "-QxCOMMON-AVX512")
+ set(QT_CFLAGS_AVX512CD "-QxCOMMON-AVX512")
+ set(QT_CFLAGS_AVX512ER "-QxMIC-AVX512")
+ set(QT_CFLAGS_AVX512PF "-QxMIC-AVX512")
+ set(QT_CFLAGS_AVX512DQ "-QxCORE-AVX512")
+ set(QT_CFLAGS_AVX512BW "-QxCORE-AVX512")
+ set(QT_CFLAGS_AVX512VL "-QxCORE-AVX512")
+ set(QT_CFLAGS_F16C "${QT_CFLAGS_AVX2}")
+ set(QT_CFLAGS_AESNI "-QxSSE2")
+ set(QT_CFLAGS_SHANI "-QxSSE4.2")
+ else()
+ set(QT_CFLAGS_SSE2 "-msse2")
+ set(QT_CFLAGS_SSE3 "-msse3")
+ set(QT_CFLAGS_SSSE3 "-mssse3")
+ set(QT_CFLAGS_SSE4_1 "-msse4.1")
+ set(QT_CFLAGS_SSE4_2 "-msse4.2")
+ set(QT_CFLAGS_AVX "-march=core-avx")
+ set(QT_CFLAGS_AVX2 "-march=core-avx2")
+ set(QT_CFLAGS_AVX512F "-march=broadwell -xCOMMON-AVX512")
+ set(QT_CFLAGS_AVX512CD "-march=broadwell -xCOMMON-AVX512")
+ set(QT_CFLAGS_AVX512ER "-march=knl")
+ set(QT_CFLAGS_AVX512PF "-march=knl")
+ set(QT_CFLAGS_AVX512DQ "-march=skylake-avx512")
+ set(QT_CFLAGS_AVX512BW "-march=skylake-avx512")
+ set(QT_CFLAGS_AVX512VL "-march=skylake-avx512")
+ set(QT_CFLAGS_AESNI "-maes")
+ set(QT_CFLAGS_F16C "${QT_CFLAGS_AVX2}")
+ set(QT_CFLAGS_RDRND "-mrdrnd")
+ set(QT_CFLAGS_SHANI "-msha")
+ endif()
+endif()
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
new file mode 100644
index 0000000000..6d69c1f90e
--- /dev/null
+++ b/cmake/QtConfig.cmake.in
@@ -0,0 +1,59 @@
+@PACKAGE_INIT@
+
+# Slightly amended version of ./src/corelib/Qt6Config.cmake.in
+if (CMAKE_VERSION VERSION_LESS 3.1.0)
+ message(FATAL_ERROR "Qt requires at least CMake version 3.1.0")
+endif()
+
+get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
+set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
+
+if (NOT QT_NO_CREATE_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
+ if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
+ endif()
+else()
+ # For examples using `find_package(...)` inside their CMakeLists.txt files:
+ # Make CMake's AUTOGEN detect this Qt version properly
+ set_directory_properties(PROPERTIES
+ QT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+ QT_VERSION_MINOR @PROJECT_VERSION_MINOR@
+ QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
+endif()
+
+# if (NOT @INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS)
+# set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "The Qt package requires at least one component")
+# set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
+# return()
+# endif()
+
+get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
+list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
+list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/extra-cmake-modules/find-modules")
+list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/kwin")
+
+foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
+ find_package(@INSTALL_CMAKE_NAMESPACE@${module}
+ ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
+ ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED}
+ PATHS ${_qt_cmake_dir} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
+ )
+ if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
+ string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
+
+ if (@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
+ set(_Qt_NOTFOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"\n")
+ elseif(NOT @INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
+ message(WARNING "Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"")
+ endif()
+
+ unset(_expected_module_location)
+ endif()
+endforeach()
+
+if (_Qt_NOTFOUND_MESSAGE)
+ set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
+ set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
+endif()
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
new file mode 100644
index 0000000000..faca42635c
--- /dev/null
+++ b/cmake/QtFeature.cmake
@@ -0,0 +1,760 @@
+function(qt_feature_module_begin)
+ qt_parse_all_arguments(arg "qt_feature_module_begin"
+ "NO_MODULE" "LIBRARY;PRIVATE_FILE;PUBLIC_FILE" "PUBLIC_DEPENDENCIES;PRIVATE_DEPENDENCIES" ${ARGN})
+
+ if ("${arg_LIBRARY}" STREQUAL "" AND (NOT ${arg_NO_MODULE}))
+ message(FATAL_ERROR "qt_feature_begin_module needs a LIBRARY name! (or specify NO_MODULE)")
+ endif()
+ if ("${arg_PUBLIC_FILE}" STREQUAL "")
+ message(FATAL_ERROR "qt_feature_begin_module needs a PUBLIC_FILE name!")
+ endif()
+ if ("${arg_PRIVATE_FILE}" STREQUAL "")
+ message(FATAL_ERROR "qt_feature_begin_module needs a PRIVATE_FILE name!")
+ endif()
+
+ set(__QtFeature_library "${arg_LIBRARY}" PARENT_SCOPE)
+ set(__QtFeature_public_features "" PARENT_SCOPE)
+ set(__QtFeature_private_features "" PARENT_SCOPE)
+ set(__QtFeature_internal_features "" PARENT_SCOPE)
+
+ set(__QtFeature_private_file "${arg_PRIVATE_FILE}" PARENT_SCOPE)
+ set(__QtFeature_public_file "${arg_PUBLIC_FILE}" PARENT_SCOPE)
+
+ set(__QtFeature_private_extra "" PARENT_SCOPE)
+ set(__QtFeature_public_extra "" PARENT_SCOPE)
+
+ set(__QtFeature_config_definitions "" PARENT_SCOPE)
+
+ set(__QtFeature_define_definitions "" PARENT_SCOPE)
+endfunction()
+
+function(qt_feature_normalize_name name out_var)
+ # Normalize the feature name to something CMake can deal with.
+ if(name MATCHES "c\\+\\+")
+ string(REGEX REPLACE "[^a-zA-Z0-9_]" "x" name "${name}")
+ else()
+ string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" name "${name}")
+ endif()
+ set(${out_var} "${name}" PARENT_SCOPE)
+endfunction()
+
+function(qt_feature feature)
+ set(original_name "${feature}")
+ qt_feature_normalize_name("${feature}" feature)
+ set_property(GLOBAL PROPERTY QT_FEATURE_ORIGINAL_NAME_${feature} "${original_name}")
+
+ qt_parse_all_arguments(arg "qt_feature"
+ "PRIVATE;PUBLIC"
+ "LABEL;PURPOSE;SECTION;" "AUTODETECT;CONDITION;ENABLE;DISABLE;EMIT_IF" ${ARGN})
+
+ set(_QT_FEATURE_DEFINITION_${feature} ${ARGN} PARENT_SCOPE)
+
+ # Register feature for future use:
+ if (arg_PUBLIC)
+ list(APPEND __QtFeature_public_features "${feature}")
+ endif()
+ if (arg_PRIVATE)
+ list(APPEND __QtFeature_private_features "${feature}")
+ endif()
+ if (NOT arg_PUBLIC AND NOT arg_PRIVATE)
+ list(APPEND __QtFeature_internal_features "${feature}")
+ endif()
+
+
+ set(__QtFeature_public_features ${__QtFeature_public_features} PARENT_SCOPE)
+ set(__QtFeature_private_features ${__QtFeature_private_features} PARENT_SCOPE)
+ set(__QtFeature_internal_features ${__QtFeature_internal_features} PARENT_SCOPE)
+endfunction()
+
+function(qt_evaluate_to_boolean expressionVar)
+ if(${${expressionVar}})
+ set(${expressionVar} ON PARENT_SCOPE)
+ else()
+ set(${expressionVar} OFF PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(qt_evaluate_config_expression resultVar)
+ set(result "")
+ set(nestingLevel 0)
+ set(skipNext OFF)
+ set(expression "${ARGN}")
+ list(LENGTH expression length)
+
+ math(EXPR length "${length}-1")
+ foreach(memberIdx RANGE ${length})
+ if(${skipNext})
+ set(skipNext OFF)
+ continue()
+ endif()
+
+ list(GET expression ${memberIdx} member)
+
+ if("${member}" STREQUAL "(")
+ if(${nestingLevel} GREATER 0)
+ list(APPEND result ${member})
+ endif()
+ math(EXPR nestingLevel "${nestingLevel} + 1")
+ continue()
+ elseif("${member}" STREQUAL ")")
+ math(EXPR nestingLevel "${nestingLevel} - 1")
+ if(nestingLevel LESS 0)
+ break()
+ endif()
+ if(${nestingLevel} EQUAL 0)
+ qt_evaluate_config_expression(result ${result})
+ else()
+ list(APPEND result ${member})
+ endif()
+ continue()
+ elseif(${nestingLevel} GREATER 0)
+ list(APPEND result ${member})
+ continue()
+ elseif("${member}" STREQUAL "NOT")
+ list(APPEND result ${member})
+ continue()
+ elseif("${member}" STREQUAL "AND")
+ qt_evaluate_to_boolean(result)
+ if(NOT ${result})
+ break()
+ endif()
+ set(result "")
+ elseif("${member}" STREQUAL "OR")
+ qt_evaluate_to_boolean(result)
+ if(${result})
+ break()
+ endif()
+ set(result "")
+ elseif("${member}" STREQUAL "STREQUAL" AND memberIdx LESS ${length})
+ # Unfortunately the semantics for STREQUAL in if() are broken when the
+ # RHS is an empty string and the parameters to if are coming through a variable.
+ # So we expect people to write the empty string with single quotes and then we
+ # do the comparison manually here.
+ list(LENGTH result lhsIndex)
+ math(EXPR lhsIndex "${lhsIndex}-1")
+ list(GET result ${lhsIndex} lhs)
+ list(REMOVE_AT result ${lhsIndex})
+ set(lhs "${${lhs}}")
+
+ math(EXPR rhsIndex "${memberIdx}+1")
+ set(skipNext ON)
+
+ list(GET expression ${rhsIndex} rhs)
+ # We can't pass through an empty string with double quotes through various
+ # stages of substitution, so instead it is represented using single quotes
+ # and resolve here.
+ string(REGEX REPLACE "'(.*)'" "\\1" rhs "${rhs}")
+
+ string(COMPARE EQUAL "${lhs}" "${rhs}" stringCompareResult)
+ list(APPEND result ${stringCompareResult})
+ else()
+ string(FIND "${member}" "QT_FEATURE_" idx)
+ if(idx EQUAL 0)
+ # Remove the QT_FEATURE_ prefix
+ string(SUBSTRING "${member}" 11 -1 feature)
+ qt_evaluate_feature(${feature})
+ endif()
+
+ list(APPEND result ${member})
+ endif()
+ endforeach()
+ # The 'TARGET Gui' case is handled by qt_evaluate_to_boolean, by passing those tokens verbatim
+ # to if().
+
+ if("${result}" STREQUAL "")
+ set(result ON)
+ else()
+ qt_evaluate_to_boolean(result)
+ endif()
+
+ set(${resultVar} ${result} PARENT_SCOPE)
+endfunction()
+
+function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
+ if (DEFINED "FEATURE_${feature}")
+ # Must set up the cache
+ if (NOT (emit_if))
+ message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} that was not emitted was found in the CMakeCache.")
+ endif()
+
+ # Revisit value:
+ set(cache "${FEATURE_${feature}}")
+ set(booly_values OFF NO FALSE N ON YES TRUE Y)
+ if ((cache IN_LIST booly_values) OR (cache GREATER_EQUAL 0))
+ set(result "${cache}")
+ else()
+ message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} has invalid value \"${cache}\"!")
+ endif()
+ # Fix-up user-provided values
+ set("FEATURE_${feature}" "${cache}" CACHE BOOL "${label}")
+ else()
+ # Initial setup:
+ if (emit_if)
+ set("FEATURE_${feature}" "${calculated}" CACHE BOOL "${label}")
+ set(result "${calculated}")
+ else()
+ set(result OFF)
+ endif()
+ endif()
+
+ set("${resultVar}" "${result}" PARENT_SCOPE)
+endfunction()
+
+macro(qt_feature_set_value feature cache emit_if condition label)
+ set(result "${cache}")
+
+ if (NOT (condition) AND (cache))
+ message(SEND_ERROR "Feature \"${feature}\": Forcing to \"${cache}\" breaks its condition.")
+ endif()
+
+ if (DEFINED "QT_FEATURE_${feature}")
+ message(FATAL_ERROR "Feature ${feature} is already defined when evaluating configure.cmake features for ${target}.")
+ endif()
+ set(QT_FEATURE_${feature} "${result}" CACHE INTERNAL "Qt feature: ${feature}")
+endmacro()
+
+function(qt_evaluate_feature feature)
+ # If the feature was set explicitly by the user to be on or off, in the cache, then
+ # there's nothing for us to do.
+ if(DEFINED "QT_FEATURE_${feature}")
+ return()
+ endif()
+
+ if(NOT DEFINED _QT_FEATURE_DEFINITION_${feature})
+ qt_debug_print_variables(DEDUP MATCH "^QT_FEATURE")
+ message(FATAL_ERROR "Attempting to evaluate feature ${feature} but its definition is missing. Either the feature does not exist or a dependency to the module that defines it is missing")
+ endif()
+
+ cmake_parse_arguments(arg
+ "PRIVATE;PUBLIC"
+ "LABEL;PURPOSE;SECTION;" "AUTODETECT;CONDITION;ENABLE;DISABLE;EMIT_IF" ${_QT_FEATURE_DEFINITION_${feature}})
+
+ if(DEFINED QT_FEATURE_${feature})
+ return()
+ endif()
+
+ if("${arg_ENABLE}" STREQUAL "")
+ set(arg_ENABLE OFF)
+ endif()
+
+ if("${arg_DISABLE}" STREQUAL "")
+ set(arg_DISABLE OFF)
+ endif()
+
+ if("${arg_AUTODETECT}" STREQUAL "")
+ set(arg_AUTODETECT ON)
+ endif()
+
+ if("${arg_CONDITION}" STREQUAL "")
+ set(condition ON)
+ else()
+ qt_evaluate_config_expression(condition ${arg_CONDITION})
+ endif()
+
+ qt_evaluate_config_expression(disable_result ${arg_DISABLE})
+ qt_evaluate_config_expression(enable_result ${arg_ENABLE})
+ if(${disable_result})
+ set(result OFF)
+ elseif((${enable_result}) OR (${arg_AUTODETECT}))
+ set(result ${condition})
+ else()
+ # feature not auto-detected and not explicitly enabled
+ set(result OFF)
+ endif()
+
+ if("${arg_EMIT_IF}" STREQUAL "")
+ set(emit_if ON)
+ else()
+ qt_evaluate_config_expression(emit_if ${arg_EMIT_IF})
+ endif()
+
+ if (NOT (condition) AND (calculated))
+ message(FATAL_ERROR "Sanity check failed: Feature ${feature} is enabled but condition does not hold true.")
+ endif()
+
+ qt_feature_set_cache_value(cache "${feature}" "${emit_if}" "${result}" "${arg_LABEL}")
+ qt_feature_set_value("${feature}" "${cache}" "${emit_if}" "${condition}" "${arg_LABEL}")
+endfunction()
+
+function(qt_feature_config feature config_var_name)
+ qt_feature_normalize_name("${feature}" feature)
+ qt_parse_all_arguments(arg "qt_feature_config" "NEGATE" "NAME" "" ${ARGN})
+
+ # Store all the config related info in a unique variable key.
+ set(key_name "_QT_FEATURE_CONFIG_DEFINITION_${feature}_${config_var_name}")
+ set(${key_name} "FEATURE;${feature};CONFIG_VAR_NAME;${config_var_name};${ARGN}" PARENT_SCOPE)
+
+ # Store the key for later evaluation.
+ list(APPEND __QtFeature_config_definitions "${key_name}")
+
+ set(__QtFeature_config_definitions ${__QtFeature_config_definitions} PARENT_SCOPE)
+endfunction()
+
+function(qt_evaluate_qmake_config_values key)
+ if(NOT DEFINED ${key})
+ qt_debug_print_variables(DEDUP MATCH "^_QT_FEATURE_CONFIG_DEFINITION")
+ message(FATAL_ERROR
+ "Attempting to evaluate feature config ${key} but its definition is missing. ")
+ endif()
+
+ cmake_parse_arguments(arg
+ "NEGATE"
+ "FEATURE;NAME;CONFIG_VAR_NAME"
+ "" ${${key}})
+
+ set(expected "NOT")
+ if (arg_NEGATE)
+ set(expected "")
+ endif()
+
+ # If no custom name is specified, then the config value is the same as the feature name.
+ if(NOT arg_NAME)
+ set(arg_NAME "${arg_FEATURE}")
+ endif()
+
+ # The feature condition is false, there is no need to export any config values.
+ if(${expected} ${QT_FEATURE_${arg_FEATURE}})
+ return()
+ endif()
+
+ if(arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PUBLIC_CONFIG")
+ list(APPEND __QtFeature_qmake_public_config "${arg_NAME}")
+ set(__QtFeature_qmake_public_config "${__QtFeature_qmake_public_config}" PARENT_SCOPE)
+ endif()
+ if(arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PRIVATE_CONFIG")
+ list(APPEND __QtFeature_qmake_private_config "${arg_NAME}")
+ set(__QtFeature_qmake_private_config "${__QtFeature_qmake_private_config}" PARENT_SCOPE)
+ endif()
+ if(arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PUBLIC_QT_CONFIG")
+ list(APPEND __QtFeature_qmake_public_qt_config "${arg_NAME}")
+ set(__QtFeature_qmake_public_qt_config "${__QtFeature_qmake_public_qt_config}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(qt_feature_definition feature name)
+ qt_feature_normalize_name("${feature}" feature)
+ qt_parse_all_arguments(arg "qt_feature_definition" "NEGATE" "VALUE" "" ${ARGN})
+
+ # Store all the define related info in a unique variable key.
+ set(key_name "_QT_FEATURE_DEFINE_DEFINITION_${feature}_${name}")
+ set(${key_name} "FEATURE;${feature};NAME;${name};${ARGN}" PARENT_SCOPE)
+
+ # Store the key for later evaluation and subsequent define generation:
+ list(APPEND __QtFeature_define_definitions "${key_name}")
+
+ set(__QtFeature_define_definitions ${__QtFeature_define_definitions} PARENT_SCOPE)
+endfunction()
+
+function(qt_evaluate_feature_definition key)
+ if(NOT DEFINED ${key})
+ qt_debug_print_variables(DEDUP MATCH "^_QT_FEATURE_DEFINE_DEFINITION")
+ message(FATAL_ERROR "Attempting to evaluate feature define ${key} but its definition is missing. ")
+ endif()
+
+ cmake_parse_arguments(arg
+ "NEGATE;"
+ "FEATURE;NAME;VALUE;" "" ${${key}})
+
+ set(expected ON)
+ if (arg_NEGATE)
+ set(expected OFF)
+ endif()
+
+ set(msg "")
+
+ if(QT_FEATURE_${arg_FEATURE} STREQUAL expected)
+ if (arg_VALUE)
+ string(APPEND msg "#define ${arg_NAME} ${arg_VALUE}\n")
+ else()
+ string(APPEND msg "#define ${arg_NAME}\n")
+ endif()
+
+ string(APPEND __QtFeature_public_extra "${msg}")
+ endif()
+
+ set(__QtFeature_public_extra ${__QtFeature_public_extra} PARENT_SCOPE)
+endfunction()
+
+function(qt_extra_definition name value)
+ qt_parse_all_arguments(arg "qt_extra_definition" "PUBLIC;PRIVATE" "" "" ${ARGN})
+
+ if (arg_PUBLIC)
+ string(APPEND __QtFeature_public_extra "\n#define ${name} ${value}\n")
+ elseif(arg_PRIVATE)
+ string(APPEND __QtFeature_private_extra "\n#define ${name} ${value}\n")
+ endif()
+
+ set(__QtFeature_public_extra ${__QtFeature_public_extra} PARENT_SCOPE)
+ set(__QtFeature_private_extra ${__QtFeature_private_extra} PARENT_SCOPE)
+endfunction()
+
+function(qt_internal_generate_feature_line line feature)
+ if (QT_FEATURE_${feature} STREQUAL "ON")
+ set(line "#define QT_FEATURE_${feature} 1\n\n" PARENT_SCOPE)
+ elseif(QT_FEATURE_${feature} STREQUAL "OFF")
+ set(line "#define QT_FEATURE_${feature} -1\n\n" PARENT_SCOPE)
+ elseif(QT_FEATURE_${feature} STREQUAL "UNSET")
+ set(line "#define QT_FEATURE_${feature} 0\n\n" PARENT_SCOPE)
+ else()
+ message(FATAL_ERROR "${feature} has unexpected value \"${QT_FEATURE_${feature}}\"!")
+ endif()
+endfunction()
+
+function(qt_internal_feature_write_file file features extra)
+ message("Generating file ${file}.")
+ set(contents "")
+ foreach(it ${features})
+ qt_internal_generate_feature_line(line "${it}")
+ string(APPEND contents "${line}")
+ endforeach()
+ string(APPEND contents "${extra}")
+
+ file(GENERATE OUTPUT "${file}" CONTENT "${contents}")
+endfunction()
+
+function(qt_feature_module_end)
+ set(flags)
+ set(options OUT_VAR_PREFIX)
+ set(multiopts)
+ cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN})
+ set(target ${arg_UNPARSED_ARGUMENTS})
+
+ # The value of OUT_VAR_PREFIX is used as a prefix for output variables that should be
+ # set in the parent scope.
+ if(NOT arg_OUT_VAR_PREFIX)
+ set(arg_OUT_VAR_PREFIX "")
+ endif()
+
+ set(all_features ${__QtFeature_public_features} ${__QtFeature_private_features} ${__QtFeature_internal_features})
+ list(REMOVE_DUPLICATES all_features)
+
+ foreach(feature ${all_features})
+ qt_evaluate_feature(${feature})
+ endforeach()
+
+ # Evaluate custom cache assignments.
+ foreach(cache_var_name ${__QtFeature_custom_enabled_cache_variables})
+ set(${cache_var_name} ON CACHE BOOL "Force enabled by platform." FORCE)
+ endforeach()
+ foreach(cache_var_name ${__QtFeature_custom_disabled_cache_variables})
+ set(${cache_var_name} OFF CACHE BOOL "Force disabled by platform." FORCE)
+ endforeach()
+
+ set(enabled_public_features "")
+ set(disabled_public_features "")
+ set(enabled_private_features "")
+ set(disabled_private_features "")
+
+ foreach(feature ${__QtFeature_public_features})
+ if(QT_FEATURE_${feature})
+ list(APPEND enabled_public_features ${feature})
+ else()
+ list(APPEND disabled_public_features ${feature})
+ endif()
+ endforeach()
+
+ foreach(feature ${__QtFeature_private_features})
+ if(QT_FEATURE_${feature})
+ list(APPEND enabled_private_features ${feature})
+ else()
+ list(APPEND disabled_private_features ${feature})
+ endif()
+ endforeach()
+
+ foreach(key ${__QtFeature_config_definitions})
+ qt_evaluate_qmake_config_values(${key})
+ unset(${key} PARENT_SCOPE)
+ endforeach()
+
+ foreach(key ${__QtFeature_define_definitions})
+ qt_evaluate_feature_definition(${key})
+ unset(${key} PARENT_SCOPE)
+ endforeach()
+
+ foreach(feature ${all_features})
+ unset(_QT_FEATURE_DEFINITION_${feature} PARENT_SCOPE)
+ endforeach()
+
+ qt_internal_feature_write_file("${CMAKE_CURRENT_BINARY_DIR}/${__QtFeature_private_file}"
+ "${__QtFeature_private_features}" "${__QtFeature_private_extra}"
+ )
+
+ qt_internal_feature_write_file("${CMAKE_CURRENT_BINARY_DIR}/${__QtFeature_public_file}"
+ "${__QtFeature_public_features}" "${__QtFeature_public_extra}"
+ )
+
+ # Extra header injections which have to have forwarding headers created by
+ # qt_install_injections.
+ # Skip creating forwarding headers if qt_feature_module_begin was called with NO_MODULE, aka
+ # there is no include/<module_name> so there's no place to put the forwarding headers.
+ if(__QtFeature_library)
+ set(injections "")
+ qt_compute_injection_forwarding_header("${__QtFeature_library}"
+ SOURCE "${__QtFeature_public_file}"
+ OUT_VAR injections)
+ qt_compute_injection_forwarding_header("${__QtFeature_library}"
+ SOURCE "${__QtFeature_private_file}" PRIVATE
+ OUT_VAR injections)
+
+ set(${arg_OUT_VAR_PREFIX}extra_library_injections ${injections} PARENT_SCOPE)
+ endif()
+
+ if (NOT ("${target}" STREQUAL "NO_MODULE"))
+ get_target_property(targetType "${target}" TYPE)
+ if("${targetType}" STREQUAL "INTERFACE_LIBRARY")
+ set(propertyPrefix "INTERFACE_")
+ else()
+ set(propertyPrefix "")
+ set_target_properties("${target}" PROPERTIES EXPORT_PROPERTIES "QT_ENABLED_PUBLIC_FEATURES;QT_DISABLED_PUBLIC_FEATURES;QT_ENABLED_PRIVATE_FEATURES;QT_DISABLED_PRIVATE_FEATURES;MODULE_PLUGIN_TYPES;QT_PLUGINS;QT_QMAKE_PUBLIC_CONFIG;QT_QMAKE_PRIVATE_CONFIG;QT_QMAKE_PUBLIC_QT_CONFIG")
+ endif()
+ foreach(visibility public private)
+ string(TOUPPER "${visibility}" capitalVisibility)
+ foreach(state enabled disabled)
+ string(TOUPPER "${state}" capitalState)
+
+ set_property(TARGET "${target}" PROPERTY ${propertyPrefix}QT_${capitalState}_${capitalVisibility}_FEATURES "${${state}_${visibility}_features}")
+ endforeach()
+ endforeach()
+
+ set_property(TARGET "${target}"
+ PROPERTY ${propertyPrefix}QT_QMAKE_PUBLIC_CONFIG
+ "${__QtFeature_qmake_public_config}")
+ set_property(TARGET "${target}"
+ PROPERTY ${propertyPrefix}QT_QMAKE_PRIVATE_CONFIG
+ "${__QtFeature_qmake_private_config}")
+ set_property(TARGET "${target}"
+ PROPERTY ${propertyPrefix}QT_QMAKE_PUBLIC_QT_CONFIG
+ "${__QtFeature_qmake_public_qt_config}")
+
+ # Config values were the old-school features before actual configure.json features were
+ # implemented. Therefore "CONFIG+=foo" values should be considered features as well,
+ # so that CMake can find them when building qtmultimedia for example.
+ if(__QtFeature_qmake_public_config)
+ set_property(TARGET "${target}"
+ APPEND PROPERTY ${propertyPrefix}QT_ENABLED_PUBLIC_FEATURES
+ ${__QtFeature_qmake_public_config})
+ endif()
+ if(__QtFeature_qmake_private_config)
+ set_property(TARGET "${target}"
+ APPEND PROPERTY ${propertyPrefix}QT_ENABLED_PRIVATE_FEATURES
+ ${__QtFeature_qmake_private_config})
+ endif()
+ if(__QtFeature_qmake_public_qt_config)
+ set_property(TARGET "${target}"
+ APPEND PROPERTY ${propertyPrefix}QT_ENABLED_PUBLIC_FEATURES
+ ${__QtFeature_qmake_public_qt_config})
+ endif()
+
+ qt_feature_copy_global_config_features_to_core(${target})
+ endif()
+
+ unset(__QtFeature_library PARENT_SCOPE)
+ unset(__QtFeature_public_features PARENT_SCOPE)
+ unset(__QtFeature_private_features PARENT_SCOPE)
+ unset(__QtFeature_internal_features PARENT_SCOPE)
+
+ unset(__QtFeature_private_file PARENT_SCOPE)
+ unset(__QtFeature_public_file PARENT_SCOPE)
+
+ unset(__QtFeature_private_extra PARENT_SCOPE)
+ unset(__QtFeature_public_extra PARENT_SCOPE)
+
+ unset(__QtFeature_define_definitions PARENT_SCOPE)
+ unset(__QtFeature_custom_enabled_features PARENT_SCOPE)
+ unset(__QtFeature_custom_disabled_features PARENT_SCOPE)
+endfunction()
+
+function(qt_feature_copy_global_config_features_to_core target)
+ # CMake doesn't support setting custom properties on exported INTERFACE libraries
+ # See https://gitlab.kitware.com/cmake/cmake/issues/19261.
+ # To circumvent that, copy the properties from GlobalConfig to Core target.
+ # This way the global features actually get set in the generated CoreTargets.cmake file.
+ if(target STREQUAL Core)
+ foreach(visibility public private)
+ string(TOUPPER "${visibility}" capitalVisibility)
+ foreach(state enabled disabled)
+ string(TOUPPER "${state}" capitalState)
+
+ set(core_property_name "QT_${capitalState}_${capitalVisibility}_FEATURES")
+ set(global_property_name "INTERFACE_${core_property_name}")
+
+ get_property(core_values TARGET Core PROPERTY ${core_property_name})
+ get_property(global_values TARGET GlobalConfig PROPERTY ${global_property_name})
+
+ set(total_values ${core_values} ${global_values})
+ set_property(TARGET Core PROPERTY ${core_property_name} ${total_values})
+ endforeach()
+ endforeach()
+
+ set(config_property_names
+ QT_QMAKE_PUBLIC_CONFIG QT_QMAKE_PRIVATE_CONFIG QT_QMAKE_PUBLIC_QT_CONFIG )
+ foreach(property_name ${config_property_names})
+ set(core_property_name "${property_name}")
+ set(global_property_name "INTERFACE_${core_property_name}")
+
+ get_property(core_values TARGET Core PROPERTY ${core_property_name})
+ get_property(global_values TARGET GlobalConfig PROPERTY ${global_property_name})
+
+ set(total_values ${core_values} ${global_values})
+ set_property(TARGET Core PROPERTY ${core_property_name} ${total_values})
+ endforeach()
+ endif()
+endfunction()
+
+function(qt_config_compile_test name)
+ if(DEFINED "TEST_${name}")
+ return()
+ endif()
+
+ cmake_parse_arguments(arg "" "LABEL;PROJECT_PATH;C_STANDARD;CXX_STANDARD" "LIBRARIES;CODE" ${ARGN})
+
+ if(arg_PROJECT_PATH)
+ message(STATUS "Performing Test ${arg_LABEL}")
+ try_compile(HAVE_${name} "${CMAKE_BINARY_DIR}/config.tests/${name}" "${arg_PROJECT_PATH}"
+ "${name}")
+
+ if(${HAVE_${name}})
+ set(status_label "Success")
+ else()
+ set(status_label "Failed")
+ endif()
+ message(STATUS "Performing Test ${arg_LABEL} - ${status_label}")
+ else()
+ foreach(library IN ITEMS ${arg_LIBRARIES})
+ if(NOT TARGET "${library}")
+ # If the dependency looks like a cmake target, then make this compile test
+ # fail instead of cmake abort later via CMAKE_REQUIRED_LIBRARIES.
+ string(FIND "${library}" "::" cmake_target_namespace_separator)
+ if(NOT cmake_target_namespace_separator EQUAL -1)
+ set(HAVE_${name} FALSE)
+ break()
+ endif()
+ endif()
+ endforeach()
+
+ if(NOT DEFINED HAVE_${name})
+ set(_save_CMAKE_C_STANDARD "${CMAKE_C_STANDARD}")
+ set(_save_CMAKE_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
+
+ if(arg_C_STANDARD)
+ set(CMAKE_C_STANDARD "${arg_C_STANDARD}")
+ endif()
+
+ if(arg_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}")
+ endif()
+
+ set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
+ set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
+ check_cxx_source_compiles("${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name})
+ set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
+
+ set(CMAKE_C_STANDARD "${_save_CMAKE_C_STANDARD}")
+ set(CMAKE_CXX_STANDARD "${_save_CMAKE_CXX_STANDARD}")
+ endif()
+ endif()
+
+ set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}")
+endfunction()
+
+# This function should be used for passing required try compile platform variables to the
+# project-based try_compile() call.
+# out_var will be a list of -Dfoo=bar strings, suitable to pass to CMAKE_FLAGS.
+function(qt_get_platform_try_compile_vars out_var)
+ # Use the regular variables that are used for source-based try_compile() calls.
+ set(flags "${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}")
+
+ # Pass toolchain files.
+ if(CMAKE_TOOLCHAIN_FILE)
+ list(APPEND flags "CMAKE_TOOLCHAIN_FILE")
+ endif()
+ if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ list(APPEND flags "VCPKG_CHAINLOAD_TOOLCHAIN_FILE")
+ endif()
+
+ # Assemble the list with regular options.
+ set(flags_cmd_line "")
+ foreach(flag ${flags})
+ if(${flag})
+ list(APPEND flags_cmd_line "-D${flag}=${${flag}}")
+ endif()
+ endforeach()
+
+ # Pass darwin specific options.
+ if(APPLE_UIKIT)
+ if(CMAKE_OSX_ARCHITECTURES)
+ list(GET CMAKE_OSX_ARCHITECTURES 0 osx_first_arch)
+
+ # Do what qmake does, aka when doing a simulator_and_device build, build the
+ # target architecture test only with the first given architecture, which should be the
+ # device architecture, aka some variation of "arm" (armv7, arm64).
+ list(APPEND flags_cmd_line "-DCMAKE_OSX_ARCHITECTURES:STRING=${osx_first_arch}")
+ endif()
+ # Also specify the sysroot, but only if not doing a simulator_and_device build.
+ # So keep the sysroot empty for simulator_and_device builds.
+ if(QT_UIKIT_SDK)
+ list(APPEND flags_cmd_line "-DCMAKE_OSX_SYSROOT:STRING=${QT_UIKIT_SDK}")
+ endif()
+ endif()
+
+ set("${out_var}" "${flags_cmd_line}" PARENT_SCOPE)
+endfunction()
+
+function(qt_config_compile_test_x86simd extension label)
+ if (DEFINED TEST_X86SIMD_${extension})
+ return()
+ endif()
+
+ set(flags "-DSIMD:string=${extension}")
+
+ qt_get_platform_try_compile_vars(platform_try_compile_vars)
+ list(APPEND flags ${platform_try_compile_vars})
+
+ message(STATUS "Performing SIMD Test ${label}")
+ try_compile("TEST_X86SIMD_${extension}"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.tests/x86_simd_${extension}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/config.tests/x86_simd"
+ x86_simd
+ CMAKE_FLAGS ${flags})
+ if(${TEST_X86SIMD_${extension}})
+ set(status_label "Success")
+ else()
+ set(status_label "Failed")
+ endif()
+ message(STATUS "Performing SIMD Test ${label} - ${status_label}")
+ set(TEST_subarch_${extension} "${TEST_X86SIMD_${extension}}" CACHE INTERNAL "${label}")
+endfunction()
+
+function(qt_make_features_available target)
+ if(NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z][a-zA-Z0-9_-]*$")
+ message(FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z][a-zA-Z0-9_-]*. INVALID NAME.")
+ endif()
+ if(NOT TARGET ${target})
+ message(FATAL_ERROR "${target} not found.")
+ endif()
+
+ get_target_property(target_type "${target}" TYPE)
+ if("${target_type}" STREQUAL "INTERFACE_LIBRARY")
+ set(property_prefix "INTERFACE_")
+ else()
+ set(property_prefix "")
+ endif()
+ foreach(visibility IN ITEMS PUBLIC PRIVATE)
+ set(value ON)
+ foreach(state IN ITEMS ENABLED DISABLED)
+ get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES)
+ if("${features}" STREQUAL "features-NOTFOUND")
+ continue()
+ endif()
+ foreach(feature IN ITEMS ${features})
+ if (DEFINED "QT_FEATURE_${feature}" AND NOT "${QT_FEATURE_${feature}}" STREQUAL "${value}")
+ message(FATAL_ERROR "Feature ${feature} is already defined and has a different value when importing features from ${target}.")
+ endif()
+ set(QT_FEATURE_${feature} "${value}" CACHE INTERNAL "Qt feature: ${feature} (from target ${target})")
+ endforeach()
+ set(value OFF)
+ endforeach()
+ endforeach()
+endfunction()
+
+
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
new file mode 100644
index 0000000000..54e7f4f50e
--- /dev/null
+++ b/cmake/QtInternalTargets.cmake
@@ -0,0 +1,114 @@
+
+function(qt_internal_set_warnings_are_errors_flags target)
+ set(flags "")
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Regular clang 3.0+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.0.0")
+ list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations)
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+ # using AppleClang
+ # Apple clang 4.0+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "4.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL "9.2")
+ list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations)
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ # using GCC
+ list(APPEND flags -Werror -Wno-error=cpp -Wno-error=deprecated-declarations)
+
+ # GCC prints this bogus warning, after it has inlined a lot of code
+ # error: assuming signed overflow does not occur when assuming that (X + c) < X is always false
+ list(APPEND flags -Wno-error=strict-overflow)
+
+ # GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs.
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0")
+ list(APPEND flags -Wno-error=implicit-fallthrough)
+ endif()
+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0.0")
+ # GCC 9 introduced these but we are not clean for it.
+ list(APPEND flags -Wno-error=deprecated-copy -Wno-error=redundant-move -Wno-error=init-list-lifetime)
+ endif()
+
+ # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
+ if (ANDROID)
+ list(APPEND flags -Wno-error=literal-suffix)
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+ # Intel CC 13.0 +, on Linux only
+ if (LINUX)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0")
+ # 177: function "entity" was declared but never referenced
+ # (too aggressive; ICC reports even for functions created due to template instantiation)
+ # 1224: #warning directive
+ # 1478: function "entity" (declared at line N) was declared deprecated
+ # 1786: function "entity" (declared at line N of "file") was declared deprecated ("message")
+ # 1881: argument must be a constant null pointer value
+ # (NULL in C++ is usually a literal 0)
+ list(APPEND flags -Werror -ww177,1224,1478,1786,1881)
+ endif()
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ # In qmake land, currently warnings as errors are only enabled for
+ # MSVC 2012, 2013, 2015.
+ # Respectively MSVC_VERRSIONs are: 1700-1799, 1800-1899, 1900-1909.
+ if(MSVC_VERSION GREATER_EQUAL 1700 AND MSVC_VERSION LESS_EQUAL 1909)
+ list(APPEND flags /WX)
+ endif()
+ endif()
+ set(add_flags "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_SKIP_WARNINGS_ARE_ERRORS>>>")
+ set(flags_generator_expression "$<${add_flags}:${flags}>")
+ target_compile_options("${target}" INTERFACE "${flags_generator_expression}")
+endfunction()
+
+add_library(PlatformCommonInternal INTERFACE)
+add_library(Qt::PlatformCommonInternal ALIAS PlatformCommonInternal)
+
+add_library(PlatformModuleInternal INTERFACE)
+add_library(Qt::PlatformModuleInternal ALIAS PlatformModuleInternal)
+target_link_libraries(PlatformModuleInternal INTERFACE PlatformCommonInternal)
+
+add_library(PlatformPluginInternal INTERFACE)
+add_library(Qt::PlatformPluginInternal ALIAS PlatformPluginInternal)
+target_link_libraries(PlatformPluginInternal INTERFACE PlatformCommonInternal)
+
+add_library(PlatformToolInternal INTERFACE)
+add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal)
+target_link_libraries(PlatformToolInternal INTERFACE PlatformCommonInternal)
+
+if(WARNINGS_ARE_ERRORS)
+ qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal)
+ qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal)
+ qt_internal_set_warnings_are_errors_flags(PlatformToolInternal)
+endif()
+if(WIN32)
+ # Needed for M_PI define. Same as mkspecs/features/qt_module.prf.
+ # It's set for every module being built, but it's not propagated to user apps.
+ target_compile_definitions(PlatformModuleInternal INTERFACE _USE_MATH_DEFINES)
+endif()
+if(FEATURE_largefile AND UNIX)
+ target_compile_definitions(PlatformModuleInternal
+ INTERFACE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
+endif()
+
+# We can't use the gold linker on android with the NDK, which is the default
+# linker. To build our own target we will use the lld linker.
+if (ANDROID)
+ target_link_options(PlatformModuleInternal INTERFACE -fuse-ld=lld)
+endif()
+
+if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
+ target_compile_definitions(PlatformCommonInternal INTERFACE QT_NO_DEBUG)
+endif()
+
+if(APPLE_UIKIT)
+ # Do what mkspecs/features/uikit/default_pre.prf does, aka enable sse2 for
+ # simulator_and_device_builds.
+ if(FEATURE_simulator_and_device)
+ # Setting the definition on PlatformCommonInternal behaves slightly differently from what
+ # is done in qmake land. This way the define is not propagated to tests, examples, or
+ # user projects built with qmake, but only modules, plugins and tools.
+ # TODO: Figure out if this ok or not (sounds ok to me).
+ target_compile_definitions(PlatformCommonInternal INTERFACE QT_COMPILER_SUPPORTS_SSE2)
+ endif()
+endif()
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
new file mode 100644
index 0000000000..58a84fb5d5
--- /dev/null
+++ b/cmake/QtModuleConfig.cmake.in
@@ -0,0 +1,68 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
+
+# Extra cmake code begin
+@extra_cmake_code@
+# Extra cmake code end
+
+# Find required dependencies, if any.
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+endif()
+
+if (NOT QT_NO_CREATE_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
+ if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
+ endif()
+endif()
+
+foreach(extra_cmake_include @extra_cmake_includes@)
+ include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
+endforeach()
+
+include(${_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir}/QtFeature.cmake)
+
+qt_make_features_available(@QT_CMAKE_EXPORT_NAMESPACE@::@target@)
+
+set("@INSTALL_CMAKE_NAMESPACE@@target@_FOUND" TRUE)
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake")
+endif()
+
+list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@")
+
+get_target_property(_qt_module_target_type "@INSTALL_CMAKE_NAMESPACE@::@target@" TYPE)
+if(NOT _qt_module_target_type STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(_qt_module_plugin_types
+ @INSTALL_CMAKE_NAMESPACE@::@target@ MODULE_PLUGIN_TYPES)
+ if(_qt_module_plugin_types)
+ list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_qt_module_plugin_types}")
+ endif()
+endif()
+
+# Apply meta types properties
+if (@QT_MODULE_HAS_META_TYPES_FILE@)
+ if (NOT QT_NO_CREATE_TARGETS)
+ set_target_properties("@INSTALL_CMAKE_NAMESPACE@::@target@" PROPERTIES
+ INTERFACE_QT_MODULE_HAS_META_TYPES TRUE
+ INTERFACE_QT_META_TYPES_INSTALL_FILE "@QT_MODULE_META_TYPES_FILE@"
+ INTERFACE_QT_META_TYPES_INSTALL_DEP_FILE "@QT_MODULE_META_TYPES_DEP_FILE@"
+ )
+ endif()
+
+ if (NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
+ get_target_property(is_alias_target "Qt::@target@" ALIASED_TARGET)
+ if (NOT is_alias_target)
+ set_target_properties("Qt::@target@" PROPERTIES
+ INTERFACE_QT_MODULE_HAS_META_TYPES TRUE
+ INTERFACE_QT_META_TYPES_INSTALL_FILE "@QT_MODULE_META_TYPES_FILE@"
+ INTERFACE_QT_META_TYPES_INSTALL_DEP_FILE "@QT_MODULE_META_TYPES_DEP_FILE@"
+ )
+ endif()
+ endif()
+endif()
diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in
new file mode 100644
index 0000000000..ffb9e8a5d3
--- /dev/null
+++ b/cmake/QtModuleDependencies.cmake.in
@@ -0,0 +1,66 @@
+# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
+set(_third_party_deps "@third_party_deps@")
+
+foreach(_target_dep ${_third_party_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+ list(GET _target_dep 2 components)
+ set(find_package_args "${pkg}")
+ if(version)
+ list(APPEND find_package_args "${version}")
+ endif()
+
+ if(components)
+ string(REPLACE " " ";" components "${components}")
+ find_dependency(${find_package_args} COMPONENTS ${components})
+ else()
+ find_dependency(${find_package_args})
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
+# Find Qt tool package.
+set(_tool_deps "@main_module_tool_deps@")
+
+# The tools do not provide linkage targets but executables, where a mismatch
+# between 32-bit target and 64-bit host does not matter.
+set(BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
+set(CMAKE_SIZEOF_VOID_P "")
+
+foreach(_target_dep ${_tool_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+
+ find_dependency(${pkg} ${version})
+
+ if (NOT ${pkg}_FOUND)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
+ return()
+ endif()
+endforeach()
+set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
+
+# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
+set(_target_deps "@target_deps@")
+foreach(_target_dep ${_target_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+
+ if (NOT ${pkg}_FOUND)
+ find_dependency(${pkg} ${version}
+ PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
+ )
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
+
diff --git a/cmake/QtModuleToolsConfig.cmake.in b/cmake/QtModuleToolsConfig.cmake.in
new file mode 100644
index 0000000000..79ca620c13
--- /dev/null
+++ b/cmake/QtModuleToolsConfig.cmake.in
@@ -0,0 +1,17 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+if (NOT QT_NO_CREATE_TARGETS)
+ # Find required dependencies, if any.
+ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+ endif()
+
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
+ if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
+ endif()
+endif()
+
+@extra_cmake_statements@
diff --git a/cmake/QtModuleToolsDependencies.cmake.in b/cmake/QtModuleToolsDependencies.cmake.in
new file mode 100644
index 0000000000..46c60b8484
--- /dev/null
+++ b/cmake/QtModuleToolsDependencies.cmake.in
@@ -0,0 +1,16 @@
+# Find "ModuleTools" dependencies, which are other ModuleTools packages.
+set(_tool_deps "@package_deps@")
+foreach(_target_dep ${_tool_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+
+ if (NOT ${pkg}_FOUND)
+ find_dependency(${pkg} ${version})
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
diff --git a/cmake/QtModuleToolsVersionlessTargets.cmake.in b/cmake/QtModuleToolsVersionlessTargets.cmake.in
new file mode 100644
index 0000000000..6d0f57e039
--- /dev/null
+++ b/cmake/QtModuleToolsVersionlessTargets.cmake.in
@@ -0,0 +1,23 @@
+foreach(__qt_tool @tool_targets_non_prefixed@)
+ if(NOT TARGET Qt::${__qt_tool} AND TARGET Qt6::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+
+ # Check all the usual imported location properties to find one that contains a path.
+ foreach(__qt_imported_location_config
+ IMPORTED_LOCATION
+ IMPORTED_LOCATION_RELEASE
+ IMPORTED_LOCATION_RELWITHDEBINFO
+ IMPORTED_LOCATION_MINSIZEREL
+ IMPORTED_LOCATION_DEBUG)
+
+ get_target_property(__qt_imported_location
+ Qt6::${__qt_tool} ${__qt_imported_location_config})
+ if(__qt_imported_location AND EXISTS "${__qt_imported_location}")
+ break()
+ endif()
+ endforeach()
+
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION "${__qt_imported_location}")
+ endif()
+endforeach()
diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake
new file mode 100644
index 0000000000..4b5bf6ff13
--- /dev/null
+++ b/cmake/QtPlatformAndroid.cmake
@@ -0,0 +1,378 @@
+#
+# Self contained Platform Settings for Android
+#
+# Note: This file is used both by the internal and public builds.
+#
+
+#
+# Public variables:
+# QT_ANDROID_JAR
+# Location of the adroid sdk jar for java code
+# QT_ANDROID_APIVERSION
+# Android API version
+# QT_ANDROID_SDK_BUILD_TOOLS_VERSION
+# Detected Android sdk build tools version
+#
+# Public functions:
+#
+# qt_android_generate_deployment_settings()
+# Generate the deployment settings json file for a cmake target.
+#
+
+if (NOT DEFINED ANDROID_SDK_ROOT)
+ message(FATAL_ERROR "Please provide the location of the Android SDK directory via -DANDROID_SDK_ROOT=<path to Adndroid SDK>")
+endif()
+
+if (NOT IS_DIRECTORY "${ANDROID_SDK_ROOT}")
+ message(FATAL_ERROR "Could not find ANDROID_SDK_ROOT or path is not a directory: ${ANDROID_SDK_ROOT}")
+endif()
+
+# Get the Android SDK jar for an API version other than the one specified with
+# QT_ANDROID_API_VERSION.
+function(qt_get_android_sdk_jar_for_api api out_jar_location)
+ set(jar_location "${ANDROID_SDK_ROOT}/platforms/${api}/android.jar")
+ if (NOT EXISTS "${jar_location}")
+ message(WARNING "Could not locate Android SDK jar for api '${api}', defaulting to ${QT_ANDROID_API_VERSION}")
+ set(${out_jar_location} ${QT_ANDROID_JAR} PARENT_SCOPE)
+ else()
+ set(${out_jar_location} ${jar_location} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Minimum recommend android SDK api version
+set(QT_ANDROID_API_VERSION "android-21")
+
+# Locate android.jar
+set(QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_VERSION}/android.jar")
+if(NOT EXISTS "${QT_ANDROID_JAR}")
+ # Locate the highest available platform
+ file(GLOB android_platforms
+ LIST_DIRECTORIES true
+ RELATIVE "${ANDROID_SDK_ROOT}/platforms"
+ "${ANDROID_SDK_ROOT}/platforms/*")
+ # If list is not empty
+ if(android_platforms)
+ list(SORT android_platforms)
+ list(REVERSE android_platforms)
+ list(GET android_platforms 0 android_platform_latest)
+ set(QT_ANDROID_API_VERSION ${android_platform_latest})
+ set(QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_VERSION}/android.jar")
+ endif()
+endif()
+
+if(NOT EXISTS "${QT_ANDROID_JAR}")
+ message(FATAL_ERROR "No suitable Android SDK platform found. Minimum version is ${QT_ANDROID_API_VERSION}")
+endif()
+
+message(STATUS "Using Android SDK API ${QT_ANDROID_API_VERSION} from ${ANDROID_SDK_ROOT}/platforms")
+
+# Locate Java
+include(UseJava)
+
+# Find JDK 8.0
+find_package(Java 1.8 COMPONENTS Development REQUIRED)
+
+# Locate newest android sdk build tools
+if (NOT QT_ANDROID_SDK_BUILD_TOOLS_VERSION)
+ file(GLOB android_build_tools
+ LIST_DIRECTORIES true
+ RELATIVE "${ANDROID_SDK_ROOT}/build-tools"
+ "${ANDROID_SDK_ROOT}/build-tools/*")
+ if (NOT android_build_tools)
+ message(FATAL_ERROR "Could not locate Android SDK build tools under \"${ANDROID_SDK}/build-tools\"")
+ endif()
+ list(SORT android_build_tools)
+ list(REVERSE android_build_tools)
+ list(GET android_build_tools 0 android_build_tools_latest)
+ set(QT_ANDROID_SDK_BUILD_TOOLS_VERSION ${android_build_tools_latest})
+endif()
+
+# Ensure we are using the shared version of libc++
+if(NOT ANDROID_STL STREQUAL c++_shared)
+ message(FATAL_ERROR "The Qt libraries on Android only supports the shared library configuration of stl. Please use -DANDROID_STL=\"c++_shared\" as configuration argument.")
+endif()
+
+# Target properties required for android deploy tool
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_DEPLOYMENT_DEPENDENCIES
+ BRIEF_DOCS
+ "Specify additional plugins that need to be deployed with the current android application"
+ FULL_DOCS
+ "By default, androiddeployqt will detect the dependencies of your application. But since run-time usage of plugins cannot be detected, there could be false positives, as your application will depend on any plugins that are potential dependencies. If you want to minimize the size of your APK, it's possible to override the automatic detection using the ANDROID_DEPLOYMENT_DEPENDENCIES variable. This should contain a list of all Qt files which need to be included, with paths relative to the Qt install root. Note that only the Qt files specified here will be included. Failing to include the correct files can result in crashes. It's also important to make sure the files are listed in the correct loading order. This variable provides a way to override the automatic detection entirely, so if a library is listed before its dependencies, it will fail to load on some devices."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_EXTRA_LIBS
+ BRIEF_DOCS
+ "A list of external libraries that will be copied into your application's library folder and loaded on start-up."
+ FULL_DOCS
+ "A list of external libraries that will be copied into your application's library folder and loaded on start-up. This can be used, for instance, to enable OpenSSL in your application. Simply set the paths to the required libssl.so and libcrypto.so libraries here and OpenSSL should be enabled automatically."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_EXTRA_PLUGINS
+ BRIEF_DOCS
+ "This variable can be used to specify different resources that your project has to bundle but cannot be delivered through the assets system, such as qml plugins."
+ FULL_DOCS
+ "This variable can be used to specify different resources that your project has to bundle but cannot be delivered through the assets system, such as qml plugins. When using this variable, androiddeployqt will make sure everything is packaged and deployed properly."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_PACKAGE_SOURCE_DIR
+ BRIEF_DOCS
+ "This variable can be used to specify a directory where additions and modifications can be made to the default Android package template."
+ FULL_DOCS
+ "This variable can be used to specify a directory where additions and modifications can be made to the default Android package template. The androiddeployqt tool will copy the application template from Qt into the build directory, and then it will copy the contents of the ANDROID_PACKAGE_SOURCE_DIR on top of this, overwriting any existing files. The update step where parts of the source files are modified automatically to reflect your other settings is then run on the resulting merged package. If you, for instance, want to make a custom AndroidManifest.xml for your application, then place this directly into the folder specified in this variable. You can also add custom Java files in ANDROID_PACKAGE_SOURCE_DIR/src."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_ANDROID_DEPLOYMENT_SETTINGS_FILE
+ BRIEF_DOCS
+ " "
+ FULL_DOCS
+ " "
+)
+
+# Generate deployment tool json
+function(qt_android_generate_deployment_settings target)
+ # Information extracted from mkspecs/features/android/android_deployment_settings.prf
+ if (NOT TARGET ${target})
+ message(SEND_ERROR "${target} is not a cmake target")
+ return()
+ endif()
+
+ get_target_property(target_type ${target} TYPE)
+
+ if (NOT "${target_type}" STREQUAL "MODULE_LIBRARY")
+ message(SEND_ERROR "QT_ANDROID_GENERATE_DEPLOYMENT_SETTINGS only works on Module targets")
+ return()
+ endif()
+
+ get_target_property(target_source_dir ${target} SOURCE_DIR)
+ get_target_property(target_binary_dir ${target} BINARY_DIR)
+ get_target_property(target_output_name ${target} OUTPUT_NAME)
+ if (NOT target_output_name)
+ set(target_output_name ${target})
+ endif()
+ set(deploy_file "${target_binary_dir}/android-lib${target_output_name}.so-deployment-settings.json")
+
+ set(file_contents "{\n")
+ # content begin
+ string(APPEND file_contents
+ " \"description\": \"This file is generated by cmake to be read by androiddeployqt and should not be modified by hand.\",\n")
+
+ # Host Qt Android install path
+ if (NOT QT_BUILDING_QT)
+ set(file_check "${Qt6_DIR}/plugins/platforms/android/libqtforandroid_${CMAKE_ANDROID_ARCH_ABI}.so")
+ if (NOT EXISTS ${file_check})
+ message(SEND_ERROR "Detected Qt installation does not contain libqtforandroid.so. This is most likely due to the installation not being a build of Qt for Android. Please update your settings.")
+ return()
+ endif()
+ set(qt_android_install_dir ${Qt6_Dir})
+ else()
+ # Building from source, use the same install prefix
+ set(qt_android_install_dir ${CMAKE_INSTALL_PREFIX})
+ endif()
+
+ file(TO_NATIVE_PATH "${qt_android_install_dir}" qt_android_install_dir_native)
+ string(APPEND file_contents
+ " \"qt\": \"${qt_android_install_dir_native}\",\n")
+
+ # Android SDK path
+ file(TO_NATIVE_PATH "${ANDROID_SDK_ROOT}" android_sdk_root_native)
+ string(APPEND file_contents
+ " \"sdk\": \"${android_sdk_root_native}\",\n")
+
+ # Android SDK Build Tools Revision
+ string(APPEND file_contents
+ " \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_VERSION}\",\n")
+
+ # Android NDK
+ file(TO_NATIVE_PATH "${ANDROID_NDK}" android_ndk_root_native)
+ string(APPEND file_contents
+ " \"ndk\": \"${android_ndk_root_native}\",\n")
+
+ # Setup LLVM toolchain
+ string(APPEND file_contents
+ " \"toolchain-prefix\": \"llvm\",\n")
+ string(APPEND file_contents
+ " \"tool-prefix\": \"llvm\",\n")
+ string(APPEND file_contents
+ " \"useLLVM\": true,\n")
+
+ # NDK Toolchain Version
+ string(APPEND file_contents
+ " \"toolchain-version\": \"${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\",\n")
+
+ # NDK Host
+ string(APPEND file_contents
+ " \"ndk-host\": \"${ANDROID_NDK_HOST_SYSTEM_NAME}\",\n")
+
+ if (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86")
+ set(arch_value "i686-linux-android")
+ elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
+ set(arch_value "x86_64-linux-android")
+ elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "armv64-v8a")
+ set(arch_value "aarch64-linux-android")
+ else()
+ set(arch_value "arm-linux-androideabi")
+ endif()
+
+ # Architecture
+ string(APPEND file_contents
+ " \"architectures\": { \"${CMAKE_ANDROID_ARCH_ABI}\" : \"${arch_value}\" },\n")
+
+ # deployment dependencies
+ get_target_property(android_deployment_dependencies
+ ${target} QT_ANDROID_DEPLOYMENT_DEPENDENCIES)
+ if (android_deployment_dependencies)
+ list(JOIN android_deployment_dependencies "," android_deployment_dependencies)
+ string(APPEND file_contents
+ " \"deployment-dependencies\": \"${android_deployment_dependencies}\",\n")
+ endif()
+
+ # Extra plugins
+ get_target_property(android_extra_plugins
+ ${target} QT_ANDROID_EXTRA_PLUGINS)
+ if (android_extra_plugins)
+ list(JOIN android_extra_plugins "," android_extra_plugins)
+ string(APPEND file_contents
+ " \"android-extra-plugins\": \"${android_extra_plugins}\",\n")
+ endif()
+
+ # Extra libs
+ get_target_property(android_extra_libs
+ ${target} QT_ANDROID_EXTRA_LIBS)
+ if (android_extra_libs)
+ list(JOIN android_extra_libs "," android_extra_libs)
+ string(APPEND file_contents
+ " \"android-extra-libs\": \"${android_extra_libs}\",\n")
+ endif()
+
+ # package source dir
+ get_target_property(android_package_source_dir
+ ${target} QT_ANDROID_PACKAGE_SOURCE_DIR)
+ if (android_package_source_dir)
+ file(TO_NATIVE_PATH "${android_package_source_dir}" android_package_source_dir_native)
+ string(APPEND file_contents
+ " \"android-package-source-directory\": \"${android_package_source_dir_native}\",\n")
+endif()
+
+ #TODO: ANDROID_VERSION_NAME, doesn't seem to be used?
+
+ #TODO: ANDROID_VERSION_CODE, doesn't seem to be used?
+
+ get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH)
+ if (qml_import_path)
+ file(TO_NATIVE_PATH "${qml_import_path}" qml_import_path_native)
+ string(APPEND file_contents
+ " \"qml-import-path\": \"${qml_import_path_native}\",\n")
+ endif()
+
+ get_target_property(qml_root_path ${target} QT_QML_ROOT_PATH)
+ if(NOT qml_root_path)
+ set(qml_root_path "${target_source_dir}")
+ endif()
+ file(TO_NATIVE_PATH "${qml_root_path}" qml_root_path_native)
+ string(APPEND file_contents
+ " \"qml-root-path\": \"${qml_root_path_native}\",\n")
+
+ # App binary
+ string(APPEND file_contents
+ " \"application-binary\": \"${target_output_name}\",\n")
+
+ # Override qmlimportscanner binary path
+ set(qml_importscanner_binary_path "${QT_HOST_PATH}/bin/qmlimportscanner")
+ if (WIN32)
+ string(APPEND qml_importscanner_binary_path ".exe")
+ endif()
+ file(TO_NATIVE_PATH "${qml_importscanner_binary_path}" qml_importscanner_binary_path_native)
+ string(APPEND file_contents
+ " \"qml-importscanner-binary\" : \"${qml_importscanner_binary_path_native}\",\n")
+
+ # Last item in json file
+
+ # base location of stdlibc++, will be suffixed by androiddeploy qt
+ set(android_ndk_stdlib_base_path
+ "${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/"
+ )
+ string(APPEND file_contents
+ " \"stdcpp-path\": \"${android_ndk_stdlib_base_path}\"\n")
+
+ # content end
+ string(APPEND file_contents "}\n")
+
+ file(WRITE ${deploy_file} ${file_contents})
+
+ set_target_properties(${target}
+ PROPERTIES
+ QT_ANDROID_DEPLOYMENT_SETTINGS_FILE ${deploy_file}
+ )
+endfunction()
+
+function(qt_android_apply_arch_suffix target)
+ get_target_property(target_type ${target} TYPE)
+ if (target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
+ set_property(TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.so")
+ elseif (target_type STREQUAL "STATIC_LIBRARY")
+ set_property(TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.a")
+ endif()
+endfunction()
+
+# Add custom target to package the APK
+function(qt_android_add_apk_target target)
+ get_target_property(deployment_file ${target} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
+ if (NOT deployment_file)
+ message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")
+ endif()
+
+ set(deployment_tool "${QT_HOST_PATH}/bin/androiddeployqt")
+ set(apk_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/android-build")
+ add_custom_target(${target}_prepare_apk_dir
+ DEPENDS ${target}
+ COMMAND ${CMAKE_COMMAND}
+ -E copy $<TARGET_FILE:${target}>
+ "${apk_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:${target}>"
+ COMMENT "Copying ${target} binarty to apk folder"
+ )
+
+ add_custom_target(${target}_make_apk
+ DEPENDS ${target}_prepare_apk_dir
+ COMMAND ${deployment_tool}
+ --input ${deployment_file}
+ --output ${apk_dir}
+ COMMENT "Creating APK for ${target}"
+ )
+endfunction()
+
+
+# Add a test for Android which will be run by the android test runner tool
+function(qt_android_add_test target)
+
+ set(deployment_tool "${QT_HOST_PATH}/bin/androiddeployqt")
+ set(test_runner "${QT_HOST_PATH}/bin/androidtestrunner")
+
+ get_target_property(deployment_file ${target} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
+ if (NOT deployment_file)
+ message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")
+ endif()
+
+ set(target_binary_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>")
+ set(apk_dir "${target_binary_dir}/android-build")
+
+ add_test(NAME "${target}"
+ COMMAND "${test_runner}"
+ --androiddeployqt "${deployment_tool} --input ${deployment_file}"
+ --adb "${ANDROID_SDK_ROOT}/platform-tools/adb"
+ --path "${apk_dir}"
+ --skip-install-root
+ --make "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}_make_apk"
+ --apk "${apk_dir}/${target}.apk"
+ --verbose
+ )
+endfunction()
diff --git a/cmake/QtPlatformSupport.cmake b/cmake/QtPlatformSupport.cmake
new file mode 100644
index 0000000000..b54d52eba4
--- /dev/null
+++ b/cmake/QtPlatformSupport.cmake
@@ -0,0 +1,81 @@
+function(qt_set01 result)
+ if (${ARGN})
+ set("${result}" 1 PARENT_SCOPE)
+ else()
+ set("${result}" 0 PARENT_SCOPE)
+ endif()
+endfunction()
+
+qt_set01(LINUX CMAKE_SYSTEM_NAME STREQUAL "Linux")
+qt_set01(HPUX CMAKE_SYSTEM_NAME STREQUAL "HPUX")
+qt_set01(ANDROID CMAKE_SYSTEM_NAME STREQUAL "Android") # FIXME: How to identify this?
+qt_set01(NACL CMAKE_SYSTEM_NAME STREQUAL "NaCl") # FIXME: How to identify this?
+qt_set01(INTEGRITY CMAKE_SYSTEM_NAME STREQUAL "Integrity") # FIXME: How to identify this?
+qt_set01(VXWORKS CMAKE_SYSTEM_NAME STREQUAL "VxWorks") # FIXME: How to identify this?
+qt_set01(QNX CMAKE_SYSTEM_NAME STREQUAL "QNX") # FIXME: How to identify this?
+qt_set01(OPENBSD CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # FIXME: How to identify this?
+qt_set01(FREEBSD CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FIXME: How to identify this?
+qt_set01(NETBSD CMAKE_SYSTEM_NAME STREQUAL "NetBSD") # FIXME: How to identify this?
+qt_set01(WASM CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+
+qt_set01(BSD APPLE OR OPENBSD OR FREEBSD OR NETBSD)
+
+qt_set01(WINRT WIN32 AND CMAKE_VS_PLATFORM_TOOSLET STREQUAL "winrt") # FIXME: How to identify this?
+
+qt_set01(APPLE_IOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
+qt_set01(APPLE_TVOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "tvOS")
+qt_set01(APPLE_WATCHOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "watchOS")
+qt_set01(APPLE_UIKIT APPLE AND (APPLE_IOS OR APPLE_TVOS OR APPLE_WATCHOS))
+qt_set01(APPLE_OSX APPLE AND NOT APPLE_UIKIT)
+
+qt_set01(GCC CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+qt_set01(CLANG CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+qt_set01(ICC CMAKE_C_COMPILER MATCHES "icc|icl")
+qt_set01(QCC CMAKE_C_COMPILER MATCHES "qcc") # FIXME: How to identify this?
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(QT_64BIT TRUE)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(QT_32BIT TRUE)
+endif()
+
+# Parses a version string like "xx.yy.zz" and sets the major, minor and patch variables.
+function(qt_parse_version_string version_string out_var_prefix)
+ string(REPLACE "." ";" version_list ${version_string})
+ list(LENGTH version_list length)
+
+ set(out_var "${out_var_prefix}_MAJOR")
+ set(value "")
+ if(length GREATER 0)
+ list(GET version_list 0 value)
+ list(REMOVE_AT version_list 0)
+ math(EXPR length "${length}-1")
+ endif()
+ set(${out_var} "${value}" PARENT_SCOPE)
+
+ set(out_var "${out_var_prefix}_MINOR")
+ set(value "")
+ if(length GREATER 0)
+ list(GET version_list 0 value)
+ set(${out_var} "${value}" PARENT_SCOPE)
+ list(REMOVE_AT version_list 0)
+ math(EXPR length "${length}-1")
+ endif()
+ set(${out_var} "${value}" PARENT_SCOPE)
+
+ set(out_var "${out_var_prefix}_PATCH")
+ set(value "")
+ if(length GREATER 0)
+ list(GET version_list 0 value)
+ set(${out_var} "${value}" PARENT_SCOPE)
+ list(REMOVE_AT version_list 0)
+ math(EXPR length "${length}-1")
+ endif()
+ set(${out_var} "${value}" PARENT_SCOPE)
+endfunction()
+
+# Set up the separate version components for the compiler version, to allow mapping of qmake
+# conditions like 'equals(QT_GCC_MAJOR_VERSION,5)'.
+if(CMAKE_CXX_COMPILER_VERSION)
+ qt_parse_version_string("${CMAKE_CXX_COMPILER_VERSION}" "QT_COMPILER_VERSION")
+endif()
diff --git a/cmake/QtPluginConfig.cmake.in b/cmake/QtPluginConfig.cmake.in
new file mode 100644
index 0000000000..5fde0bc511
--- /dev/null
+++ b/cmake/QtPluginConfig.cmake.in
@@ -0,0 +1,17 @@
+include_guard(DIRECTORY)
+
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
+
+if (NOT QT_NO_CREATE_TARGETS)
+ # Find required dependencies, if any.
+ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@target@Dependencies.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@target@Dependencies.cmake")
+ endif()
+
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
+endif()
diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in
new file mode 100644
index 0000000000..f25d0bed43
--- /dev/null
+++ b/cmake/QtPluginDependencies.cmake.in
@@ -0,0 +1,42 @@
+# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
+set(_third_party_deps "@third_party_deps@")
+
+foreach(_target_dep ${_third_party_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+ list(GET _target_dep 2 components)
+ set(find_package_args "${pkg}")
+ if(version)
+ list(APPEND find_package_args "${version}")
+ endif()
+
+ if(components)
+ string(REPLACE " " ";" components "${components}")
+ find_dependency(${find_package_args} COMPONENTS ${components})
+ else()
+ find_dependency(${find_package_args})
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
+# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
+set(_target_deps "@target_deps@")
+foreach(_target_dep ${_target_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+
+ if (NOT ${pkg}_FOUND)
+ find_dependency(${pkg} ${version}
+ PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
+ )
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in
new file mode 100644
index 0000000000..91884302c6
--- /dev/null
+++ b/cmake/QtPlugins.cmake.in
@@ -0,0 +1,131 @@
+include_guard(DIRECTORY)
+
+@QT_MODULE_PLUGIN_INCLUDES@
+
+if(NOT @BUILD_SHARED_LIBS@)
+ set(_module_target "@INSTALL_CMAKE_NAMESPACE@::@QT_MODULE@")
+ # Properties can't be set on aliased targets, so make sure to unalias the target. This is needed
+ # when Qt examples are built as part of the Qt build itself.
+ get_target_property(_aliased_target ${_module_target} ALIASED_TARGET)
+ if(_aliased_target)
+ set(_module_target ${_aliased_target})
+ endif()
+ unset(_aliased_target)
+
+ set(_default_plugins_are_enabled "$<NOT:$<STREQUAL:$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>,0>>")
+ # Make sure to boolify the result of the expression, in case if the returned property value
+ # is empty.
+ set(_default_plugins_are_enabled_wrapped "$<BOOL:${_default_plugins_are_enabled}>")
+ set(_manual_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>")
+ set(_no_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>")
+
+ # In super builds the rules below pollute the dependency rule for the
+ # plugin target when it's being build, causing cyclic dependencies.
+ # to overcome this, we check if the current target where this rule evaluates
+ # has a QT_BUILD_PROJECT_NAME equal to the current PROJECT_NAME.
+ # If so we disable the injection of plugin link rules to avoid cyclic
+ # dependencies.
+ if (@QT_SUPERBUILD@)
+ set(_build_allow_plugin_link_rules_genex "$<NOT:$<STREQUAL:$<TARGET_PROPERTY:QT_BUILD_PROJECT_NAME>,@PROJECT_NAME@>>")
+ else()
+ set(_build_allow_plugin_link_rules_genex 1)
+ endif()
+
+ # The code in here uses the properties defined in qt_import_plugins (Qt6CoreMacros.cmake)
+ foreach(target @qt_plugins@)
+ set(_plugin_target "@INSTALL_CMAKE_NAMESPACE@::${target}")
+ set(_plugin_target_versionless "Qt::${target}")
+ get_target_property(_classname "${_plugin_target}" QT_PLUGIN_CLASS_NAME)
+ if(NOT _classname)
+ message("Warning: plugin ${_plugin_target} has no class name, skipping.")
+ continue()
+ endif()
+
+ get_target_property(_plugin_type "${_plugin_target}" QT_PLUGIN_TYPE)
+ if(NOT _plugin_type)
+ message("Warning: plugin ${_plugin_target} has no type ('${_plugin_type}'), skipping.")
+ continue()
+ endif()
+
+ list(APPEND "QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${_plugin_type}" "${target}")
+
+ set(_plugin_is_default "$<TARGET_PROPERTY:${_plugin_target},QT_DEFAULT_PLUGIN>")
+
+ # INCLUDE
+ set(_plugin_is_whitelisted "$<IN_LIST:${_plugin_target},${_manual_plugins_genex}>")
+ set(_plugin_versionless_is_whitelisted
+ "$<IN_LIST:${_plugin_target_versionless},${_manual_plugins_genex}>")
+
+ # Note: qt_import_plugins sets the QT_PLUGINS_${_plugin_type} to "-"
+ # when excluding it with EXCLUDE_BY_TYPE,
+ # which ensures that no plug-in will be supported unless explicitly re-added afterwards.
+ string(CONCAT _plugin_is_not_blacklisted
+ "$<AND:"
+ "$<NOT:" # EXCLUDE
+ "$<IN_LIST:${_plugin_target},${_no_plugins_genex}>"
+ ">,"
+ "$<NOT:"
+ "$<IN_LIST:${_plugin_target_versionless},${_no_plugins_genex}>"
+ ">,"
+ # Excludes both plugins targeted by EXCLUDE_BY_TYPE and not included in
+ # INCLUDE_BY_TYPE.
+ "$<STREQUAL:,$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS_${_plugin_type}>>>"
+ ">"
+ )
+
+ # Support INCLUDE_BY_TYPE
+ string(CONCAT _plugin_is_in_type_whitelist
+ "$<IN_LIST:"
+ "${_plugin_target},"
+ "$<GENEX_EVAL:"
+ "$<TARGET_PROPERTY:QT_PLUGINS_${_plugin_type}>"
+ ">"
+ ">"
+ )
+ string(CONCAT _plugin_versionless_is_in_type_whitelist
+ "$<IN_LIST:"
+ "${_plugin_target_versionless},"
+ "$<GENEX_EVAL:"
+ "$<TARGET_PROPERTY:QT_PLUGINS_${_plugin_type}>"
+ ">"
+ ">"
+ )
+
+ # Complete condition that defines whether a static plugin is linked
+ string(CONCAT _plugin_condition
+ "$<BOOL:$<AND:"
+ "${_build_allow_plugin_link_rules_genex},"
+ "$<OR:"
+ "${_plugin_is_whitelisted},"
+ "${_plugin_versionless_is_whitelisted},"
+ "${_plugin_is_in_type_whitelist},"
+ "${_plugin_versionless_is_in_type_whitelist},"
+ "$<AND:"
+ "${_default_plugins_are_enabled_wrapped},"
+ "${_plugin_is_default},"
+ "${_plugin_is_not_blacklisted}"
+ ">"
+ ">"
+ ">>"
+ )
+
+ # If this condition is true, we link against the plug-in
+ set(_plugin_genex "$<${_plugin_condition}:${_plugin_target}>")
+ target_link_libraries(${_module_target} INTERFACE "${_plugin_genex}")
+
+ set(_generated_qt_plugin_file_name
+ "${CMAKE_CURRENT_BINARY_DIR}/qt_@QT_MODULE@_${target}.cpp")
+ set(_generated_qt_plugin_file_name_template "${_generated_qt_plugin_file_name}.in")
+ set(_generated_qt_plugin_file_content "#include <QtPlugin>\nQ_IMPORT_PLUGIN(${_classname})")
+
+ # Generate a source file to import that plug-in. Has to be done with configure_file,
+ # because file(GENERATE) and target_sources has issues with scopes.
+ file(WRITE "${_generated_qt_plugin_file_name_template}"
+ "${_generated_qt_plugin_file_content}")
+ configure_file("${_generated_qt_plugin_file_name_template}"
+ "${_generated_qt_plugin_file_name}")
+
+ target_sources(${_module_target} INTERFACE
+ "$<${_plugin_condition}:${_generated_qt_plugin_file_name}>")
+ endforeach()
+endif()
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
new file mode 100644
index 0000000000..ab2cab447f
--- /dev/null
+++ b/cmake/QtPostProcess.cmake
@@ -0,0 +1,405 @@
+function(qt_internal_write_depends_file target)
+ set(module Qt${target})
+ set(outfile "${QT_BUILD_DIR}/include/${module}/${module}Depends")
+ message("Generate ${outfile}...")
+ set(contents "/* This file was generated by cmake with the info from ${module} target. */\n")
+ string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n")
+ foreach (m ${ARGN})
+ string(APPEND contents "# include <Qt${m}/Qt${m}>\n")
+ endforeach()
+ string(APPEND contents "#endif\n")
+
+ file(GENERATE OUTPUT "${outfile}" CONTENT "${contents}")
+endfunction()
+
+macro(qt_collect_third_party_deps target)
+ set(_target_is_static OFF)
+ get_target_property(_target_type ${target} TYPE)
+ if (${_target_type} STREQUAL "STATIC_LIBRARY")
+ set(_target_is_static ON)
+ endif()
+ unset(_target_type)
+ # If we are doing a non-static Qt build, we only want to propagate public dependencies.
+ # If we are doing a static Qt build, we need to propagate all dependencies.
+ set(depends_var "public_depends")
+ if(_target_is_static)
+ set(depends_var "depends")
+ endif()
+ unset(_target_is_static)
+
+ foreach(dep ${${depends_var}})
+ # Gather third party packages that should be found when using the Qt module.
+ # Also handle nolink target dependencies.
+ string(REGEX REPLACE "_nolink$" "" base_dep "${dep}")
+ if(NOT base_dep STREQUAL dep)
+ # Resets target name like Vulkan_nolink to Vulkan, because we need to call
+ # find_package(Vulkan).
+ set(dep ${base_dep})
+ endif()
+
+ if(TARGET ${dep})
+ list(FIND third_party_deps_seen ${dep} dep_seen)
+
+ get_target_property(package_name ${dep} INTERFACE_QT_PACKAGE_NAME)
+ if(dep_seen EQUAL -1 AND package_name)
+ list(APPEND third_party_deps_seen ${dep})
+ get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
+ if(NOT package_version)
+ set(package_version "")
+ endif()
+
+ get_target_property(package_components ${dep} INTERFACE_QT_PACKAGE_COMPONENTS)
+ if(NOT package_components)
+ set(package_components "")
+ endif()
+
+ list(APPEND third_party_deps
+ "${package_name}\;${package_version}\;${package_components}")
+ endif()
+ endif()
+ endforeach()
+endmacro()
+
+function(qt_internal_create_module_depends_file target)
+ get_target_property(target_type "${target}" TYPE)
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ set(arg_HEADER_MODULE ON)
+ else()
+ set(arg_HEADER_MODULE OFF)
+ endif()
+
+ if(NOT arg_HEADER_MODULE)
+ get_target_property(depends "${target}" LINK_LIBRARIES)
+ endif()
+ get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
+
+ # Used for collecting Qt module dependencies that should be find_package()'d in
+ # ModuleDependencies.cmake.
+ get_target_property(target_deps "${target}" _qt_target_deps)
+ set(target_deps_seen "")
+
+ if(NOT arg_HEADER_MODULE)
+ get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
+ endif()
+ if(NOT extra_depends STREQUAL "${extra_depends}-NOTFOUND")
+ list(APPEND target_deps "${extra_depends}")
+ endif()
+
+ # Used for assembling the content of an include/Module/ModuleDepends.h header.
+ set(qtdeps "")
+
+ # Used for collecting third party dependencies that should be find_package()'d in
+ # ModuleDependencies.cmake.
+ set(third_party_deps "")
+ set(third_party_deps_seen "")
+
+ # Used for collecting Qt tool dependencies that should be find_package()'d in
+ # ModuleToolsDependencies.cmake.
+ set(tool_deps "")
+ set(tool_deps_seen "")
+
+ # Used for collecting Qt tool dependencies that should be find_package()'d in
+ # ModuleDependencies.cmake.
+ set(main_module_tool_deps "")
+
+ qt_internal_get_qt_all_known_modules(known_modules)
+
+ set(all_depends ${depends} ${public_depends})
+ foreach (dep ${all_depends})
+ # Normalize module by stripping leading "Qt::" and trailing "Private"
+ if (dep MATCHES "Qt::(.*)")
+ set(dep "${CMAKE_MATCH_1}")
+ endif()
+ if (dep MATCHES "(.*)Private")
+ set(dep "${CMAKE_MATCH_1}")
+ endif()
+
+ list(FIND known_modules "${dep}" _pos)
+ if (_pos GREATER -1)
+ list(APPEND qtdeps "${dep}")
+
+ # Make the ModuleTool package depend on dep's ModuleTool package.
+ list(FIND tool_deps_seen ${dep} dep_seen)
+ if(dep_seen EQUAL -1 AND ${dep} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
+ list(APPEND tool_deps_seen ${dep})
+ list(APPEND tool_deps
+ "${INSTALL_CMAKE_NAMESPACE}${dep}Tools\;${PROJECT_VERSION}")
+ endif()
+ endif()
+ endforeach()
+
+ qt_collect_third_party_deps(${target})
+
+ # Add dependency to the main ModuleTool package to ModuleDependencies file.
+ if(${target} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
+ set(main_module_tool_deps
+ "${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}")
+ endif()
+
+ # Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
+ foreach(dep ${target_deps})
+ if(dep)
+ list(FIND target_deps_seen "${dep}" dep_seen)
+ if(dep_seen EQUAL -1)
+ list(LENGTH dep len)
+ if(NOT (len EQUAL 2))
+ message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
+ endif()
+ list(GET dep 0 dep_name)
+ list(GET dep 1 dep_ver)
+
+ list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
+ endif()
+ endif()
+ endforeach()
+ set(target_deps "${target_deps_seen}")
+
+ if (DEFINED qtdeps)
+ list(REMOVE_DUPLICATES qtdeps)
+ endif()
+
+ get_target_property(hasModuleHeaders "${target}" INTERFACE_MODULE_HAS_HEADERS)
+ if (${hasModuleHeaders})
+ qt_internal_write_depends_file("${target}" ${qtdeps})
+ endif()
+
+ if(third_party_deps OR main_module_tool_deps OR target_deps)
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ # Configure and install ModuleDependencies file.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ @ONLY
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ endif()
+ if(tool_deps)
+ # The value of the property will be used by qt_export_tools.
+ set_property(TARGET "${target}" PROPERTY _qt_tools_package_deps "${tool_deps}")
+ endif()
+endfunction()
+
+function(qt_internal_create_plugin_depends_file target)
+ get_target_property(qt_module "${target}" QT_MODULE)
+ get_target_property(depends "${target}" LINK_LIBRARIES)
+ get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
+ get_target_property(target_deps "${target}" _qt_target_deps)
+ set(target_deps_seen "")
+
+ qt_collect_third_party_deps(${target})
+
+ # Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
+ foreach(dep ${target_deps})
+ if(dep)
+ list(FIND target_deps_seen "${dep}" dep_seen)
+ if(dep_seen EQUAL -1)
+ list(LENGTH dep len)
+ if(NOT (len EQUAL 2))
+ message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
+ endif()
+ list(GET dep 0 dep_name)
+ list(GET dep 1 dep_ver)
+
+ list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
+ endif()
+ endif()
+ endforeach()
+ set(target_deps "${target_deps_seen}")
+
+ if(third_party_deps OR target_deps)
+ # Setup build and install paths
+ if(qt_module)
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}")
+ else()
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
+ endif()
+
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
+
+ # Configure and install ModuleDependencies file.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtPluginDependencies.cmake.in"
+ "${config_build_dir}/${target}Dependencies.cmake"
+ @ONLY
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${target}Dependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+ endif()
+endfunction()
+
+# Create Depends.cmake & Depends.h files for all modules and plug-ins.
+function(qt_internal_create_depends_files)
+ qt_internal_get_qt_repo_known_modules(repo_known_modules)
+
+ message("Generating ModuleDepends files and CMake ModuleDependencies files for ${repo_known_modules}...")
+ foreach (target ${repo_known_modules})
+ qt_internal_create_module_depends_file(${target})
+ endforeach()
+
+ message("Generating CMake PluginDependencies files for ${QT_KNOWN_PLUGINS}...")
+ foreach (target ${QT_KNOWN_PLUGINS})
+ qt_internal_create_plugin_depends_file(${target})
+ endforeach()
+endfunction()
+
+# This function creates the Qt<Module>Plugins.cmake used to list all
+# the plug-in target files.
+function(qt_internal_create_plugins_files)
+ # The plugins cmake configuration is only needed for static builds. Dynamic builds don't need
+ # the application to link against plugins at build time.
+ if(QT_BUILD_SHARED_LIBS)
+ return()
+ endif()
+ qt_internal_get_qt_repo_known_modules(repo_known_modules)
+
+ message("Generating Plugins files for ${repo_known_modules}...")
+ foreach (QT_MODULE ${repo_known_modules})
+ get_target_property(target_type "${QT_MODULE}" TYPE)
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ # No plugins are provided by a header only module.
+ continue()
+ endif()
+ qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
+ qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
+ set(QT_MODULE_PLUGIN_INCLUDES "")
+
+ get_target_property(qt_plugins "${QT_MODULE}" QT_PLUGINS)
+ if(qt_plugins)
+ foreach (pluginTarget ${qt_plugins})
+ set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}include(\"\${CMAKE_CURRENT_LIST_DIR}/${pluginTarget}Config.cmake\")\n")
+ endforeach()
+ configure_file(
+ "${QT_CMAKE_DIR}/QtPlugins.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
+ @ONLY
+ )
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+ endif()
+ endforeach()
+endfunction()
+
+function(qt_generate_build_internals_extra_cmake_code)
+ if(PROJECT_NAME STREQUAL "QtBase")
+ foreach(var IN LISTS QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "set(${var} \"${${var}}\" CACHE INTERNAL \"\")\n")
+ endforeach()
+
+ set(QT_SOURCE_TREE "${QtBase_SOURCE_DIR}")
+ qt_path_join(extra_file_path
+ ${QT_CONFIG_BUILD_DIR}
+ ${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
+
+ if(CMAKE_BUILD_TYPE)
+ # Need to force set, because CMake itself initializes a value for CMAKE_BUILD_TYPE
+ # at the start of project configuration (with an empty value),
+ # so we need to force override it.
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" CACHE STRING \"Choose the type of build.\" FORCE)\n")
+
+ endif()
+ if(CMAKE_CONFIGURATION_TYPES)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(CMAKE_CONFIGURATION_TYPES \"${CMAKE_CONFIGURATION_TYPES}\")\n")
+ endif()
+ if(CMAKE_TRY_COMPILE_CONFIGURATION)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(CMAKE_TRY_COMPILE_CONFIGURATION \"${CMAKE_TRY_COMPILE_CONFIGURATION}\")\n")
+ endif()
+ if(QT_MULTI_CONFIG_FIRST_CONFIG)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(QT_MULTI_CONFIG_FIRST_CONFIG \"${QT_MULTI_CONFIG_FIRST_CONFIG}\")\n")
+ endif()
+ if(CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE \"${CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE}\")\n")
+ endif()
+ if(CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE)
+ string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
+ "set(CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE \"${CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE}\")\n")
+ endif()
+
+ configure_file(
+ "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake.in"
+ "${extra_file_path}"
+ @ONLY
+ )
+ endif()
+endfunction()
+
+# For every Qt module check if there any android dependencies that require
+# processing.
+function(qt_modules_process_android_dependencies)
+ qt_internal_get_qt_repo_known_modules(repo_known_modules)
+ foreach (target ${repo_known_modules})
+ qt_android_dependencies(${target})
+ endforeach()
+endfunction()
+
+function(qt_create_tools_config_files)
+ # Create packages like Qt6CoreTools/Qt6CoreToolsConfig.cmake.
+ foreach(module_name ${QT_KNOWN_MODULES_WITH_TOOLS})
+ qt_export_tools("${module_name}")
+ endforeach()
+endfunction()
+
+function(qt_internal_create_config_file_for_standalone_tests)
+ set(standalone_tests_config_dir "StandaloneTests")
+ qt_path_join(config_build_dir
+ ${QT_CONFIG_BUILD_DIR}
+ "${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
+ qt_path_join(config_install_dir
+ ${QT_CONFIG_INSTALL_DIR}
+ "${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
+
+ list(JOIN QT_REPO_KNOWN_MODULES " " QT_REPO_KNOWN_MODULES_STRING)
+ string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING)
+
+ # Skip generating and installing file if no modules were built. This make sure not to install
+ # anything when build qtx11extras on macOS for example.
+ if(NOT QT_REPO_KNOWN_MODULES_STRING)
+ return()
+ endif()
+
+ # Ceate a Config file that calls find_package on the modules that were built as part
+ # of the current repo. This is used for standalone tests.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in"
+ "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
+ @ONLY
+ )
+ qt_install(FILES
+ "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+endfunction()
+
+qt_internal_create_depends_files()
+qt_generate_build_internals_extra_cmake_code()
+qt_internal_create_plugins_files()
+qt_internal_create_config_file_for_standalone_tests()
+
+# Needs to run after qt_internal_create_depends_files.
+qt_create_tools_config_files()
+
+if (ANDROID)
+ qt_modules_process_android_dependencies()
+endif()
diff --git a/cmake/QtProperties.cmake b/cmake/QtProperties.cmake
new file mode 100644
index 0000000000..a12fa53252
--- /dev/null
+++ b/cmake/QtProperties.cmake
@@ -0,0 +1,107 @@
+define_property(TARGET
+ PROPERTY
+ QT_PLUGINS
+ BRIEF_DOCS
+ "List of Qt plug-ins associated with a given Qt module."
+ FULL_DOCS
+ "This is a property on Qt modules.
+ For instance, sqlite;odbc for Sql"
+)
+
+define_property(TARGET
+ PROPERTY
+ MODULE_PLUGIN_TYPES
+ BRIEF_DOCS
+ "List of plugin categories associated to the Qt module"
+ FULL_DOCS
+ "This is a property on Qt modules.
+ For instance, sqldrivers for Sql."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_PLUGIN_CLASS_NAME
+ BRIEF_DOCS
+ "Class name of the Qt plug-in"
+ FULL_DOCS
+ "This is a property on Qt plug-ins.
+ For instance, QICOPlugin for the qico plug-in"
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_PLUGIN_TYPE
+ BRIEF_DOCS
+ "Type of the Qt plug-in"
+ FULL_DOCS
+ "This is a property on Qt plug-ins.
+ For example, the value of the QT_PLUGIN_TYPE property on the qico plugin is \"imageformats\""
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_MODULE
+ BRIEF_DOCS
+ "Qt module associated with a plug-in."
+ FULL_DOCS
+ "This is a property on Qt plug-ins.
+ For instance, Sql for qsqlite"
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_DEFAULT_PLUGIN
+ BRIEF_DOCS
+ "Indicates whether a plug-in is added by default."
+ FULL_DOCS
+ "This is a property on Qt plug-ins.
+ It is mainly used to indicate if a plug-in should be added
+ to the default set of plug-ins when building a static app -
+ for instance, which QPA should be linked."
+)
+
+define_property(GLOBAL
+ PROPERTY
+ QT_KNOWN_PLUGINS
+ BRIEF_DOCS
+ ""
+ FULL_DOCS
+ ""
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_QML_MODULE_TARGET_PATH
+ BRIEF_DOCS
+ "Specifies the target path for a qml module"
+ FULL_DOCS
+ "Specifies the target path for a qml module"
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_QML_MODULE_URI
+ BRIEF_DOCS
+ "Specifies the URI for a qml module"
+ FULL_DOCS
+ "Specifies the URI for a qml module"
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_RESOURCE_PREFIX
+ BRIEF_DOCS
+ "Specifies the default Qt resource prefix."
+ FULL_DOCS
+ "When using qt_add_resource() without a PREFIX, then prefix of this target property
+ will be used."
+)
+
+define_property(TARGET
+ PROPERTY
+ QT_QML_MODULE_VERSION
+ BRIEF_DOCS
+ "Specifies the qml module's version."
+ FULL_DOCS
+ "Specifies the qml module's version."
+)
diff --git a/cmake/QtResource.cmake.in b/cmake/QtResource.cmake.in
new file mode 100644
index 0000000000..2f8f77eb79
--- /dev/null
+++ b/cmake/QtResource.cmake.in
@@ -0,0 +1,313 @@
+#
+# All things resource related
+#
+
+function(__qt_get_relative_resource_path_for_file output_alias file)
+ get_property(alias SOURCE ${file} PROPERTY QT_RESOURCE_ALIAS)
+ if (NOT alias)
+ set(alias "${file}")
+ endif()
+ set(${output_alias} ${alias} PARENT_SCOPE)
+endfunction()
+
+function(__qt_propagate_generated_resource target resource_name generated_source_code output_generated_target)
+ get_target_property(type ${target} TYPE)
+ if(type STREQUAL STATIC_LIBRARY)
+ set(resource_target "${target}_resources_${resourceName}")
+ add_library("${resource_target}" OBJECT "${generated_source_code}")
+
+ # Use TARGET_NAME genex to map to the correct prefixed target name when it is exported
+ # via qt_install(EXPORT), so that the consumers of the target can find the object library
+ # as well.
+ target_link_libraries(${target} INTERFACE
+ "$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>")
+ set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
+ else()
+ set(${output_generated_target} "" PARENT_SCOPE)
+ target_sources(${target} PRIVATE ${generated_source_code})
+ endif()
+endfunction()
+
+# Inspect all files passed to a call to qt_add_resource. If there are any
+# files present, invoke the quick compiler and return the remaining resource
+# files that have not been processed in OUTPUT_REMAINING_RESOURCES as well as the new
+# name for the resource in OUTPUT_RESOURCE_NAME.
+function(__qt_quick_compiler_process_resources target resource_name)
+
+ cmake_parse_arguments(arg
+ "" "PREFIX;OUTPUT_REMAINING_RESOURCES;OUTPUT_RESOURCE_NAME;OUTPUT_GENERATED_TARGET" "FILES" ${ARGN}
+ )
+
+ set(qml_files)
+ set(resource_files)
+ set(retained_files)
+ # scan for qml files
+ foreach(file IN LISTS arg_FILES)
+ # check whether this resource should not be processed by the qt quick
+ # compiler
+ get_source_file_property(skip_compiler_check ${file} QT_SKIP_QUICKCOMPILER)
+ get_source_file_property(retain_compiler_check ${file} QT_RETAIN_QUICKCOMPILER)
+ if (skip_compiler_check)
+ list(APPEND resource_files ${file})
+ continue()
+ endif()
+
+ if (${file} MATCHES "\.js$"
+ OR ${file} MATCHES "\.mjs$"
+ OR ${file} MATCHES "\.qml$")
+ list(APPEND qml_files ${file})
+ if (retain_compiler_check)
+ list(APPEND retained_files ${file})
+ list(APPEND resource_files ${file})
+ endif()
+ else()
+ list(APPEND resource_files ${file})
+ endif()
+ endforeach()
+ if (NOT TARGET @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen AND qml_files)
+ message(WARNING "QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE: Qml files were detected but the qmlcachgen target is not defined. Consider adding QmlTools to your find_package command.")
+ endif()
+
+ set(retained_resource_paths)
+ if (TARGET @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen AND qml_files)
+ # Enable qt quick compiler support
+ set(qml_resource_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${resource_name}.qrc")
+ if (resource_files)
+ set(chained_resource_name "${resource_name}_qmlcache")
+ endif()
+
+ foreach(file IN LISTS qml_files)
+ get_filename_component(file_absolute ${file} ABSOLUTE)
+ file(RELATIVE_PATH file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${file_absolute})
+ __qt_get_relative_resource_path_for_file(file_resource_path ${file})
+ if (arg_PREFIX STREQUAL "/")
+ # TO_CMAKE_PATH does not clean up cases such as //Foo
+ set(file_resource_path "/${file_resource_path}")
+ else()
+ set(file_resource_path "${arg_PREFIX}/${file_resource_path}")
+ endif()
+ if (file IN_LIST retained_files)
+ list(APPEND retained_resource_paths ${file_resource_path})
+ endif()
+ file(TO_CMAKE_PATH ${file_resource_path} file_resource_path)
+ list(APPEND file_resource_paths ${file_resource_path})
+ string(REGEX REPLACE "\.js$" "_js" compiled_file ${file_relative})
+ string(REGEX REPLACE "\.mjs$" "_mjs" compiled_file ${compiled_file})
+ string(REGEX REPLACE "\.qml$" "_qml" compiled_file ${compiled_file})
+ string(REGEX REPLACE "[\$#\?]+" "_" compiled_file ${compiled_file})
+ set(compiled_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${resource_name}/${compiled_file}.cpp")
+ get_filename_component(out_dir ${compiled_file} DIRECTORY)
+ if(NOT EXISTS ${out_dir})
+ file(MAKE_DIRECTORY ${out_dir})
+ endif()
+ add_custom_command(
+ OUTPUT ${compiled_file}
+ DEPENDS ${file_absolute}
+ ${QT_TOOL_PATH_SETUP_COMMAND}
+ COMMAND
+ @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen
+ --resource-path ${file_resource_path}
+ -o ${compiled_file}
+ ${file_absolute}
+ )
+ target_sources(${target} PRIVATE ${compiled_file})
+ endforeach()
+
+ set(qmlcache_loader_list "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${resource_name}/qml_loader_file_list.rsp")
+ file(GENERATE
+ OUTPUT ${qmlcache_loader_list}
+ CONTENT "$<JOIN:${file_resource_paths},\n>"
+ )
+
+ set(qmlcache_loader_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${resource_name}/qmlcache_loader.cpp")
+ set(resource_name_arg "${resource_name}.qrc")
+ if (chained_resource_name)
+ set(resource_name_arg "${resource_name_arg}=${chained_resource_name}")
+ endif()
+
+ if (retained_resource_paths)
+ set(retained_loader_list "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/${resource_name}/retained_file_list.rsp")
+ file(GENERATE
+ OUTPUT ${retained_loader_list}
+ CONTENT "$<JOIN:${retained_resource_paths},\n>"
+ )
+ set(retained_args "--retain" "@${retained_loader_list}")
+ endif()
+
+ add_custom_command(
+ OUTPUT ${qmlcache_loader_file}
+ DEPENDS ${qmlcache_loader_list}
+ ${QT_TOOL_PATH_SETUP_COMMAND}
+ COMMAND
+ @QT_CMAKE_EXPORT_NAMESPACE@::qmlcachegen
+ ${retained_args}
+ --resource-name "${resource_name_arg}"
+ -o ${qmlcache_loader_file}
+ "@${qmlcache_loader_list}"
+ )
+
+ __qt_propagate_generated_resource(${target}
+ ${resource_name}
+ ${qmlcache_loader_file}
+ output_target)
+
+ set(${arg_OUTPUT_GENERATED_TARGET} "${output_target}" PARENT_SCOPE)
+
+ if (resource_files)
+ set(resource_name ${chained_resource_name})
+ endif()
+
+ # The generated qmlcache_loader source file uses private headers of Qml, so make sure
+ # if the object library was created, it depends on the Qml target. If there's no target,
+ # that means the target is a shared library and the sources are directly added to the target
+ # via target_sources, so add dependency in that case as well.
+ set(chosen_target "target") # shared library case
+ if(output_target)
+ set(chosen_target "output_target") # static library case.
+ endif()
+ target_link_libraries(${${chosen_target}} PRIVATE @QT_CMAKE_EXPORT_NAMESPACE@::Qml)
+ else()
+ set(resource_files ${arg_FILES})
+ endif()
+
+ set(${arg_OUTPUT_REMAINING_RESOURCES} ${resource_files} PARENT_SCOPE)
+ set(${arg_OUTPUT_RESOURCE_NAME} ${resource_name} PARENT_SCOPE)
+endfunction()
+
+#
+# Process resources via file path instead of QRC files. Behind the
+# scnenes, it will generate a qrc file and apply post processing steps
+# when applicable. (e.g.: QtQuickCompiler)
+#
+# The QRC Prefix is set via the PREFIX parameter.
+#
+# Alias settings for files need to be set via the QT_RESOURCE_ALIAS property
+# via the set_soure_files_properties() command.
+#
+# When using this command with static libraries, one or more special targets
+# will be generated. Should you wish to perform additional processing on these
+# targets pass a value to the OUTPUT_TARGETS parameter.
+#
+function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
+
+ cmake_parse_arguments(rcc "" "PREFIX;LANG;BASE;OUTPUT_TARGETS" "FILES;OPTIONS" ${ARGN})
+
+ string(REPLACE "/" "_" resourceName ${resourceName})
+ string(REPLACE "." "_" resourceName ${resourceName})
+
+ set(output_targets "")
+ # Apply base to all files
+ if (rcc_BASE)
+ foreach(file IN LISTS rcc_FILES)
+ set(resource_file "${rcc_BASE}/${file}")
+ __qt_get_relative_resource_path_for_file(alias ${resource_file})
+ # Handle case where resources were generated from a directory
+ # different than the one where the main .pro file resides.
+ # Unless otherwise specified, we should use the original file path
+ # as alias.
+ if (alias STREQUAL resource_file)
+ set_source_files_properties(${resource_file} PROPERTIES QT_RESOURCE_ALIAS ${file})
+ endif()
+ file(TO_CMAKE_PATH ${resource_file} resource_file)
+ list(APPEND resource_files ${resource_file})
+ endforeach()
+ else()
+ set(resource_files ${rcc_FILES})
+ endif()
+
+ if(NOT rcc_PREFIX)
+ get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX)
+ if (NOT rcc_PREFIX)
+ message(FATAL_ERROR "QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
+ endif()
+ endif()
+
+ # Apply quick compiler pass
+ __qt_quick_compiler_process_resources(${target} ${resourceName}
+ FILES ${resource_files}
+ PREFIX ${rcc_PREFIX}
+ OUTPUT_REMAINING_RESOURCES resources
+ OUTPUT_RESOURCE_NAME newResourceName
+ OUTPUT_GENERATED_TARGET output_target_quick
+ )
+
+ if (NOT resources)
+ if (rcc_OUTPUT_TARGETS)
+ set(${rcc_OUTPUT_TARGETS} "${output_target_quick}" PARENT_SCOPE)
+ endif()
+ return()
+ endif()
+ list(APPEND output_targets ${output_target_quick})
+ set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/generated_${newResourceName}.qrc")
+ set(generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${newResourceName}.cpp")
+
+ # Generate .qrc file:
+
+ # <RCC><qresource ...>
+ set(qrcContents "<RCC>\n <qresource")
+ if (rcc_PREFIX)
+ string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"")
+ endif()
+ if (rcc_LANG)
+ string(APPEND qrcContents " lang=\"${rcc_LANG}\"")
+ endif()
+ string(APPEND qrcContents ">\n")
+
+ set(resource_dependencies)
+ foreach(file IN LISTS resources)
+ __qt_get_relative_resource_path_for_file(file_resource_path ${file})
+
+ if (NOT IS_ABSOLUTE ${file})
+ set(file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
+ endif()
+
+ ### FIXME: escape file paths to be XML conform
+ # <file ...>...</file>
+ string(APPEND qrcContents " <file alias=\"${file_resource_path}\">")
+ string(APPEND qrcContents "${file}</file>\n")
+ list(APPEND files "${file}")
+
+ get_source_file_property(target_dependency ${file} QT_RESOURCE_TARGET_DEPENDENCY)
+ if (NOT target_dependency)
+ list(APPEND resource_dependencies ${file})
+ else()
+ if (NOT TARGET ${target_dependency})
+ message(FATAL_ERROR "Target dependency on resource file ${file} is not a cmake target.")
+ endif()
+ list(APPEND resource_dependencies ${target_dependency})
+ endif()
+ endforeach()
+
+ # </qresource></RCC>
+ string(APPEND qrcContents " </qresource>\n</RCC>\n")
+
+ file(GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}")
+
+ set(rccArgs --name "${newResourceName}"
+ --output "${generatedSourceCode}" "${generatedResourceFile}")
+ if(rcc_OPTIONS)
+ list(APPEND rccArgs ${rcc_OPTIONS})
+ endif()
+
+ # Process .qrc file:
+ add_custom_command(OUTPUT "${generatedSourceCode}"
+ COMMAND "@QT_CMAKE_EXPORT_NAMESPACE@::rcc"
+ ARGS ${rccArgs}
+ DEPENDS ${resource_dependencies} ${generatedResourceFile}
+ COMMENT "RCC ${newResourceName}"
+ VERBATIM)
+
+ get_target_property(type "${target}" TYPE)
+ # Only do this if newResourceName is the same as resourceName, since
+ # the resource will be chainloaded by the qt quickcompiler
+ # qml cache loader
+ if(newResourceName STREQUAL resourceName)
+ __qt_propagate_generated_resource(${target} ${resourceName} "${generatedSourceCode}" output_target)
+ list(APPEND output_targets ${output_target})
+ else()
+ target_sources(${target} PRIVATE "${generatedSourceCode}")
+ endif()
+ if (rcc_OUTPUT_TARGETS)
+ set(${rcc_OUTPUT_TARGETS} "${output_targets}" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
new file mode 100644
index 0000000000..90588c99b3
--- /dev/null
+++ b/cmake/QtSetup.cmake
@@ -0,0 +1,176 @@
+## Set a default build type if none was specified
+
+# Set the QT_IS_BUILDING_QT variable so we can verify whether we are building
+# Qt from source
+set(QT_BUILDING_QT TRUE CACHE
+ TYPE STRING "When this is present and set to true, it signals that we are building Qt from source.")
+
+set(_default_build_type "Release")
+if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
+ set(_default_build_type "Debug")
+endif()
+
+# Reset content of extra build internal vars for each inclusion of QtSetup.
+unset(QT_EXTRA_BUILD_INTERNALS_VARS)
+
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to '${_default_build_type}' as none was specified.")
+ set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE
+ PROPERTY STRINGS
+ "Debug" "Release" "MinSizeRel" "RelWithDebInfo") # Set the possible values for cmake-gui.
+elseif(CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Building for multiple configurations: ${CMAKE_CONFIGURATION_TYPES}.")
+ message(STATUS "Main configuration is: ${QT_MULTI_CONFIG_FIRST_CONFIG}.")
+ if(CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE)
+ message(STATUS
+ "Default build configuration set to '${CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE}'.")
+ endif()
+endif()
+
+# Appends a 'debug postfix' to library targets (not executables)
+# e.g. lib/libQt6DBus_debug.5.12.0.dylib
+if(WIN32)
+ set(CMAKE_DEBUG_POSTFIX "d")
+elseif(APPLE)
+ set(CMAKE_DEBUG_POSTFIX "_debug")
+endif()
+
+## Position independent code:
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+# Do not relink dependent libraries when no header has changed:
+set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
+
+# Default to hidden visibility for symbols:
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+# Detect non-prefix builds, either when the install prefix is set to the binary dir
+# or when enabling developer builds and no prefix is specified.
+# This detection only happens when building qtbase, and later is propagated via the generated
+# QtBuildInternalsExtra.cmake file.
+if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
+ if((CMAKE_INSTALL_PREFIX STREQUAL CMAKE_BINARY_DIR) OR
+ (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build))
+
+ set(__qt_will_install_value OFF)
+ # Handle non-prefix builds by setting the CMake install prefix to point to qtbase's build
+ # dir.
+ # While building another repo (like qtsvg), the CMAKE_INSTALL_PREFIX or CMAKE_PREFIX_PATH
+ # (either work) should be set on the command line to point to the qtbase build dir.
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH
+ "Install path prefix, prepended onto install directories." FORCE)
+ else()
+ set(__qt_will_install_value ON)
+ endif()
+ set(QT_WILL_INSTALL ${__qt_will_install_value} CACHE BOOL
+ "Boolean indicating if doing a Qt prefix build (vs non-prefix build)." FORCE)
+ unset(__qt_will_install_value)
+endif()
+
+# Specify the QT_SOURCE_TREE only when building qtbase. Needed by some tests when the tests are
+# built as part of the project, and not standalone. For standalone tests, the value is set in
+# QtBuildInternalsExtra.cmake.
+if(PROJECT_NAME STREQUAL "QtBase")
+ set(QT_SOURCE_TREE "${QtBase_SOURCE_DIR}" CACHE PATH
+ "A path to the source tree of the previously configured QtBase project." FORCE)
+endif()
+
+if(FEATURE_developer_build)
+ if(DEFINED QT_CMAKE_EXPORT_COMPILE_COMMANDS)
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ${QT_CMAKE_EXPORT_COMPILE_COMMANDS})
+ else()
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+ endif()
+ set(QT_BUILD_TESTING ON)
+ set(__build_benchmarks ON)
+
+ # Tests are not built by default with qmake for iOS and friends, and thus the overall build
+ # tends to fail. Disable them by default when targeting uikit.
+ if(APPLE_UIKIT)
+ set(QT_BUILD_TESTING OFF)
+ endif()
+
+ # Disable benchmarks for single configuration generators which do not build
+ # with release configuration.
+ if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+ set(__build_benchmarks OFF)
+ endif()
+else()
+ set(QT_BUILD_TESTING OFF)
+ set(__build_benchmarks OFF)
+endif()
+
+## Set up testing
+option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING})
+if(QT_BUILD_STANDALONE_TESTS)
+ set(QT_BUILD_TESTING ON)
+
+ # BuildInternals might have set it to OFF on initial configuration. So force it to ON when
+ # building standalone tests.
+ set(BUILD_TESTING ON CACHE BOOL "Build the testing tree." FORCE)
+
+ # Also force the tests to be built as part of the default build target.
+ set(QT_NO_MAKE_TESTS OFF CACHE BOOL
+ "Should examples be built as part of the default 'all' target." FORCE)
+endif()
+option(QT_NO_MAKE_TESTS "Should tests be built as part of the default 'all' target." OFF)
+
+include(CTest)
+enable_testing()
+
+# Set up building of examples.
+set(QT_BUILD_EXAMPLES ON)
+# Examples are not built by default with qmake for iOS and friends, and thus the overall build
+# tends to fail. Disable them by default when targeting uikit.
+if(APPLE_UIKIT)
+ set(QT_BUILD_EXAMPLES OFF)
+endif()
+
+option(BUILD_EXAMPLES "Build Qt examples" ${QT_BUILD_EXAMPLES})
+option(QT_NO_MAKE_EXAMPLES "Should examples be built as part of the default 'all' target." OFF)
+
+# Build Benchmarks
+option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})
+
+## Android platform settings
+if(ANDROID)
+ include(QtPlatformAndroid)
+endif()
+
+## qt_add_module and co.:
+include(QtBuild)
+
+## Qt Feature support:
+include(QtFeature)
+
+## Compiler optimization flags:
+include(QtCompilerOptimization)
+
+## Compiler flags:
+include(QtCompilerFlags)
+
+## Set up non-prefix build:
+qt_set_up_nonprefix_build()
+
+qt_set_language_standards()
+
+## Find host tools (if non native):
+set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")
+
+if (CMAKE_CROSSCOMPILING AND NOT IS_DIRECTORY ${QT_HOST_PATH})
+ message(FATAL_ERROR "You need to set QT_HOST_PATH to cross compile Qt.")
+endif()
+
+## Enable support for sanitizers:
+include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake)
+
+option(QT_USE_CCACHE "Enable the use of ccache")
+if(QT_USE_CCACHE)
+ find_program(CCACHE_PROGRAM ccache)
+ set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
+ set(CMAKE_OBJC_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
+endif()
diff --git a/cmake/QtStandaloneTestsConfig.cmake.in b/cmake/QtStandaloneTestsConfig.cmake.in
new file mode 100644
index 0000000000..3d08ae0c12
--- /dev/null
+++ b/cmake/QtStandaloneTestsConfig.cmake.in
@@ -0,0 +1,2 @@
+find_package(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@
+ REQUIRED COMPONENTS @QT_REPO_KNOWN_MODULES_STRING@)
diff --git a/cmake/QtToolsConfig.cmake.in b/cmake/QtToolsConfig.cmake.in
new file mode 100644
index 0000000000..7b2fa1de74
--- /dev/null
+++ b/cmake/QtToolsConfig.cmake.in
@@ -0,0 +1,35 @@
+@PACKAGE_INIT@
+
+get_filename_component(_qt_tools_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
+
+ if (NOT @INSTALL_CMAKE_NAMESPACE@Tools_FIND_COMPONENTS)
+ set(@INSTALL_CMAKE_NAMESPACE@Tools_NOT_FOUND_MESSAGE
+ "The Qt tools package requires at least one component.")
+ set(@INSTALL_CMAKE_NAMESPACE@Tools_FOUND False)
+ return()
+ endif()
+
+foreach(module ${@INSTALL_CMAKE_NAMESPACE@Tools_FIND_COMPONENTS})
+ find_package(@INSTALL_CMAKE_NAMESPACE@${module}Tools
+ ${_@INSTALL_CMAKE_NAMESPACE@Tools_FIND_PARTS_QUIET}
+ ${_@INSTALL_CMAKE_NAMESPACE@Tools_FIND_PARTS_REQUIRED}
+ PATHS ${_qt_tools_cmake_dir} NO_DEFAULT_PATH
+ )
+ if (NOT @INSTALL_CMAKE_NAMESPACE@${module}Tools_FOUND)
+ string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
+
+ if (@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
+ set(_Qt_NOTFOUND_MESSAGE
+ "${_Qt_NOTFOUND_MESSAGE}Failed to find Qt component \"${module}\" config file.")
+ elseif(NOT Qt_FIND_QUIETLY)
+ message(WARNING "Failed to find Qt component \"${module}\" config file.")
+ endif()
+
+ unset(_expected_module_location)
+ endif()
+endforeach()
+
+if (_Qt_NOTFOUND_MESSAGE)
+ set(@INSTALL_CMAKE_NAMESPACE@Tools_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
+ set(@INSTALL_CMAKE_NAMESPACE@Tools_FOUND False)
+endif()
diff --git a/cmake/README.md b/cmake/README.md
new file mode 100644
index 0000000000..6b65f0e69a
--- /dev/null
+++ b/cmake/README.md
@@ -0,0 +1,308 @@
+# Status
+
+Initial port is on-going. Some modules of QtBase are ported, incl. some of the platform modules.
+Many libraries, tests and examples are still missing.
+
+Basic functionality is there (moc, uic, etc.), but documentation, translations, etc. are missing.
+
+NOTE: YOU NEED CMAKE 3.15 or later.
+
+# Intro
+
+The CMake update offers an opportunity to revisit some topics that came up during the last few
+years.
+
+* The Qt build system does not support building host tools during a cross-compilation run. You need
+ to build a Qt for your host machine first and then use the platform tools from that version. The
+ decision to do this was reached independent of cmake: This does save resources on build machines
+ as the host tools will only get built once.
+
+* 3rd-party dependencies are no longer built as part of Qt. zlib, libpng, etc. from src/3rdparty
+ need to be supplied from the outside to the build now. You may find apt-get/brew/etc. useful for
+ this. Otherwise you may consider using vcpkg as in the next section. The decision to remove 3rd
+ party dependencies from Qt repositories was reached independent of the decision to use cmake, we
+ just use the opportunity to implement this decision.
+
+* There is less need for bootstrapping. Only moc and rcc (plus the lesser known tracegen and
+ qfloat16-tables) are linking against the bootstrap Qt library. Everything else can link against
+ the full QtCore. This will include qmake, which is currently missing from a cmake build. This will
+ change: Qmake is supported as a build system for applications *using* Qt going forward and will
+ not go away anytime soon.
+
+* For the time being we try to keep qmake working so that we do not interfere too much with ongoing
+ development.
+
+
+# Building against VCPKG on Windows
+
+You may use vcpkg to install dependencies needed to build QtBase.
+
+ * ```git clone -b qt https://github.com/tronical/vcpkg```
+ * Run ```bootstrap-vcpkg.bat``` or ```bootstrap-vcpkg.sh```
+ * Set the ``VCPKG_DEFAULT_TRIPLET`` environment variable to ``qt-x64-windows-static`` or
+ ``qt-x86-windows-static``
+ * Set the ``VCPKG_ROOT`` environment variable to the path where you cloned vcpkg
+ * Build Qt dependencies: ``vcpkg install @qt-packages-windows.txt``
+ * When running cmake in qtbase, support for vcpkg will be picked up automatically when the
+ VCPKG_ROOT/VCPKG_DEFAULT_TRIPLET environment variable is set.
+
+# Building against homebrew on macOS
+
+You may use brew to install dependencies needed to build QtBase.
+
+ * Install homebrew:
+ ```/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"```
+ * Build Qt dependencies: ``brew install pcre2 harfbuzz freetype``
+ * Install cmake: ``brew install cmake``
+ * When running cmake in qtbase, pass ``-DCMAKE_PREFIX_PATH=/usr/local``
+
+# Building
+
+The basic way of building with cmake is as follows:
+
+```
+ cd {build directory}
+ cmake -DCMAKE_INSTALL_PREFIX=/path/where/to/install {path to source directory}
+ cmake --build .
+ cmake --install .
+```
+
+You need one build directory per Qt module. The build directory can be a sub-directory inside the
+module ``qtbase/build`` or an independent directory ``qtbase_build``. The installation prefix is
+chosen when running cmake by passing ``-DCMAKE_INSTALL_PREFIX``. To build more than one Qt module,
+make sure to pass the same install prefix.
+
+``cmake --build`` and ``cmake --install`` are simple wrappers around the basic build tool that CMake
+generated a build system for. It works with any supported build backend supported by cmake, but you
+can also use the backend build tool directly, e.g. by running ``make``.
+
+CMake has a ninja backend that works quite well and is noticeably faster than make, so you may want
+to use that:
+
+```
+ cd {build directory}
+ cmake -GNinja -DCMAKE_INSTALL_PREFIX=/path/where/to/install {path to source directory}
+ cmake --build .
+ cmake --install .
+```
+
+You can look into the generated ``build.ninja`` file if you're curious and you can also build
+targets directory such as ``ninja lib/libQt6Core.so``.
+
+Make sure to remove CMakeCache.txt if you forgot to set the CMAKE_INSTALL_PREFIX on the first
+configuration, otherwise a second re-configuration will not pick up the new install prefix.
+
+You can use ``cmake-gui {path to build directory}`` or ``ccmake {path to build directory}`` to
+configure the values of individual cmake variables or Qt features. After changing a value, you need
+to choose the *configure* step (usually several times:-/), followed by the *generate* step (to
+generate makefiles/ninja files).
+
+## Developer Build
+
+When working on Qt itself, it can be tedious to wait for the install step. In that case you want to
+use the developer build option, to get as many auto tests enabled and no longer be required to make
+install:
+
+```
+ cd {build directory}
+ cmake -GNinja -DCMAKE_INSTALL_PREFIX=/path/to/qtbase_build -DFEATURE_developer_build=ON {path to source directory}
+ cmake --build .
+ # do NOT make install
+```
+
+## Specifying configure.json features on the command line
+
+QMake defines most features in configure.json files, like -developer-build or -no-opengl.
+
+In CMake land, we currently generate configure.cmake files from the configure.json files into
+the source directory next to them using the helper script
+``path_to_qtbase_source/util/cmake/configurejson2cmake.py``. They are checked into the repository.
+If the feature in configure.json has the name "dlopen", you can specify whether to enable or disable that
+feature in CMake with a -D flag on the CMake command line. So for example -DFEATURE_dlopen=ON or
+-DFEATURE_sql_mysql=OFF. At the moment, if you change a FEATURE flag's value, you have to remove the
+CMakeCache.txt file and reconfigure with CMake. And even then you might stumble on some issues when
+reusing an existing build, because of an automoc bug in upstream CMake.
+
+## Ninja reconfiguration bug
+
+If you use the Ninja generator, there's a bug that after the first CMake configuration, if you run
+ninja, it will do the reconfiguration step again. This is quite annoying and time consuming.
+
+There is an open pull request that fixes the issue at
+https://github.com/ninja-build/ninja/pull/1527. You can build your own Ninja executable until the
+request is merged.
+
+```
+ cd {some directory}
+ git clone https://github.com/ninja-build/ninja.git
+ cd ninja && mkdir build && cd build
+ git remote add fix git@github.com:mathstuf/ninja.git && git fetch --all
+ git cherry-pick 29a565f18e01ce83ca14801f4684cd2acaf00d4c
+ ../configure.py --bootstrap
+ cp ninja /usr/local/bin/ninja
+```
+
+## Building with CCache
+
+You can pass ``-DQT_USE_CCACHE=ON`` to make the build system look for ``ccache`` in your ``PATH``
+and prepend it to all C/C++/Objective-C compiler calls. At the moment this is only supported for the
+Ninja and the Makefile generators.
+
+## Cross Compiling
+
+Compiling for a target architecture that's different than the host requires one build of Qt for the
+host. This "host build" is needed because the process of building Qt involves the compilation of
+intermediate code generator tools, that in turn are called to produce source code that needs to be
+compiled into the final libraries. These tools are built using Qt itself and they need to run on the
+machine you're building on, regardless of the architecure you are targeting.
+
+Build Qt regularly for your host system and install it into a directory of your choice using the
+``CMAKE_INSTALL_PREFIX`` variable. You are free to disable the build of tests and examples by
+passing ``-DBUILD_EXAMPLES=OFF`` and ``-DBUILD_TESTING=OFF``.
+
+With this installation of Qt in place, which contains all tools needed, we can proceed to create a
+new build of Qt that is cross-compiled to the target architecture of choice. You may proceed by
+setting up your environment. The CMake wiki has further information how to do that at
+
+<https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling>
+
+Yocto based device SDKs come with an environment setup script that needs to be sourced in your shell
+and takes care of setting up environment variables and a cmake alias with a toolchain file, so that
+you can call cmake as you always do.
+
+In order to make sure that Qt picks up the code generator tools from the host build, you need to
+pass an extra parameter to cmake:
+
+```
+ -DQT_HOST_PATH=/path/to/your/host_build
+```
+
+The specified path needs to point to a directory that contains an installed host build of Qt.
+
+### Cross Compiling for Android
+
+In order to cross-compile Qt to Android, you need a host build (see instructions above) and an
+Android build. In addition, it is necessary to install the Android NDK as well as vcpkg. Vcpkg is
+needed to supply third-party libraries that Qt requires but that are not part of the Android NDK.
+
+Vcpkg for Android can be set up using the following steps:
+
+ * ```git clone -b qt https://github.com/tronical/vcpkg```
+ * Run ```bootstrap-vcpkg.bat``` or ```bootstrap-vcpkg.sh```
+ * Set the ``VCPKG_DEFAULT_TRIPLET`` environment variable to one of the following values:
+ * ``arm-android`` (armeabi-v7a)
+ * ``arm64-android`` (arm64v8)
+ * ``x86-android`` (x86)
+ * ``x64-android`` (x86_64)
+ * Set the ``VCPKG_ROOT`` environment variable to the path where you cloned vcpkg
+ * Set the ``ANDROID_NDK_HOME`` environment variable to the path where you have installed the Android NDK.
+ * Set the ``ANDROID_SDK_HOME`` environment variable to the path where you have installed the Android SDK.
+ * Build Qt dependencies: ``vcpkg install @qt-packages-android.txt``
+
+When running cmake in qtbase, pass
+``-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DQT_HOST_PATH=/path/to/your/host/build -DANDROID_SDK_ROOT=$ANDROID_SDK_HOME -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH``
+
+If you don't supply the configuration argument ``-DANDROID_ABI=...``, it will default to
+``armeabi-v7a``. To target other architectures, use one of the following values:
+ * arm64: ``-DANDROID_ABI=arm64-v8``
+ * x86: ``-DANDROID_ABI=x86``
+ * x86_64: ``-DANDROID_ABI=x86_64``
+
+By default we set the android API level to 21. Should you need to change this supply the following
+configuration argument to the above CMake call: ``-DANDROID_NATIVE_API_LEVEL=${API_LEVEL}``
+
+### Cross compiling for iOS
+
+In order to cross-compile Qt to iOS, you need a host macOS build.
+In addition, it is necessary to install a custom version of vcpkg. Vcpkg is
+needed to supply third-party libraries that Qt requires, but that are not part of the iOS SDK.
+
+Vcpkg for iOS can be set up using the following steps:
+
+ * ```git clone -b qt https://github.com/alcroito/vcpkg```
+ * Run ```bootstrap-vcpkg.sh```
+ * Set the ``VCPKG_DEFAULT_TRIPLET`` environment variable to one of the following values:
+ * ``x64-ios`` (simulator x86_64)
+ * ``x86-ios`` (simulator i386)
+ * ``arm64-ios`` (device arm64)
+ * ``arm-ios`` (device armv7)
+ * ``fat-ios`` (simulator_and_device x86_64 and arm64* - special considedrations)
+ * Set the ``VCPKG_ROOT`` environment variable to the path where you cloned vcpkg
+ * Build Qt dependencies: ``vcpkg install @qt-packages-ios.txt``
+
+When running cmake in qtbase, pass
+``-DCMAKE_SYSTEM_NAME=iOS -DQT_HOST_PATH=/path/to/your/host/build -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH``
+
+If you don't supply the configuration argument ``-DQT_UIKIT_SDK=...``, it will default to
+``iphonesimulator``. To target another SDK / device type, use one of the following values:
+ * iphonesimulator: ``-DQT_UIKIT_SDK=iphonesimulator``
+ * iphoneos: ``-DQT_UIKIT_SDK=iphoneos``
+ * simulator_and_device: ``-DQT_FORCE_SIMULATOR_AND_DEVICE=ON -DQT_UIKIT_SDK=``
+
+Depending on what value you pass to ``-DQT_UIKIT_SDK=`` a list of target architectures is chosen
+by default:
+ * iphonesimulator: ``x86_64``
+ * iphoneos: ``arm64``
+ * simulator_and_device: ``arm64;x86_64``
+
+You can try choosing a different list of architectures by passing
+``-DCMAKE_OSX_ARCHITECTURES=x86_64;i386``.
+Note that if you choose different architectures compared to the default ones, the build might fail.
+Only do it if you know what you are doing.
+
+#### simulator_and_device special considerations
+To do a simulator_and_device build, a custom version of CMake is required in addition to the vcpkg
+fork. The merge request can be found here:
+https://gitlab.kitware.com/cmake/cmake/merge_requests/3617
+
+After you build your own copy of CMake using this merge request, you need to use it for both
+vcpkg and Qt.
+
+Note that vcpkg prefers its own version of CMake when building packages.
+Make sure to put your custom built CMake in PATH, and force vcpkg to use this CMake by running
+``export VCPKG_FORCE_SYSTEM_BINARIES=1`` in your shell.
+
+# Debugging CMake files
+
+CMake allows specifying the ``--trace`` and ``--trace-expand`` options, which work like
+``qmake -d -d``: As the cmake code is evaluated, the values of parameters and variables is shown.
+This can be a lot of output, so you may want to redirect it to a file.
+
+# Porting Help
+
+We have some python scripts to help with the conversion from qmake to cmake. These scripts can be
+found in ``utils/cmake``.
+
+## configurejson2cmake.py
+
+This script converts all ``configure.json`` in the Qt repository to ``configure.cmake`` files for
+use with CMake. We want to generate configure.cmake files for the foreseeable future, so if you need
+to tweak the generated configure.cmake files, please tweak the generation script instead.
+
+``configurejson2cmake.py`` is run like this: ``util/cmake/configurejson2cmake.py .`` in the
+top-level source directory of a Qt repository.
+
+
+## pro2cmake.py
+
+``pro2cmake.py`` generates a skeleton CMakeLists.txt file from a .pro-file. You will need to polish
+the resulting CMakeLists.txt file, but e.g. the list of files, etc. should be extracted for you.
+
+``pro2cmake.py`` is run like this: ``path_to_qtbase_source/util/cmake/pro2cmake.py some.pro``.
+
+
+## run_pro2cmake.py
+
+`` A small helper script to run pro2cmake.py on all .pro-files in a directory. Very useful to e.g.
+convert all the unit tests for a Qt module over to cmake;-)
+
+``run_pro2cmake.py`` is run like this: ``path_to_qtbase_source/util/cmake/run_pro2cmake.py some_dir``.
+
+
+## How to convert certain constructs
+
+| qmake | CMake |
+| ------ | ------ |
+| ``qtHaveModule(foo)`` | ``if(TARGET Qt::foo)`` |
+| ``qtConfig(foo)`` | ``if (QT_FEATURE_foo)`` |
+
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
new file mode 100644
index 0000000000..22bfe6baec
--- /dev/null
+++ b/cmake/qt.toolchain.cmake.in
@@ -0,0 +1,20 @@
+list(APPEND CMAKE_PREFIX_PATH "@CMAKE_INSTALL_PREFIX@")
+list(APPEND CMAKE_FIND_ROOT_PATH "@CMAKE_INSTALL_PREFIX@")
+
+@init_platform@
+
+@init_qt_host_path@
+
+@init_original_toolchain_file@
+
+@init_vcpkg@
+
+if(qt_chainload_toolchain_file)
+ include("${qt_chainload_toolchain_file}")
+ unset(qt_chainload_toolchain_file)
+endif()
+
+if(QT_HOST_PATH)
+ list(APPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH}")
+ list(APPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
+endif()
diff --git a/cmake/tests/CMakeLists.txt b/cmake/tests/CMakeLists.txt
new file mode 100644
index 0000000000..6b53c9703d
--- /dev/null
+++ b/cmake/tests/CMakeLists.txt
@@ -0,0 +1,48 @@
+# These macros are inspired by ECM:
+
+# a macro for tests that have a simple format where the name matches the
+# directory and project
+
+# The following macros will produce tests that generate the build
+# system for the test project, build it and then run its tests.
+macro(add_cmake_test_generate_build_run_variant name base command)
+ string(REPLACE "." "/" src_dir "${base}")
+ string(REPLACE "." "/" build_dir "${name}")
+ string(REGEX REPLACE "[^.]*\\." "" proj "${name}")
+ add_test(NAME "cmake_${name}"
+ COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}"
+ --build-two-config
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project ${proj}
+ ${${name}_EXTRA_OPTIONS}
+ --test-command ${command} ${ARGN})
+endmacro()
+
+macro(add_cmake_test_generate_build_run name)
+ add_cmake_test_generate_build_run_variant("${name}" "${name}" ${ARGN})
+endmacro()
+
+# The following macros will produce tests that just run cmake
+# to generate the build system for the test project.
+macro(add_cmake_test_generate_variant name base)
+ string(REPLACE "." "/" src_dir "${base}")
+ string(REPLACE "." "/" build_dir "${name}")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
+ add_test(NAME "cmake_${name}"
+ COMMAND "${CMAKE_COMMAND}" "-G${CMAKE_GENERATOR}"
+ "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
+ ${${name}_EXTRA_OPTIONS}
+ "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
+endmacro()
+
+macro(add_cmake_test_generate name)
+ add_cmake_test_generate_variant("${name}" "${name}")
+endmacro()
+
+add_cmake_test_generate(features)
+add_cmake_test_generate(qt_make_output_file)
diff --git a/cmake/tests/empty.cpp b/cmake/tests/empty.cpp
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cmake/tests/empty.cpp
diff --git a/cmake/tests/features/CMakeLists.txt b/cmake/tests/features/CMakeLists.txt
new file mode 100644
index 0000000000..0fff2b8be9
--- /dev/null
+++ b/cmake/tests/features/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.12.0)
+
+project(FeaturesTest
+ VERSION 1.0.0
+ DESCRIPTION "QtFeature test"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+)
+
+## Add some paths to check for cmake modules:
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/extra-cmake-modules/find-modules;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/kwin")
+
+## Qt specific setup common for all modules:
+include(QtSetup)
+
+## Library to hold global features:
+add_library(GlobalConfig INTERFACE)
+
+qt_feature_module_begin(LIBRARY GlobalConfig
+ PUBLIC_FILE src/corelib/global/qconfig.h
+ PRIVATE_FILE src/corelib/global/qconfig_p.h
+)
+include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
+qt_feature_module_end(GlobalConfig)
+
+assert(QT_FEATURE_top_a STREQUAL "ON")
+assert(QT_FEATURE_top_b STREQUAL "OFF")
+assert(QT_FEATURE_top_enabled STREQUAL "ON")
+assert(QT_FEATURE_top_disabled STREQUAL "OFF")
+assert(QT_FEATURE_top_disabled_enabled STREQUAL "OFF")
+assert(QT_FEATURE_top_not_emitted STREQUAL "OFF")
+
+## Enable feature summary at the end of the configure run:
+include(FeatureSummary)
+
+add_subdirectory(src)
+
+## Delayed actions on some of the Qt targets:
+include(QtPostProcess)
+
+## Print a feature summary:
+feature_summary(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/cmake/tests/features/configure.cmake b/cmake/tests/features/configure.cmake
new file mode 100644
index 0000000000..ace2b62450
--- /dev/null
+++ b/cmake/tests/features/configure.cmake
@@ -0,0 +1,35 @@
+#### Features
+
+# This belongs into gui, but the license check needs it here already.
+qt_feature("top_a" PRIVATE
+ LABEL "top_a"
+ CONDITION ON
+)
+qt_feature("top_b" PUBLIC PRIVATE
+ LABEL "top_b"
+ AUTODETECT OFF
+)
+qt_feature_definition("top_a" "top_defa")
+
+qt_feature("top_enabled" PRIVATE
+ LABEL "top_enabled"
+ ENABLE ON
+)
+
+qt_feature("top_disabled" PRIVATE
+ LABEL "top_enabled"
+ DISABLE ON
+)
+
+qt_feature("top_disabled_enabled" PRIVATE
+ LABEL "top_enabled_enabled"
+ DISABLE ON
+ ENABLE ON
+)
+
+qt_feature("top_not_emitted" PRIVATE
+ LABEL "top_not_emitted"
+ EMIT_IF OFF
+)
+
+qt_extra_definition("top_extra" "PUBLIC_FOO" PUBLIC)
diff --git a/cmake/tests/features/src/CMakeLists.txt b/cmake/tests/features/src/CMakeLists.txt
new file mode 100644
index 0000000000..bfb02be07d
--- /dev/null
+++ b/cmake/tests/features/src/CMakeLists.txt
@@ -0,0 +1,7 @@
+## Features from parent scope were inherited:
+assert(QT_FEATURE_top_a STREQUAL "ON")
+assert(QT_FEATURE_top_b STREQUAL "OFF")
+assert(QT_FEATURE_top_enabled STREQUAL "ON")
+assert(QT_FEATURE_top_disabled STREQUAL "OFF")
+assert(QT_FEATURE_top_disabled_enabled STREQUAL "OFF")
+assert(QT_FEATURE_top_not_emitted STREQUAL "OFF")
diff --git a/cmake/tests/main.cpp b/cmake/tests/main.cpp
new file mode 100644
index 0000000000..a9b8738990
--- /dev/null
+++ b/cmake/tests/main.cpp
@@ -0,0 +1 @@
+int main(int argc, char** argv) { return 0; }
diff --git a/cmake/tests/qt_make_output_file/CMakeLists.txt b/cmake/tests/qt_make_output_file/CMakeLists.txt
new file mode 100644
index 0000000000..3620909494
--- /dev/null
+++ b/cmake/tests/qt_make_output_file/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.12.0)
+
+project(QtMakeOutputFileTest
+ VERSION 1.0.0
+ DESCRIPTION "qt_make_output_file test"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+)
+
+## Add some paths to check for cmake modules:
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/extra-cmake-modules/find-modules;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/kwin")
+
+include(QtBuild)
+
+qt_make_output_file("foo.cpp" "" ".mapped" "/tmp/foo" "/tmp/bar" outfile)
+assert(outfile STREQUAL "/tmp/bar/foo.mapped")
+
+qt_make_output_file("../foo.cpp" "prefix_" ".cpp" "/tmp/foo" "/tmp/bar" outfile)
+assert(outfile STREQUAL "/tmp/bar/__/prefix_foo.cpp")
+
+qt_make_output_file("/tmp/bar/foo.cpp" "prefix_" ".cpp" "/tmp/foo" "/tmp/bar" outfile)
+assert(outfile STREQUAL "/tmp/bar/prefix_foo.cpp")
diff --git a/cmake/tests/test.cmake b/cmake/tests/test.cmake
new file mode 100644
index 0000000000..099f490c94
--- /dev/null
+++ b/cmake/tests/test.cmake
@@ -0,0 +1,54 @@
+# FAKE moc-ing:
+set(QT_MOCSCANNER /usr/bin/true)
+
+# Fake mocscanner run.
+# The files passed in after MOC will be reported to be in need of moc-ing,
+# but will not be built.
+# The files passed in after MOC_AND_BUILD will be reported to be in need
+# of moc-ing and should also be built by the target.
+function(fake_moc_results)
+ cmake_parse_arguments(arg "" "" "MOC;MOC_AND_BUILD" ${ARGN})
+
+ string(REPLACE ";" "\n" arg_MOC "${arg_MOC}")
+ string(REPLACE ";" "\n" arg_MOC_AND_BUILD "${arg_MOC_AND_BUILD}")
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_included.txt" "${arg_MOC}")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_to_build.txt" "${arg_MOC_AND_BUILD}")
+endfunction()
+
+# Test whether a target has a file listed in its sources.
+# Tests with the BUILD flag set will require this file to be built,
+# while those without will require the file to not be built by
+# the target.
+function(test_source_file target file)
+ cmake_parse_arguments(arg "BUILD" "" "" ${ARGN})
+
+ get_target_property(sources "${target}" SOURCES)
+ list(FIND sources "${file}" source_pos)
+ assert(NOT source_pos STREQUAL "-1")
+
+ get_source_file_property(prop "${file}" HEADER_FILE_ONLY)
+ if (arg_BUILD)
+ assert(NOT prop)
+ else()
+ assert(prop)
+ endif()
+endfunction()
+
+# Test whether or not a target uses a header path
+# The test passes when the path is in the list of include directories.
+# Passing 'UNKNOWN' to this function reverses the test result.
+function(test_include_directory target path)
+ cmake_parse_arguments(arg "UNKNOWN" "" "" ${ARGN})
+ get_target_property(includes "${target}" INCLUDE_DIRECTORIES)
+ list(FIND includes "${path}" include_pos)
+ if(arg_UNKNOWN)
+ assert(include_pos STREQUAL "-1")
+ else()
+ assert(NOT include_pos STREQUAL "-1")
+ endif()
+endfunction()
+
+# Add Core and Qt::Core libraries:
+add_library(Core SHARED "${CMAKE_CURRENT_LIST_DIR}/empty.cpp")
+add_library(Qt::Core ALIAS Core)