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.cmake164
-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/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.in13
-rw-r--r--cmake/FindATSPI2.cmake8
-rw-r--r--cmake/FindAtomic.cmake44
-rw-r--r--cmake/FindCups.cmake98
-rw-r--r--cmake/FindGLESv2.cmake40
-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/FindPPS.cmake19
-rw-r--r--cmake/FindSlog2.cmake19
-rw-r--r--cmake/FindTslib.cmake7
-rw-r--r--cmake/FindWrapDBus1.cmake31
-rw-r--r--cmake/FindWrapDoubleConversion.cmake61
-rw-r--r--cmake/FindWrapFreetype.cmake33
-rw-r--r--cmake/FindWrapPCRE2.cmake20
-rw-r--r--cmake/FindWrapRt.cmake34
-rw-r--r--cmake/FindXKB_COMMON_X11.cmake7
-rw-r--r--cmake/FindXRender.cmake9
-rw-r--r--cmake/FindZSTD.cmake50
-rw-r--r--cmake/Finddouble-conversion.cmake32
-rw-r--r--cmake/QtAutoDetect.cmake57
-rw-r--r--cmake/QtBaseCMakeTesting.cmake9
-rw-r--r--cmake/QtBaseConfigureTests.cmake150
-rw-r--r--cmake/QtBaseGlobalTargets.cmake226
-rw-r--r--cmake/QtBuild.cmake2416
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake206
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake148
-rw-r--r--cmake/QtBuildInternalsExtra.cmake.in17
-rw-r--r--cmake/QtCompilerFlags.cmake6
-rw-r--r--cmake/QtCompilerOptimization.cmake121
-rw-r--r--cmake/QtConfig.cmake.in49
-rw-r--r--cmake/QtFeature.cmake542
-rw-r--r--cmake/QtInternalTargets.cmake98
-rw-r--r--cmake/QtModuleConfig.cmake.in35
-rw-r--r--cmake/QtModuleDependencies.cmake.in76
-rw-r--r--cmake/QtModuleToolsConfig.cmake.in14
-rw-r--r--cmake/QtModuleToolsDependencies.cmake.in16
-rw-r--r--cmake/QtPlatformAndroid.cmake288
-rw-r--r--cmake/QtPlatformSupport.cmake81
-rw-r--r--cmake/QtPluginConfig.cmake.in15
-rw-r--r--cmake/QtPluginDependencies.cmake.in54
-rw-r--r--cmake/QtPlugins.cmake.in40
-rw-r--r--cmake/QtPostProcess.cmake293
-rw-r--r--cmake/QtProperties.cmake61
-rw-r--r--cmake/QtSetup.cmake113
-rw-r--r--cmake/QtToolsConfig.cmake.in35
-rw-r--r--cmake/README.md194
-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
74 files changed, 7900 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..de271a1140
--- /dev/null
+++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
@@ -0,0 +1,164 @@
+#.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()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(EGL
+ FOUND_VAR
+ EGL_FOUND
+ REQUIRED_VARS
+ EGL_LIBRARY
+ EGL_INCLUDE_DIR
+ HAVE_EGL
+ VERSION_VAR
+ EGL_VERSION
+)
+
+if(EGL_FOUND AND NOT TARGET EGL::EGL)
+ 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()
+
+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/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..fe15a1efc6
--- /dev/null
+++ b/cmake/3rdpartyConfig.cmake.in
@@ -0,0 +1,13 @@
+@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}")
+
+include("${CMAKE_CURRENT_LIST_DIR}/@target@Targets.cmake")
diff --git a/cmake/FindATSPI2.cmake b/cmake/FindATSPI2.cmake
new file mode 100644
index 0000000000..87e3838ee9
--- /dev/null
+++ b/cmake/FindATSPI2.cmake
@@ -0,0 +1,8 @@
+include(FindPkgConfig)
+
+if(NOT TARGET PkgConfig::ATSPI2)
+ pkg_check_modules(ATSPI2 atspi-2 IMPORTED_TARGET)
+ if (NOT TARGET PkgConfig::ATSPI2)
+ set(ATSPI2_FOUND 0)
+ endif()
+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/FindGLESv2.cmake b/cmake/FindGLESv2.cmake
new file mode 100644
index 0000000000..a4af6cbbbc
--- /dev/null
+++ b/cmake/FindGLESv2.cmake
@@ -0,0 +1,40 @@
+include(CheckCXXSourceCompiles)
+
+find_library(GLESv2_LIBRARY NAMES GLESv2)
+find_path(GLESv2_INCLUDE_DIR NAMES "GLES2/gl2.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)
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2)
+
+mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2)
+
+if(GLESv2_FOUND AND NOT TARGET GLESv2::GLESv2)
+ add_library(GLESv2::GLESv2 UNKNOWN IMPORTED)
+ set_target_properties(GLESv2::GLESv2 PROPERTIES
+ IMPORTED_LOCATION "${GLESv2_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}")
+endif()
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..09c6452932
--- /dev/null
+++ b/cmake/FindLibsystemd.cmake
@@ -0,0 +1,7 @@
+find_package(PkgConfig)
+
+pkg_check_modules(Libsystemd systemd 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/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..42349a8b1a
--- /dev/null
+++ b/cmake/FindWrapDBus1.cmake
@@ -0,0 +1,31 @@
+# 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()
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/FindWrapPCRE2.cmake b/cmake/FindWrapPCRE2.cmake
new file mode 100644
index 0000000000..b69c5078a5
--- /dev/null
+++ b/cmake/FindWrapPCRE2.cmake
@@ -0,0 +1,20 @@
+include_guard(GLOBAL) # pragma once equivalent
+
+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..9f2e341208
--- /dev/null
+++ b/cmake/FindXRender.cmake
@@ -0,0 +1,9 @@
+include(FindPkgConfig)
+
+if(NOT TARGET PkgConfig::XRender)
+ pkg_check_modules(XRender xrender IMPORTED_TARGET)
+
+ if (NOT TARGET PkgConfig::XRender)
+ set(XRender_FOUND 0)
+ endif()
+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/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
new file mode 100644
index 0000000000..a1e66ffcbe
--- /dev/null
+++ b/cmake/QtAutoDetect.cmake
@@ -0,0 +1,57 @@
+#
+# Collection of auto dection routines to improve the user eperience when
+# building Qt from source.
+#
+
+function(qt_auto_detect_android)
+ if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID)
+
+ 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})
+ 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)
+ endif()
+endfunction()
+
+
+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..2787edaecd
--- /dev/null
+++ b/cmake/QtBaseConfigureTests.cmake
@@ -0,0 +1,150 @@
+include(CheckCXXSourceCompiles)
+
+function(run_config_test_architecture)
+ # Test architecture
+ set(_arch_file "${CMAKE_CURRENT_BINARY_DIR}/architecture_test")
+ try_compile(_arch_result "${CMAKE_CURRENT_BINARY_DIR}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/config.tests/arch/arch.cpp"
+ COPY_FILE "${_arch_file}")
+ if (NOT _arch_result)
+ message(FATAL_ERROR "Failed to compile architecture detection file.")
+ endif()
+
+ 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")
+ 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")
+ endforeach()
+ set(TEST_buildAbi "${_build_abi}" CACHE INTERNAL "Target machine buildAbi")
+endfunction()
+
+
+function(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(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(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(run_config_tests)
+ 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)
+ run_config_test_sun_iconv()
+ endif()
+ run_config_test_architecture()
+ run_linker_version_script_support()
+endfunction()
+
+run_config_tests()
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
new file mode 100644
index 0000000000..059f528ca6
--- /dev/null
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -0,0 +1,226 @@
+## QtPlatform Target:
+add_library(Platform INTERFACE)
+add_library(Qt::Platform ALIAS Platform)
+target_include_directories(Platform
+ INTERFACE
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${QT_PLATFORM_DEFINITION_DIR}>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ $<INSTALL_INTERFACE:${INSTALL_DATADIR}/${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()
+
+if(APPLE)
+ if(CMAKE_OSX_SYSROOT)
+ list(APPEND init_platform "set(CMAKE_OSX_SYSROOT \"${CMAKE_OSX_SYSROOT}\" CACHE PATH \"\")")
+ endif()
+ if(CMAKE_OSX_DEPLOYMENT_TARGET)
+ list(APPEND init_platform "set(CMAKE_OSX_DEPLOYMENT_TARGET \"${CMAKE_OSX_DEPLOYMENT_TARGET}\" CACHE STRING \"\")")
+ endif()
+elseif(WIN32)
+ # 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%.
+ 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 \"\")")
+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 \"\")")
+endif()
+
+string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}")
+string(REPLACE ";" "\n" 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}/bin/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}/bin/qt-cmake.bat" DESTINATION "${INSTALL_BINDIR}")
+endif()
+
+## 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")
+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/QtBuild.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/QtPluginConfig.cmake.in
+ cmake/QtPluginDependencies.cmake.in
+ DESTINATION "${__GlobalConfig_install_dir}"
+)
+if(QT_WILL_INSTALL)
+ # NOTE: QtFeature.cmake is included by the Qt module config files unconditionally
+ # In a prefix build, QtFeature.cmake is not copied to the build dir by default
+ # Thus do it explicitly in that case so we can use the module config files in the examples
+ file(COPY cmake/QtFeature.cmake DESTINATION "${__GlobalConfig_install_dir}")
+endif()
+
+
+# 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"
+ DESTINATION "${__build_internals_install_dir}"
+ COMPONENT Devel
+)
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
new file mode 100644
index 0000000000..fc2007517a
--- /dev/null
+++ b/cmake/QtBuild.cmake
@@ -0,0 +1,2416 @@
+include(CMakePackageConfigHelpers)
+
+# Install locations:
+set(INSTALL_BINDIR "bin" CACHE PATH "Executables [PREFIX/bin]")
+set(INSTALL_INCLUDEDIR "include" CACHE PATH "Header files [PREFIX/include]")
+set(INSTALL_LIBDIR "lib" CACHE PATH "Libraries [PREFIX/lib]")
+set(INSTALL_ARCHDATADIR "." CACHE PATH "Arch-dependent data [PREFIX]")
+set(INSTALL_PLUGINSDIR "${INSTALL_ARCHDATADIR}/plugins" CACHE PATH
+ "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 PATH
+ "Helper programs [ARCHDATADIR/bin on Windows, ARCHDATADIR/libexec otherwise]")
+set(INSTALL_IMPORTDIR "${INSTALL_ARCHDATADIR}/imports" CACHE PATH
+ "QML1 imports [ARCHDATADIR/imports]")
+set(INSTALL_QMLDIR "${INSTALL_ARCHDATADIR}/qml" CACHE PATH
+ "QML2 imports [ARCHDATADIR/qml]")
+set(INSTALL_DATADIR "." CACHE PATH "Arch-independent data [PREFIX]")
+set(INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" CACHE PATH "Documentation [DATADIR/doc]")
+set(INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations" CACHE PATH
+ "Translations [DATADIR/translations]")
+set(INSTALL_SYSCONFDIR "etc/xdg" CACHE PATH
+ "Settings used by Qt programs [PREFIX/etc/xdg]")
+set(INSTALL_EXAMPLESDIR "examples" CACHE PATH "Examples [PREFIX/examples]")
+set(INSTALL_TESTSDIR "tests" CACHE PATH "Tests [PREFIX/tests]")
+
+# 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}")
+
+# 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}/lib" isSystemDir)
+IF("${isSystemDir}" STREQUAL "-1")
+ SET(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/lib")
+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)
+
+# 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)
+ set(QT_QMAKE_TARGET_MKSPEC win32-clang)
+ elseif(MINGW)
+ set(QT_QMAKE_TARGET_MKSPEC win32-g++)
+ 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)
+endif()
+
+# TODO: Fixme to be correct.
+set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
+
+if(QT_QMAKE_TARGET_MKSPEC)
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/${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_NAMESPACE "" CACHE STRING "Qt Namespace")
+if(QT_NAMESPACE STREQUAL "")
+ set(QT_HAS_NAMESPACE OFF)
+else()
+ set(QT_HAS_NAMESPACE ON)
+endif()
+
+macro(qt_internal_set_qt_known_modules)
+ set(QT_KNOWN_MODULES ${ARGN} CACHE INTERNAL "Known Qt modules" FORCE)
+endmacro()
+macro(qt_internal_set_qt_known_plugins)
+ set(QT_KNOWN_PLUGINS ${ARGN} CACHE INTERNAL "Known Qt plugins" FORCE)
+endmacro()
+
+# Reset:
+qt_internal_set_qt_known_modules("")
+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)
+ 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.
+#
+# 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_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()
+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 "")
+
+# Functions and macros:
+
+# 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(remove_install_target)
+ 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)
+ remove_install_target()
+ endif()
+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)
+ set(options)
+ set(multiopts QMAKE_MODULE_CONFIG)
+ cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN})
+
+ qt_internal_module_info(module "${target}")
+ set(pri_files)
+
+ get_target_property(enabled_features "${target}" QT_ENABLED_PUBLIC_FEATURES)
+ get_target_property(disabled_features "${target}" QT_DISABLED_PUBLIC_FEATURES)
+ get_target_property(enabled_private_features "${target}" QT_ENABLED_PRIVATE_FEATURES)
+ get_target_property(disabled_private_features "${target}" 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} mkspecs)
+ 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 mkspecs)
+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.
+ 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})
+
+ 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(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()
+
+
+function(qt_internal_add_link_flags_no_undefined target)
+ if (GCC OR CLANG)
+ if(APPLE)
+ set(no_undefined_flag "-Wl,-undefined,error")
+ elseif(LINUX OR MINGW OR ANDROID)
+ set(no_undefined_flag "-Wl,--no-undefined")
+ else()
+ 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)
+ 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}" "${PROJECT_SOURCE_DIR}/mkspecs/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_include_dir with the module's include directory in the binary tree
+# * 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}")
+ set("${result}_upper" "${upper}" PARENT_SCOPE)
+ set("${result}_lower" "${lower}" 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_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")
+ 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()
+
+# This function can be used to add sources/libraries/etc. to the specified CMake target
+# if the provided CONDITION evaluates to true.
+function(extend_target target)
+ if (NOT TARGET "${target}")
+ message(FATAL_ERROR "Trying to extend non-existing target \"${target}\".")
+ endif()
+ qt_parse_all_arguments(arg "extend_target" "" ""
+ "CONDITION;${__default_public_args};${__default_private_args};COMPILE_FLAGS" ${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("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()
+
+ foreach(lib ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES})
+ 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()
+ target_include_directories("${target}" PUBLIC ${arg_PUBLIC_INCLUDE_DIRECTORIES} PRIVATE ${arg_INCLUDE_DIRECTORIES})
+ target_compile_definitions("${target}" PUBLIC ${arg_PUBLIC_DEFINES} PRIVATE ${arg_DEFINES})
+ target_link_libraries("${target}" PUBLIC ${arg_PUBLIC_LIBRARIES} PRIVATE ${arg_LIBRARIES})
+ target_compile_options("${target}" PUBLIC ${arg_PUBLIC_COMPILE_OPTIONS} PRIVATE ${arg_COMPILE_OPTIONS})
+ target_link_options("${target}" PUBLIC ${arg_PUBLIC_LINK_OPTIONS} PRIVATE ${arg_LINK_OPTIONS})
+
+ set_target_properties("${target}" PROPERTIES
+ AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}"
+ _qt_target_deps "${target_deps}"
+ )
+
+ # When computing the private library dependencies, we need to check not only the known
+ # modules added by this repo's qt_build_repo() (which are stored in QT_KNOWN_MODULES), but
+ # also all module dependencies that were found via find_package() (which are stored in
+ # QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE).
+ set(known_modules ${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE} ${QT_KNOWN_MODULES})
+ list(REMOVE_DUPLICATES 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})
+
+ else()
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("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
+ set("${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x040800" PARENT_SCOPE)
+ else()
+ # On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
+ set("${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x050000" PARENT_SCOPE)
+ endif()
+ set("${result}" "QT_DEPRECATED_WARNINGS_SINCE=0x060000" PARENT_SCOPE)
+endfunction()
+
+
+function(qt_install_injections module build_dir install_dir)
+ set(injections ${ARGN})
+ # 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}")
+
+ # 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)
+
+ # 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")
+
+ # 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)
+ 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()
+
+# 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(add_qt_module target)
+ qt_internal_module_info(module "${target}")
+
+ # Process arguments:
+ qt_parse_all_arguments(arg "add_qt_module"
+ "NO_MODULE_HEADERS;STATIC;DISABLE_TOOLS_EXPORT;EXCEPTIONS;INTERNAL_MODULE;NO_SYNC_QT"
+ "CONFIG_MODULE_NAME"
+ "${__default_private_args};${__default_public_args};QMAKE_MODULE_CONFIG" ${ARGN})
+
+ if(NOT DEFINED arg_CONFIG_MODULE_NAME)
+ set(arg_CONFIG_MODULE_NAME "${module_lower}")
+ endif()
+
+ qt_internal_set_qt_known_modules("${QT_KNOWN_MODULES}" "${target}")
+
+ ### Define Targets:
+ if(${arg_STATIC})
+ add_library("${target}" STATIC)
+ elseif(${QT_BUILD_SHARED_LIBS})
+ add_library("${target}" SHARED)
+ else()
+ add_library("${target}" STATIC)
+ endif()
+ qt_internal_add_target_aliases("${target}")
+
+ # Add _private target to link against the private headers:
+ set(target_private "${target}Private")
+ add_library("${target_private}" INTERFACE)
+ qt_internal_add_target_aliases("${target_private}")
+
+ # Module headers:
+ if(${arg_NO_MODULE_HEADERS} OR ${arg_NO_SYNC_QT})
+ set_target_properties("${target}" PROPERTIES 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 MODULE_HAS_HEADERS ON)
+
+ ### FIXME: Can we replace headers.pri?
+ qt_read_headers_pri("${target}" "module_headers")
+ set_property(TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}")
+ set_property(TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_include_dir}/${module}Depends")
+ set_property(TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}")
+ if(module_headers_qpa)
+ qt_install(FILES ${module_headers_qpa} DESTINATION ${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}/${module}/qpa)
+ endif()
+ endif()
+
+ # Plugin types associated to a module
+ if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x")
+ set_target_properties("${target}" PROPERTIES MODULE_PLUGIN_TYPES "${arg_PLUGIN_TYPES}")
+ endif()
+
+ set_target_properties("${target}" PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
+ RUNTIME_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ RUNTIME_OUTPUT_DIRECTORY_DEBUG "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
+ VERSION ${PROJECT_VERSION}
+ SOVERSION ${PROJECT_VERSION_MAJOR}
+ OUTPUT_NAME "${INSTALL_CMAKE_NAMESPACE}${target}"
+ )
+
+ qt_internal_library_deprecation_level(deprecation_define)
+
+ qt_autogen_tools_initial_setup(${target})
+
+ set(_public_includes
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${module_include_dir}>
+ )
+ if(NOT arg_NO_MODULE_HEADERS)
+ list(APPEND _public_includes $<INSTALL_INTERFACE:include/${module}>)
+ endif()
+ list(APPEND _public_includes ${arg_PUBLIC_INCLUDE_DIRECTORIES})
+
+ extend_target("${target}"
+ SOURCES ${arg_SOURCES}
+ PUBLIC_INCLUDE_DIRECTORIES
+ ${_public_includes}
+ INCLUDE_DIRECTORIES
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ "${module_include_dir}/${PROJECT_VERSION}"
+ "${module_include_dir}/${PROJECT_VERSION}/${module}"
+ ${arg_INCLUDE_DIRECTORIES}
+ 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}
+ )
+
+ if(NOT ${arg_EXCEPTIONS})
+ 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(DEFINED module_headers_private)
+ qt_internal_add_linker_version_script("${target}" PRIVATE_HEADERS ${module_headers_private})
+ else()
+ qt_internal_add_linker_version_script("${target}")
+ 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("${module}" "${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()
+
+ 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()
+
+ 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} ${target_private})
+ 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}
+ PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}
+ PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}/${module}/private
+ )
+
+ if (ANDROID)
+ # 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} mkspecs/modules)
+ qt_generate_module_pri_file("${target}" "${pri_target_path}" module_pri_files
+ ${arg_INTERNAL_MODULE}
+ QMAKE_MODULE_CONFIG
+ ${arg_QMAKE_MODULE_CONFIG}
+ )
+ qt_install(FILES "${module_pri_files}" DESTINATION mkspecs/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.
+ qt_internal_add_link_flags_no_undefined("${target}")
+
+ target_include_directories("${target_private}" INTERFACE
+ $<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)
+ target_include_directories("${target_private}" INTERFACE
+ $<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}>
+ $<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}/${module}>
+ )
+ endif()
+
+ if(NOT ${arg_DISABLE_TOOLS_EXPORT})
+ qt_export_tools(${target})
+ endif()
+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 and the function is called manually and not
+ # by add_qt_module.
+
+ 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 "")
+ foreach(tool_name ${QT_KNOWN_MODULE_${module_name}_TOOLS})
+ 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}")
+ endforeach()
+
+ string(APPEND extra_cmake_statements
+"set(${QT_CMAKE_EXPORT_NAMESPACE}${module_name}Tools_TARGETS \"${tool_targets}\")")
+
+ 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}")
+
+
+ qt_internal_export_modern_cmake_config_targets_file(TARGETS ${QT_KNOWN_MODULE_${module_name}_TOOLS}
+ EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
+ CONFIG_INSTALL_DIR ${config_install_dir})
+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 "add_qt_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)
+ foreach(qt_module ${QT_KNOWN_MODULES})
+ get_target_property(plugin_types "${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()
+
+# 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(add_qt_plugin target)
+ qt_internal_module_info(module "${target}")
+
+ qt_internal_set_qt_known_plugins("${QT_KNOWN_PLUGINS}" "${target}")
+
+ qt_parse_all_arguments(arg "add_qt_plugin" "STATIC;EXCEPTIONS"
+ "TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY"
+ "${__default_private_args};${__default_public_args};DEFAULT_IF" ${ARGN})
+
+ set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}")
+
+ if ("x${arg_CLASS_NAME}" STREQUAL x)
+ message(AUTHOR_WARNING "add_qt_plugin called without setting CLASS_NAME.")
+ endif()
+
+ qt_internal_check_directory_or_type(OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" "${arg_TYPE}"
+ "${output_directory_default}" output_directory)
+ qt_internal_check_directory_or_type(INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" "${arg_TYPE}"
+ "${INSTALL_PLUGINSDIR}/${arg_TYPE}" install_directory)
+ qt_internal_check_directory_or_type(ARCHIVE_INSTALL_DIRECTORY
+ "${arg_ARCHIVE_INSTALL_DIRECTORY}" "${arg_TYPE}"
+ "${INSTALL_LIBDIR}/${arg_TYPE}" archive_install_directory)
+
+ 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()
+ qt_internal_add_target_aliases("${target}")
+
+ set_target_properties("${target}" PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${output_directory}"
+ RUNTIME_OUTPUT_DIRECTORY "${output_directory}"
+ ARCHIVE_OUTPUT_DIRECTORY "${output_directory}"
+ QT_PLUGIN_CLASS_NAME "${arg_CLASS_NAME}")
+
+ 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
+ qt_get_module_for_plugin("${target}" "${arg_TYPE}")
+ get_target_property(qt_module "${target}" QT_MODULE)
+
+ # 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_MODULE;QT_DEFAULT_PLUGIN")
+
+ extend_target("${target}"
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ # For the syncqt headers
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ ${arg_INCLUDE_DIRECTORIES}
+ PUBLIC_INCLUDE_DIRECTORIES ${arg_PUBLIC_INCLUDE_DIRECTORIES}
+ 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 "")
+ foreach(it ${QT_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}")
+
+ # 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
+ )
+
+ set(export_name "${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}"
+ )
+
+ ### 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}")
+
+ qt_internal_add_linker_version_script(${target})
+endfunction()
+
+
+# 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 add_qt_test or add_qt_tool below.
+function(add_qt_executable name)
+ qt_parse_all_arguments(arg "add_qt_executable" "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ARGN})
+
+ if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
+ set(arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}")
+ endif()
+
+ get_filename_component(arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}")
+
+ if ("x${arg_INSTALL_DIRECTORY}" STREQUAL "x")
+ set(arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}")
+ endif()
+
+ add_executable("${name}" ${arg_EXE_FLAGS})
+
+ qt_autogen_tools_initial_setup(${name})
+
+ set(extra_libraries "")
+ if(NOT arg_BOOTSTRAP AND NOT arg_NO_QT)
+ set(extra_libraries "Qt::Core")
+ endif()
+
+ extend_target("${name}"
+ SOURCES ${arg_SOURCES}
+ INCLUDE_DIRECTORIES
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ ${arg_INCLUDE_DIRECTORIES}
+ DEFINES ${arg_DEFINES}
+ LIBRARIES ${arg_LIBRARIES}
+ PUBLIC_LIBRARIES ${extra_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}"
+ 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}"
+ BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}")
+ endif()
+endfunction()
+
+
+# This function creates a CMake test target with the specified name for use with CTest.
+function(add_qt_test name)
+ qt_parse_all_arguments(arg "add_qt_test" "RUN_SERIAL;EXCEPTIONS" "" "${__default_private_args}" ${ARGN})
+ set(path "${CMAKE_CURRENT_BINARY_DIR}")
+
+ if (${arg_EXCEPTIONS})
+ set(EXCEPTIONS_TEXT "EXCEPTIONS")
+ endif()
+
+ add_qt_executable("${name}"
+ ${EXCEPTIONS_TEXT}
+ NO_INSTALL
+ OUTPUT_DIRECTORY "${path}"
+ SOURCES "${arg_SOURCES}"
+ INCLUDE_DIRECTORIES
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ "${arg_INCLUDE_DIRECTORIES}"
+ DEFINES
+ "${arg_DEFINES}"
+ QT_TESTCASE_BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}"
+ QT_TESTCASE_SOURCEDIR="${CMAKE_CURRENT_SOURCE_DIR}"
+ PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Core ${QT_CMAKE_EXPORT_NAMESPACE}::Test
+ 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}
+ )
+
+ # 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}")
+
+ add_test(NAME "${name}" COMMAND "${name}" -o ${name}.xml,xml -o -,txt WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+
+ set_tests_properties("${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}" LABELS "${label}")
+ set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "PATH=${path}${QT_PATH_SEPARATOR}${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}$ENV{PATH}")
+ set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}")
+endfunction()
+
+
+# This function creates an executable for use as helper program with tests. Some
+# tests launch separate programs to test certainly input/output behavior.
+function(add_qt_test_helper name)
+ add_qt_executable("${name}" NO_INSTALL OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." ${ARGN})
+endfunction()
+
+# Sets QT_WILL_BUILD_TOOLS if tools will be built.
+function(qt_check_if_tools_will_be_built)
+ set01(will_build_tools NOT CMAKE_CROSSCOMPILING AND NOT QT_FORCE_FIND_TOOLS)
+ set(QT_WILL_BUILD_TOOLS ${will_build_tools} CACHE INTERNAL "Are tools going to be built" FORCE)
+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(add_qt_tool name)
+ qt_parse_all_arguments(arg "add_qt_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()
+
+ add_qt_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}")
+
+ set_target_properties("${name}" PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE "${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()
+
+
+
+function(add_qt_resource target resourceName)
+ qt_parse_all_arguments(rcc "add_qt_resource" "" "PREFIX;LANG;BASE" "FILES" ${ARGN})
+
+ # 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")
+
+ foreach(file ${rcc_FILES})
+ if(rcc_BASE)
+ set(based_file "${rcc_BASE}/${file}")
+ else()
+ set(based_file "${file}")
+ endif()
+ get_property(alias SOURCE ${based_file} PROPERTY alias)
+ if (NOT alias)
+ set(alias "${file}")
+ endif()
+ ### FIXME: escape file paths to be XML conform
+ # <file ...>...</file>
+ string(APPEND qrcContents " <file alias=\"${alias}\">")
+ string(APPEND qrcContents "${CMAKE_CURRENT_SOURCE_DIR}/${based_file}</file>\n")
+ endforeach()
+
+ # </qresource></RCC>
+ string(APPEND qrcContents " </qresource>\n</RCC>\n")
+
+ set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/generated_${resourceName}.qrc")
+ file(GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}")
+
+ # Process .qrc file:
+
+ set(generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/qrc_${resourceName}.cpp")
+ add_custom_command(OUTPUT "${generatedSourceCode}"
+ COMMAND "${QT_CMAKE_EXPORT_NAMESPACE}::rcc"
+ ARGS --name "${resourceName}"
+ --output "${generatedSourceCode}" "${generatedResourceFile}"
+ DEPENDS ${files}
+ COMMENT "RCC ${resourceName}"
+ VERBATIM)
+ target_sources(${target} PRIVATE "${generatedSourceCode}")
+endfunction()
+
+
+# Handle files that need special SIMD-related flags.
+# This creates an object library and makes target link
+# to it (privately).
+function(add_qt_simd_part target)
+ qt_parse_all_arguments(arg "add_qt_simd_part" "" ""
+ "NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN})
+ if ("x${arg_SIMD}" STREQUAL x)
+ message(FATAL_ERROR "add_qt_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("add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated")
+ endif()
+ string(TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags)
+
+ add_library("${name}" OBJECT)
+ 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}")
+
+ if(NOT BUILD_SHARED_LIBS)
+ qt_install(
+ TARGETS ${name}
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets"
+ )
+ endif()
+ else()
+ if(QT_CMAKE_DEBUG_EXTEND_TARGET)
+ message("add_qt_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 "${CMAKE_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(add_qt_docs qdocFile)
+ # TODO
+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})
+
+ # 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))
+ # 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)
+ # Call original function without our custom arguments.
+ find_package(${arg_UNPARSED_ARGUMENTS})
+ endif()
+
+ if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
+ # 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(FWApplicationServices ApplicationServices)
+ find_library(FWCarbon Carbon)
+ find_library(FWCoreFoundation CoreFoundation)
+ find_library(FWCoreServices CoreServices)
+ find_library(FWCoreVideo CoreVideo)
+ find_library(FWcups cups)
+ find_library(FWDiskArbitration DiskArbitration)
+ find_library(FWFoundation Foundation)
+ 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)
+ 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 input_file_list consuming_target 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("imports")
+ 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}")
+
+ configure_file(global/qconfig.cpp.in global/qconfig.cpp @ONLY)
+endfunction()
diff --git a/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake b/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake
new file mode 100644
index 0000000000..4677c9dcae
--- /dev/null
+++ b/cmake/QtBuildInternals/QtBuildInternalsAndroid.cmake
@@ -0,0 +1,206 @@
+#
+# 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(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_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))
+ # 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}-android-dependencies.xml")
+
+ file(WRITE ${dependency_file} "<rules><dependencies>\n")
+ file(APPEND ${dependency_file} "<lib name=\"${target_name}\"><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)
+ file(APPEND ${dependency_file} "<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)
+ file(APPEND ${dependency_file} "<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)
+ 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)
+ file(APPEND ${dependency_file} "<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)
+ 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)
+ file(APPEND ${dependency_file} "<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)
+ file(APPEND ${dependency_file} "<bundled file=\"${file_native}\" />\n")
+ endforeach()
+ endif()
+
+ # Module plugins
+ if(module_plugins)
+ foreach(plugin IN LISTS module_plugins)
+ file(APPEND ${dependency_file} "<bundled file=\"plugins/${plugin}\" />\n")
+ endforeach()
+ endif()
+
+ # Android Permissions
+ if(arg_PERMISSIONS)
+ foreach(permission IN LISTS arg_PERMISSIONS)
+ file(APPEND ${dependency_file} "<permission name=\"${permission}\" />\n")
+ endforeach()
+ endif()
+
+ file(APPEND ${dependency_file} "</depends></lib>")
+ file(APPEND ${dependency_file} "</dependencies></rules>\n")
+
+ 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..590885c44d
--- /dev/null
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -0,0 +1,148 @@
+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 modules.
+ set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}")
+ list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH})
+
+ # If the repo has its own cmake modules, include those in the module path.
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ endif()
+endmacro()
+
+macro(qt_build_repo_begin)
+ if(${ARGC} EQUAL 1 AND "${ARGV0}" STREQUAL "SKIP_CMAKE_MODULE_PATH_ADDITION")
+ # No-op.
+ else()
+ qt_set_up_build_internals_paths()
+ endif()
+
+ # Qt specific setup common for all modules:
+ include(QtSetup)
+ include(FeatureSummary)
+
+ # Optionally include a repo specific Setup module.
+ include(${PROJECT_NAME}Setup OPTIONAL)
+
+ # Find Apple frameworks if needed.
+ qt_find_apple_system_frameworks()
+endmacro()
+
+macro(qt_build_repo_end)
+ # 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()
+
+ # Print a feature summary:
+ 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)
+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)
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
+ endif()
+
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
+ add_subdirectory(src)
+ endif()
+
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/CMakeLists.txt")
+ ## Decide whether tools will be built.
+ qt_check_if_tools_will_be_built()
+ add_subdirectory(tools)
+ endif()
+
+ if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
+ add_subdirectory(tests)
+ endif()
+
+ qt_build_repo_end()
+
+ if (BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt")
+ add_subdirectory(examples)
+ endif()
+endmacro()
+
+macro(qt_set_up_standalone_tests_build)
+ qt_set_up_build_internals_paths()
+ include(QtSetup)
+ qt_find_apple_system_frameworks()
+endmacro()
+
+macro(qt_build_tests)
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/auto/CMakeLists.txt")
+ add_subdirectory(auto)
+ endif()
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt")
+ add_subdirectory(benchmarks)
+ endif()
+endmacro()
+
+macro(qt_examples_build_begin)
+ # It is part of a Qt build => Use the CMake config files from the binary dir
+ list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
+ # Also make sure the CMake config files do not recreate the already-existing targets
+ set(QT_NO_CREATE_TARGETS TRUE)
+ 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" "uic" "rcc")
+ endforeach()
+
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
+endmacro()
+
+if (ANDROID)
+ include(QtBuildInternals/QtBuildInternalsAndroid)
+endif()
diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in
new file mode 100644
index 0000000000..028cfe2717
--- /dev/null
+++ b/cmake/QtBuildInternalsExtra.cmake.in
@@ -0,0 +1,17 @@
+# 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(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
+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()
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..5ca28c4de4
--- /dev/null
+++ b/cmake/QtCompilerOptimization.cmake
@@ -0,0 +1,121 @@
+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")
+ set(QT_CFLAGS_NEON "-mfpu=neon")
+ 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..1212c191b9
--- /dev/null
+++ b/cmake/QtConfig.cmake.in
@@ -0,0 +1,49 @@
+@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)
+
+if (NOT QT_NO_CREATE_TARGETS)
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
+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@)
+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()
+
+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} 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..8d7006a4de
--- /dev/null
+++ b/cmake/QtFeature.cmake
@@ -0,0 +1,542 @@
+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_define_definitions "" PARENT_SCOPE)
+endfunction()
+
+function(qt_feature feature)
+ 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}}")
+ if ((cache STREQUAL "ON") OR (cache STREQUAL "OFF"))
+ 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_definition feature name)
+ 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()
+
+ 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_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")
+ 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()
+ 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)
+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()
+ endif()
+endfunction()
+
+function(qt_config_compile_test name)
+ cmake_parse_arguments(arg "" "LABEL" "LIBRARIES;CODE" ${ARGN})
+
+ 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_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}")
+ endif()
+ set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}")
+endfunction()
+
+function(qt_config_compile_test_x86simd extension label)
+ if (DEFINED TEST_X86SIMD_${extension})
+ return()
+ endif()
+
+ 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 "-DSIMD:string=${extension}")
+ 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..ad8ded29cf
--- /dev/null
+++ b/cmake/QtInternalTargets.cmake
@@ -0,0 +1,98 @@
+
+function(qt_internal_set_warnings_are_errors_flags target)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Regular clang 3.0+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.0.0")
+ target_compile_options("${target}" INTERFACE -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")
+ target_compile_options("${target}" INTERFACE -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations)
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ # using GCC
+ target_compile_options("${target}" INTERFACE -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
+ target_compile_options("${target}" INTERFACE -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")
+ target_compile_options("${target}" INTERFACE -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.
+ target_compile_options("${target}" INTERFACE -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)
+ target_compile_options("${target}" INTERFACE -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)
+ target_compile_options("${target}" INTERFACE -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)
+ target_compile_options("${target}" INTERFACE /WX)
+ endif()
+ endif()
+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()
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
new file mode 100644
index 0000000000..4bbd485fc4
--- /dev/null
+++ b/cmake/QtModuleConfig.cmake.in
@@ -0,0 +1,35 @@
+@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")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
+endif()
+
+foreach(extra_cmake_include @extra_cmake_includes@)
+ include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
+endforeach()
+
+include(${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/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@")
diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in
new file mode 100644
index 0000000000..81d6431c67
--- /dev/null
+++ b/cmake/QtModuleDependencies.cmake.in
@@ -0,0 +1,76 @@
+# Save old module path, and append a new path that points to the copied over Find modules
+# so that find_dependency() can find the third party packages.
+set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/extra-cmake-modules/find-modules")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/kwin")
+
+# 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()
+
+# Restore old module path.
+set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
+
+# 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}/.." 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..6d7ff9c8fa
--- /dev/null
+++ b/cmake/QtModuleToolsConfig.cmake.in
@@ -0,0 +1,14 @@
+@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")
+endif()
+
+@extra_cmake_statements@
diff --git a/cmake/QtModuleToolsDependencies.cmake.in b/cmake/QtModuleToolsDependencies.cmake.in
new file mode 100644
index 0000000000..bac8bb0e04
--- /dev/null
+++ b/cmake/QtModuleToolsDependencies.cmake.in
@@ -0,0 +1,16 @@
+# Find "ModuleTools" dependencies, which are other ModuleTools packages.
+set(_tool_deps "@tool_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@Tools_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake
new file mode 100644
index 0000000000..bc7e0aa862
--- /dev/null
+++ b/cmake/QtPlatformAndroid.cmake
@@ -0,0 +1,288 @@
+#
+# 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
+# QT_ANDROID_NDK_STDLIB_PATH
+# Detected path to the c++ stl lib shared library
+#
+# 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()
+
+# 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()
+
+
+# Location of stdlibc++
+set(QT_ANDROID_NDK_STDLIB_PATH "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libc++_shared.so")
+
+# 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")
+
+ file(WRITE ${deploy_file} "{\n")
+ # content begin
+ file(APPEND ${deploy_file}
+ " \"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.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)
+ file(APPEND ${deploy_file}
+ " \"qt\": \"${qt_android_install_dir_native}\",\n")
+
+ # Android SDK path
+ file(TO_NATIVE_PATH "${ANDROID_SDK_ROOT}" android_sdk_root_native)
+ file(APPEND ${deploy_file}
+ " \"sdk\": \"${android_sdk_root_native}\",\n")
+
+ # Android SDK Build Tools Revision
+ file(APPEND ${deploy_file}
+ " \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_VERSION}\",\n")
+
+ # Android NDK
+ file(TO_NATIVE_PATH "${ANDROID_NDK}" android_ndk_root_native)
+ file(APPEND ${deploy_file}
+ " \"ndk\": \"${android_ndk_root_native}\",\n")
+
+ # Setup LLVM toolchain
+ file(APPEND ${deploy_file}
+ " \"toolchain-prefix\": \"llvm\",\n")
+ file(APPEND ${deploy_file}
+ " \"tool-prefix\": \"llvm\",\n")
+ file(APPEND ${deploy_file}
+ " \"useLLVM\": true,\n")
+
+ # NDK Toolchain Version
+ file(APPEND ${deploy_file}
+ " \"toolchain-version\": \"${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\",\n")
+
+ # NDK Host
+ file(APPEND ${deploy_file}
+ " \"ndk-host\": \"${ANDROID_NDK_HOST_SYSTEM_NAME}\",\n")
+
+ # Architecture
+ file(APPEND ${deploy_file}
+ " \"target-architecture\": \"${CMAKE_ANDROID_ARCH_ABI}\",\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)
+ file(APPEND ${deploy_file}
+ " \"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)
+ file(APPEND ${deploy_file}
+ " \"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)
+ file(APPEND ${deploy_file}
+ " \"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)
+ file(APPEND ${deploy_file}
+ " \"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?
+
+ #TODO: QML import path, could be a property? Example below:
+ #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)
+ # file(APPEND ${deploy_file}
+ # " \"qml-import-path\": \"${qml_import_path_native}\",\n")
+ #endif()
+
+ #TODO: QML root path, could be a property? Example below:
+ #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)
+ #file(APPEND ${deploy_file}
+ # " \"qml-root-path\": \"${qml_root_path_native}\",\n")
+
+ # App binary
+ file(TO_NATIVE_PATH "${target_binary_dir}/lib${target_output_name}.so" target_binary_dir_native)
+ file(APPEND ${deploy_file}
+ " \"application-binary\": \"${target_binary_dir_native}\",\n")
+
+ # Lats item in json file
+
+ file(APPEND ${deploy_file}
+ " \"stdcpp-path\": \"${QT_ANDROID_NDK_STDLIB_PATH}\"\n")
+
+ # content end
+ file(APPEND ${deploy_file} "}\n")
+
+ set_target_properties(${target}
+ PROPERTIES
+ QT_ANDROID_DEPLOYMENT_SETTINGS_FILE ${deploy_file}
+ )
+endfunction()
diff --git a/cmake/QtPlatformSupport.cmake b/cmake/QtPlatformSupport.cmake
new file mode 100644
index 0000000000..ac9973905a
--- /dev/null
+++ b/cmake/QtPlatformSupport.cmake
@@ -0,0 +1,81 @@
+function(set01 result)
+ if (${ARGN})
+ set("${result}" 1 PARENT_SCOPE)
+ else()
+ set("${result}" 0 PARENT_SCOPE)
+ endif()
+endfunction()
+
+set01(LINUX CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set01(HPUX CMAKE_SYSTEM_NAME STREQUAL "HPUX")
+set01(ANDROID CMAKE_SYSTEM_NAME STREQUAL "Android") # FIXME: How to identify this?
+set01(NACL CMAKE_SYSTEM_NAME STREQUAL "NaCl") # FIXME: How to identify this?
+set01(INTEGRITY CMAKE_SYSTEM_NAME STREQUAL "Integrity") # FIXME: How to identify this?
+set01(VXWORKS CMAKE_SYSTEM_NAME STREQUAL "VxWorks") # FIXME: How to identify this?
+set01(QNX CMAKE_SYSTEM_NAME STREQUAL "QNX") # FIXME: How to identify this?
+set01(OPENBSD CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # FIXME: How to identify this?
+set01(FREEBSD CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FIXME: How to identify this?
+set01(NETBSD CMAKE_SYSTEM_NAME STREQUAL "NetBSD") # FIXME: How to identify this?
+set01(WASM CMAKE_SYSTEM_NAME STREQUAL "Webassembly") # FIXME: How to identify this?
+
+set01(BSD APPLE OR OPENBSD OR FREEBSD OR NETBSD)
+
+set01(WINRT WIN32 AND CMAKE_VS_PLATFORM_TOOSLET STREQUAL "winrt") # FIXME: How to identify this?
+
+set01(APPLE_OSX APPLE) # FIXME: How to identify this? For now assume that always building for macOS.
+set01(APPLE_UIKIT APPLE AND CMAKE_XCODE_PLATFORM_TOOLSET STREQUAL "uikit") # FIXME: How to identify this?
+set01(APPLE_IOS APPLE AND CMAKE_XCODE_PLATFORM_TOOLSET STREQUAL "ios") # FIXME: How to identify this?
+set01(APPLE_TVOS APPLE AND CMAKE_XCODE_PLATFORM_TOOLSET STREQUAL "tvos") # FIXME: How to identify this?
+set01(APPLE_WATCHOS APPLE AND CMAKE_XCODE_PLATFORM_TOOLSET STREQUAL "watchos") # FIXME: How to identify this?
+
+set01(GCC CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+set01(CLANG CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+set01(ICC CMAKE_C_COMPILER MATCHES "icc|icl")
+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..43b5b4d617
--- /dev/null
+++ b/cmake/QtPluginConfig.cmake.in
@@ -0,0 +1,15 @@
+@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}/@target@Targets.cmake")
+endif()
diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in
new file mode 100644
index 0000000000..6ca392ec64
--- /dev/null
+++ b/cmake/QtPluginDependencies.cmake.in
@@ -0,0 +1,54 @@
+# Save old module path, and append a new path that points to the copied over Find modules
+# so that find_dependency() can find the third party packages.
+set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/extra-cmake-modules/find-modules")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/kwin")
+
+# 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 (NOT ${pkg}_FOUND)
+ if(components)
+ string(REPLACE " " ";" components "${components}")
+ find_dependency(${find_package_args} COMPONENTS ${components})
+ else()
+ find_dependency(${find_package_args})
+ endif()
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
+# Restore old module path.
+set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
+
+# 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}/.." 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..e6547508a7
--- /dev/null
+++ b/cmake/QtPlugins.cmake.in
@@ -0,0 +1,40 @@
+@QT_MODULE_PLUGIN_INCLUDES@
+
+if(NOT @BUILD_SHARED_LIBS@)
+ set(_module_target "@INSTALL_CMAKE_NAMESPACE@::@QT_MODULE@")
+
+ set(_default_plugins_are_enabled "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>")
+ set(_manual_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>")
+ set(_no_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>")
+
+ foreach(target @qt_plugins@)
+ set(_plugin_target "@INSTALL_CMAKE_NAMESPACE@::${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()
+
+ set(_plugin_is_default "$<TARGET_PROPERTY:${_plugin_target},QT_DEFAULT_PLUGIN>")
+ set(_plugin_is_not_blacklisted "$<NOT:$<IN_LIST:${_plugin_target},${_no_plugins_genex}>>")
+ set(_plugin_is_whitelisted "$<IN_LIST:${_plugin_target},${_manual_plugins_genex}>")
+
+ string(CONCAT _plugin_condition
+ "$<BOOL:$<OR:"
+ "${_plugin_is_whitelisted},"
+ "$<AND:"
+ "${_default_plugins_are_enabled},"
+ "${_plugin_is_default},"
+ "${_plugin_is_not_blacklisted}"
+ ">"
+ ">>"
+ )
+ set(_plugin_genex "$<${_plugin_condition}:${_plugin_target}>")
+ target_link_libraries(${_module_target} INTERFACE "${_plugin_genex}")
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/qt_@QT_MODULE@_${target}.cpp"
+ CONTENT "#include <QtPlugin>\nQ_IMPORT_PLUGIN(${_classname})"
+ )
+ target_sources(${_module_target} INTERFACE "$<${_plugin_condition}:${CMAKE_CURRENT_BINARY_DIR}/qt_@QT_MODULE@_${target}.cpp>")
+ endforeach()
+endif()
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
new file mode 100644
index 0000000000..f56eb801ea
--- /dev/null
+++ b/cmake/QtPostProcess.cmake
@@ -0,0 +1,293 @@
+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)
+ # 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(NOT QT_BUILD_SHARED_LIBS)
+ set(depends_var "depends")
+ endif()
+
+ 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(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 "")
+
+ get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
+ if(NOT extra_depends STREQUAL "${extra_depends}-NOTFOUND")
+ list(APPEND target_deps ${extra_depends})
+ endif()
+
+ set(qtdeps "")
+ set(third_party_deps "")
+ set(third_party_deps_seen "")
+ set(tool_deps "")
+ set(tool_deps_seen "")
+ set(main_module_tool_deps "")
+
+ foreach (dep ${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 QT_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()
+
+ # 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}" 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)
+ set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}Tools")
+ 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 ModuleToolDependencies file.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtModuleToolsDependencies.cmake.in"
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ToolsDependencies.cmake"
+ @ONLY
+ )
+
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ToolsDependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+
+ 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()
+
+ # 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)
+ message("Generating depends files for ${QT_KNOWN_MODULES}...")
+ foreach (target ${QT_KNOWN_MODULES})
+ qt_internal_create_module_depends_file(${target})
+ endforeach()
+
+ message("Generating depends 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)
+ message("Generating Plugins files for ${QT_KNOWN_MODULES}...")
+ foreach (QT_MODULE ${QT_KNOWN_MODULES})
+ 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")
+ qt_path_join(extra_file_path
+ ${QT_CONFIG_BUILD_DIR}
+ ${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
+ 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)
+ foreach (target ${QT_KNOWN_MODULES})
+ qt_android_dependencies(${target})
+ endforeach()
+endfunction()
+
+qt_internal_create_depends_files()
+qt_generate_build_internals_extra_cmake_code()
+qt_internal_create_plugins_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..0c3507b953
--- /dev/null
+++ b/cmake/QtProperties.cmake
@@ -0,0 +1,61 @@
+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_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
+ ""
+)
+
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
new file mode 100644
index 0000000000..fcc26c844a
--- /dev/null
+++ b/cmake/QtSetup.cmake
@@ -0,0 +1,113 @@
+## 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()
+
+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 of build type for cmake-gui
+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()
+
+## Force C++ standard, do not fall back, do not use compiler extensions
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+## 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.
+if((CMAKE_INSTALL_PREFIX STREQUAL CMAKE_BINARY_DIR) OR (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build))
+ set(QT_WILL_INSTALL OFF)
+ # Handle non-prefix builds by setting the cmake install prefix to the project binary dir.
+ if(PROJECT_NAME STREQUAL "QtBase")
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH
+ "Install path prefix, prepended onto install directories." FORCE)
+ else()
+ # No-op. While building another module, the CMAKE_INSTALL_PREFIX or CMAKE_PREFIX_PATH
+ # (either work) should be set on the command line to point to the qtbase build dir.
+ endif()
+else()
+ set(QT_WILL_INSTALL ON)
+ set(QT_BUILD_TESTING OFF)
+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)
+endif()
+
+## Set up testing
+option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING})
+include(CTest)
+enable_testing()
+
+## Define some constants to check for certain platforms, etc:
+include(QtPlatformSupport)
+
+## Android platform settings
+if(ANDROID)
+ include(QtPlatformAndroid)
+endif()
+
+## add_qt_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()
+
+## 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/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..4a72dee1a0
--- /dev/null
+++ b/cmake/README.md
@@ -0,0 +1,194 @@
+# 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 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. 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 setting ``BUILD_EXAMPLES=OFF`` and ``BUILD_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 on 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 on 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}``
+
+# 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/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/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)