qt 6.5.1 original

This commit is contained in:
kleuter
2023-10-29 23:33:08 +01:00
parent 71d22ab6b0
commit 85d238dfda
21202 changed files with 5499099 additions and 0 deletions

View File

@ -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.

View File

@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/../modules/ECMFindModuleHelpers.cmake)

View File

@ -0,0 +1,177 @@
#.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 QUIET)
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}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}")
if(_qt_igy_gui_libs)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}")
endif()
check_cxx_source_compiles("
#include <EGL/egl.h>
int main(int, char **) {
EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
eglDestroyContext(dpy, ctx);
}" HAVE_EGL)
cmake_pop_check_state()
set(required_vars EGL_INCLUDE_DIR HAVE_EGL)
if(NOT EMSCRIPTEN)
list(APPEND required_vars EGL_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL
FOUND_VAR
EGL_FOUND
REQUIRED_VARS
${required_vars}
VERSION_VAR
EGL_VERSION
)
if(EGL_FOUND AND NOT TARGET EGL::EGL)
if (EMSCRIPTEN)
add_library(EGL::EGL INTERFACE IMPORTED)
# Nothing further to be done, system include paths have headers and linkage is implicit.
else()
add_library(EGL::EGL UNKNOWN IMPORTED)
set_target_properties(EGL::EGL PROPERTIES
IMPORTED_LOCATION "${EGL_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${EGL_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}"
)
endif()
endif()
mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR HAVE_EGL)
# compatibility variables
set(EGL_LIBRARIES ${EGL_LIBRARY})
set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
set(EGL_VERSION_STRING ${EGL_VERSION})
include(FeatureSummary)
set_package_properties(EGL PROPERTIES
URL "https://www.khronos.org/egl/"
DESCRIPTION "A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG."
)

View File

@ -0,0 +1,167 @@
#.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 QUIET)
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}
)
pkg_check_modules(PC_GTHREAD2 QUIET gthread-2.0)
find_library(GTHREAD2_LIBRARIES
NAMES gthread-2.0
HINTS ${PC_GTHREAD2_LIBDIR}
)
pkg_check_modules(PC_GOBJECT QUIET gobject-2.0)
find_path(GLIB2_GOBJECT_INCLUDE_DIRS
NAMES glib-object.h
HINTS ${PC_GOBJECT_INCLUDEDIR}
PATH_SUFFIXES glib-2.0)
find_library(GLIB2_GOBJECT_LIBRARIES
NAMES gobject-2.0
HINTS ${PC_GOBJECT_LIBDIR}
)
pkg_check_modules(PC_GIO QUIET gio-2.0)
find_path(GLIB2_GIO_INCLUDE_DIRS
NAMES gio/gio.h
HINTS ${PC_GIO_INCLUDEDIR}
PATH_SUFFIXES glib-2.0)
find_library(GLIB2_GIO_LIBRARIES
NAMES gio-2.0
HINTS ${PC_GIO_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}")
list(APPEND GLIB2_GOBJECT_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}")
list(APPEND GLIB2_GIO_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}")
endif()
# Deprecated synonyms
set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}")
set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}")
set(GLIB2_GOBJECT_INCLUDE_DIR "${GLIB2_GOBJECT_INCLUDE_DIRS}")
set(GLIB2_GOBJECT_LIBRARY "${GLIB2_GOBJECT_LIBRARIES}")
set(GLIB2_GIO_INCLUDE_DIR "${GLIB2_GIO_INCLUDE_DIRS}")
set(GLIB2_GIO_LIBRARY "${GLIB2_GIO_LIBRARIES}")
if(GLIB2_GOBJECT_LIBRARIES AND GLIB2_GOBJECT_INCLUDE_DIRS)
set(GLIB2_GOBJECT_FOUND TRUE)
endif()
if(GLIB2_GIO_LIBRARIES AND GLIB2_GIO_INCLUDE_DIRS)
set(GLIB2_GIO_FOUND TRUE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLIB2
REQUIRED_VARS GLIB2_LIBRARIES GTHREAD2_LIBRARIES GLIB2_INCLUDE_DIRS
HANDLE_COMPONENTS)
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_LINK_LIBRARIES "${GTHREAD2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}")
endif()
if(GLIB2_GOBJECT_FOUND AND NOT TARGET GLIB2::GOBJECT)
add_library(GLIB2::GOBJECT UNKNOWN IMPORTED)
set_target_properties(GLIB2::GOBJECT PROPERTIES
IMPORTED_LOCATION "${GLIB2_GOBJECT_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_GOBJECT_INCLUDE_DIRS}")
endif()
if(GLIB2_GIO_FOUND AND NOT TARGET GLIB2::GIO)
add_library(GLIB2::GIO UNKNOWN IMPORTED)
set_target_properties(GLIB2::GIO PROPERTIES
IMPORTED_LOCATION "${GLIB2_GIO_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_GIO_INCLUDE_DIRS}")
endif()
mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR
GLIB2_LIBRARIES GLIB2_LIBRARY
GLIB2_GOBJECT_INCLUDE_DIRS GLIB2_GOBJECT_INCLUDE_DIR
GLIB2_GOBJECT_LIBRARIES GLIB2_GOBJECT_LIBRARY
GLIB2_GIO_INCLUDE_DIRS GLIB2_GIO_INCLUDE_DIR
GLIB2_GIO_LIBRARIES GLIB2_GIO_LIBRARY)
include(FeatureSummary)
set_package_properties(GLIB2 PROPERTIES
URL "https://wiki.gnome.org/Projects/GLib"
DESCRIPTION "Event loop and utility library")

View File

@ -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"
)

View File

@ -0,0 +1,170 @@
#.rst:
# FindWaylandScanner
# ------------------
#
# Try to find wayland-scanner.
#
# If the wayland-scanner executable is not in your PATH, you can provide
# an alternative name or full path location with the ``WaylandScanner_EXECUTABLE``
# variable.
#
# This will define the following variables:
#
# ``WaylandScanner_FOUND``
# True if wayland-scanner is available.
#
# ``WaylandScanner_EXECUTABLE``
# The wayland-scanner executable.
#
# If ``WaylandScanner_FOUND`` is TRUE, it will also define the following imported
# target:
#
# ``Wayland::Scanner``
# The wayland-scanner executable.
#
# This module provides the following functions to generate C protocol
# implementations:
#
# - ``ecm_add_wayland_client_protocol``
# - ``ecm_add_wayland_server_protocol``
#
# ::
#
# ecm_add_wayland_client_protocol(<source_files_var>
# PROTOCOL <xmlfile>
# BASENAME <basename>)
#
# Generate Wayland client protocol files from ``<xmlfile>`` XML
# definition for the ``<basename>`` interface and append those files
# to ``<source_files_var>``.
#
# ::
#
# ecm_add_wayland_server_protocol(<source_files_var>
# PROTOCOL <xmlfile>
# BASENAME <basename>)
#
# Generate Wayland server protocol files from ``<xmlfile>`` XML
# definition for the ``<basename>`` interface and append those files
# to ``<source_files_var>``.
#
# Since 1.4.0.
#=============================================================================
# Copyright 2012-2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
ecm_find_package_version_check(WaylandScanner)
# Find wayland-scanner
find_program(WaylandScanner_EXECUTABLE NAMES wayland-scanner)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WaylandScanner
FOUND_VAR
WaylandScanner_FOUND
REQUIRED_VARS
WaylandScanner_EXECUTABLE
)
mark_as_advanced(WaylandScanner_EXECUTABLE)
if(NOT TARGET Wayland::Scanner AND WaylandScanner_FOUND)
add_executable(Wayland::Scanner IMPORTED)
set_target_properties(Wayland::Scanner PROPERTIES
IMPORTED_LOCATION "${WaylandScanner_EXECUTABLE}"
)
endif()
include(FeatureSummary)
set_package_properties(WaylandScanner PROPERTIES
URL "https://wayland.freedesktop.org/"
DESCRIPTION "Executable that converts XML protocol files to C code"
)
function(ecm_add_wayland_client_protocol out_var)
# Parse arguments
set(oneValueArgs PROTOCOL BASENAME)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN})
if(ARGS_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_client_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"")
endif()
get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE)
set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-client-protocol.h")
set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-protocol.c")
set_source_files_properties(${_client_header} GENERATED)
set_source_files_properties(${_code} GENERATED)
set_property(SOURCE ${_client_header} PROPERTY SKIP_AUTOMOC ON)
add_custom_command(OUTPUT "${_client_header}"
COMMAND ${WaylandScanner_EXECUTABLE} client-header ${_infile} ${_client_header}
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile}
VERBATIM
)
add_custom_command(OUTPUT "${_code}"
COMMAND ${WaylandScanner_EXECUTABLE} code ${_infile} ${_code}
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile} ${_client_header}
VERBATIM
)
list(APPEND ${out_var} "${_client_header}" "${_code}")
set(${out_var} ${${out_var}} PARENT_SCOPE)
endfunction()
function(ecm_add_wayland_server_protocol out_var)
# Parse arguments
set(oneValueArgs PROTOCOL BASENAME)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN})
if(ARGS_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"")
endif()
ecm_add_wayland_client_protocol(${out_var}
PROTOCOL ${ARGS_PROTOCOL}
BASENAME ${ARGS_BASENAME})
get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE)
set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${ARGS_BASENAME}-server-protocol.h")
set_property(SOURCE ${_server_header} PROPERTY SKIP_AUTOMOC ON)
set_source_files_properties(${_server_header} GENERATED)
add_custom_command(OUTPUT "${_server_header}"
COMMAND ${WaylandScanner_EXECUTABLE} server-header ${_infile} ${_server_header}
DEPENDS ${WaylandScanner_EXECUTABLE} ${_infile}
VERBATIM
)
list(APPEND ${out_var} "${_server_header}")
set(${out_var} ${${out_var}} PARENT_SCOPE)
endfunction()

View File

@ -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 QUIET)
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"
)

View File

@ -0,0 +1,192 @@
#.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
)
# 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}
)
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 "https://xcb.freedesktop.org/"
DESCRIPTION "X protocol C-language Binding"
)

View File

@ -0,0 +1,172 @@
# SPDX-FileCopyrightText: 2014 Mathieu Tarral <mathieu.tarral@gmail.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#[=======================================================================[.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
- fuzzer-no-link
- fuzzer
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.
#]=======================================================================]
# MACRO check_compiler_version
#-----------------------------
macro (check_compiler_version gcc_required_version clang_required_version msvc_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}
)
OR
(
CMAKE_CXX_COMPILER_ID MATCHES "MSVC"
AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${msvc_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}, Clang ${clang_required_version}
or MSVC ${msvc_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" "19.28")
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(XSAN_COMPILE_FLAGS "-fsanitize=address")
else()
set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(XSAN_LINKER_FLAGS "asan")
endif()
elseif (${sanitize_option} MATCHES "thread")
check_compiler_version("4.8" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=thread")
set(XSAN_LINKER_FLAGS "tsan")
elseif (${sanitize_option} MATCHES "memory")
check_compiler_version("99.99" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=memory")
elseif (${sanitize_option} MATCHES "leak")
check_compiler_version("4.9" "3.4" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=leak")
set(XSAN_LINKER_FLAGS "lsan")
elseif (${sanitize_option} MATCHES "undefined")
check_compiler_version("4.9" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-omit-frame-pointer -fno-optimize-sibling-calls")
elseif (${sanitize_option} MATCHES "fuzzer-no-link")
check_compiler_version("99.99" "6.0" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer-no-link")
set(XSAN_LINKER_FLAGS "-fsanitize=fuzzer-no-link")
elseif (${sanitize_option} MATCHES "fuzzer")
check_compiler_version("99.99" "6.0" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer")
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" OR CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# 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 MATCHES "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()

View File

@ -0,0 +1,300 @@
#.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 components 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.
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 QUIET)
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()
set(_name_mismatched_arg)
if(NOT CMAKE_VERSION VERSION_LESS 3.17)
set(_name_mismatched_arg NAME_MISMATCHED)
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
${_name_mismatched_arg}
)
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()

View File

@ -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.84.0",
"License": "BSD-3-Clause",
"LicenseId": "BSD-3-Clause",
"LicenseFile": "COPYING-CMAKE-SCRIPTS",
"Copyright": "Copyright © 2011-2018 The KDE community"
}

View File

@ -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.

134
cmake/3rdparty/kwin/FindLibdrm.cmake vendored Normal file
View File

@ -0,0 +1,134 @@
#.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 QUIET)
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}
PATH_SUFFIXES
libdrm
)
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}"
)
foreach(suffix libdrm drm)
if(EXISTS "${Libdrm_INCLUDE_DIR}/${suffix}")
set_property(TARGET Libdrm::Libdrm APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}/${suffix}"
)
endif()
endforeach()
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" "${Libdrm_INCLUDE_DIR}/drm")
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."
)

125
cmake/3rdparty/kwin/FindLibinput.cmake vendored Normal file
View File

@ -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 QUIET)
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."
)

101
cmake/3rdparty/kwin/FindXKB.cmake vendored Normal file
View File

@ -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 QUIET)
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."
)

125
cmake/3rdparty/kwin/Findgbm.cmake vendored Normal file
View File

@ -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 QUIET)
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."
)

17
cmake/3rdparty/kwin/qt_attribution.json vendored Normal file
View File

@ -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",
"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>"
}

10
cmake/FindATSPI2.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(ATSPI2 IMPORTED_TARGET "atspi-2")
if (NOT TARGET PkgConfig::ATSPI2)
set(ATSPI2_FOUND 0)
endif()

65
cmake/FindDB2.cmake Normal file
View File

@ -0,0 +1,65 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# FindDB2
# ---------
#
# Try to locate the db2 client library.
# If found, this will define the following variables:
#
# ``DB2_FOUND``
# True if the db2 library is available
# ``DB2_INCLUDE_DIRS``
# The db2 include directories
# ``DB2_LIBRARIES``
# The db2 libraries for linking
#
# If ``DB2_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``DB2::DB2``
# The db2 client library
if (NOT DEFINED DB2_INCLUDE_DIR)
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ENV DB2_HOME
PATH_SUFFIXES include)
else()
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ${DB2_INCLUDE_DIR})
endif()
if (NOT DEFINED DB2_LIBRARY_DIR)
find_library(DB2_LIBRARY
NAMES db2
HINTS ENV DB2LIB)
else()
find_library(DB2_LIBRARY
NAMES db2
HINTS ${DB2_LIBRARY_DIR})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DB2 DEFAULT_MSG DB2_INCLUDE_DIR DB2_LIBRARY)
if(DB2_FOUND)
set(DB2_INCLUDE_DIRS "${DB2_INCLUDE_DIR}")
set(DB2_LIBRARIES "${DB2_LIBRARY}")
if(NOT TARGET DB2::DB2)
add_library(DB2::DB2 UNKNOWN IMPORTED)
set_target_properties(DB2::DB2 PROPERTIES
IMPORTED_LOCATION "${DB2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${DB2_INCLUDE_DIRS}")
endif()
endif()
mark_as_advanced(DB2_INCLUDE_DIR DB2_LIBRARY)
include(FeatureSummary)
set_package_properties(DB2 PROPERTIES
URL "https://www.ibm.com"
DESCRIPTION "IBM DB2 client library")

10
cmake/FindDirectFB.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(DirectFB IMPORTED_TARGET "directfb")
if (NOT TARGET PkgConfig::DirectFB)
set(DirectFB_FOUND 0)
endif()

87
cmake/FindGLESv2.cmake Normal file
View File

@ -0,0 +1,87 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(CheckCXXSourceCompiles)
# No library linkage is necessary to use GLESv2 with Emscripten. The headers are also
# system headers, so we don't need to search for them.
if(EMSCRIPTEN)
set(HAVE_GLESv2 ON)
else()
find_library(GLESv2_LIBRARY NAMES GLESv2 OpenGLES)
find_path(GLESv2_INCLUDE_DIR NAMES "GLES2/gl2.h" "OpenGLES/ES2/gl.h" DOC "The OpenGLES 2 include path")
find_package(EGL)
set(_libraries "${CMAKE_REQUIRED_LIBRARIES}")
if(GLESv2_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${GLESv2_LIBRARY}")
endif ()
if(EGL_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
endif()
if(_qt_igy_gui_libs)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}")
endif()
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, char **) {
glUniform1f(1, GLfloat(1.0));
glClear(GL_COLOR_BUFFER_BIT);
}" HAVE_GLESv2)
set(CMAKE_REQUIRED_LIBRARY "${_libraries}")
unset(_libraries)
set(CMAKE_REQUIRED_INCLUDES "${_includes}")
unset(_includes)
set(package_args GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2)
endif()
# Framework handling partially inspired by FindGLUT.cmake.
if(GLESv2_LIBRARY MATCHES "/([^/]+)\\.framework$")
# TODO: Might need to handle non .tbd suffixes, but didn't find an
# example like that.
# TODO: Might need to handle INTERFACE_INCLUDE_DIRECTORIES differently.
set(_library_imported_location "${GLESv2_LIBRARY}/${CMAKE_MATCH_1}.tbd")
if(NOT EXISTS "${_library_imported_location}")
set(_library_imported_location "")
endif()
else()
set(_library_imported_location "${GLESv2_LIBRARY}")
endif()
set(GLESv2_LIBRARY "${_library_imported_location}")
list(APPEND package_args HAVE_GLESv2)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLESv2 DEFAULT_MSG ${package_args})
mark_as_advanced(${package_args})
if(GLESv2_FOUND AND NOT TARGET GLESv2::GLESv2)
if(EMSCRIPTEN OR IOS)
add_library(GLESv2::GLESv2 INTERFACE IMPORTED)
if(IOS)
# For simulator_and_device builds we can't specify the full library path, because
# it's specific to either the device or the simulator. Resort to passing a link
# flag instead.
target_link_libraries(GLESv2::GLESv2 INTERFACE "-framework OpenGLES")
endif()
else()
add_library(GLESv2::GLESv2 UNKNOWN IMPORTED)
set_target_properties(GLESv2::GLESv2 PROPERTIES
IMPORTED_LOCATION "${GLESv2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}")
if(EGL_LIBRARY)
target_link_libraries(GLESv2::GLESv2 INTERFACE "${EGL_LIBRARY}")
endif()
endif()
endif()

47
cmake/FindGSSAPI.cmake Normal file
View File

@ -0,0 +1,47 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(PC_GSSAPI QUIET "krb5-gssapi")
if (NOT PC_GSSAPI_FOUND)
pkg_check_modules(PC_GSSAPI QUIET "mit-krb5-gssapi")
endif()
find_path(GSSAPI_INCLUDE_DIRS
NAMES gssapi/gssapi.h
HINTS ${PC_GSSAPI_INCLUDEDIR}
)
find_library(GSSAPI_LIBRARIES
NAMES
GSS # framework
gss # solaris
gssapi # FreeBSD
gssapi_krb5
HINTS ${PC_GSSAPI_LIBDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIRS)
if(GSSAPI_FOUND AND NOT TARGET GSSAPI::GSSAPI)
if(GSSAPI_LIBRARIES MATCHES "/([^/]+)\\.framework$")
add_library(GSSAPI::GSSAPI INTERFACE IMPORTED)
set_target_properties(GSSAPI::GSSAPI PROPERTIES
INTERFACE_LINK_LIBRARIES "${GSSAPI_LIBRARIES}")
else()
add_library(GSSAPI::GSSAPI UNKNOWN IMPORTED)
set_target_properties(GSSAPI::GSSAPI PROPERTIES
IMPORTED_LOCATION "${GSSAPI_LIBRARIES}")
endif()
set_target_properties(GSSAPI::GSSAPI PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GSSAPI_INCLUDE_DIRS}")
endif()
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
include(FeatureSummary)
set_package_properties(GSSAPI PROPERTIES
DESCRIPTION "Generic Security Services Application Program Interface")

15
cmake/FindGTK3.cmake Normal file
View File

@ -0,0 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
set(__gtk3_required_version "${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION}")
if(__gtk3_required_version)
set(__gtk3_required_version " >= ${__gtk3_required_version}")
endif()
pkg_check_modules(GTK3 IMPORTED_TARGET "gtk+-3.0${__gtk3_required_version}")
if (NOT TARGET PkgConfig::GTK3)
set(GTK3_FOUND 0)
endif()
unset(__gtk3_required_version)

55
cmake/FindInterbase.cmake Normal file
View File

@ -0,0 +1,55 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# FindInterbase
# ---------
#
# Try to locate the Interbase client library.
# If found, this will define the following variables:
#
# ``Interbase_FOUND``
# True if the Interbase library is available
# ``Interbase_INCLUDE_DIR``
# The Interbase include directories
# ``Interbase_LIBRARY``
# The Interbase libraries for linking
#
# If ``Interbase_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``Interbase::Interbase``
# The Interbase client library
find_path(Interbase_INCLUDE_DIR
NAMES ibase.h
HINTS ${Interbase_INCLUDEDIR}
PATH_SUFFIXES firebird
)
find_library(Interbase_LIBRARY
NAMES firebase_ms fbclient gds
HINTS ${Interbase_LIBDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Interbase DEFAULT_MSG Interbase_LIBRARY Interbase_INCLUDE_DIR)
if(Interbase_FOUND)
set(Interbase_INCLUDE_DIRS "${Interbase_INCLUDE_DIR}")
set(Interbase_LIBRARIES "${Interbase_LIBRARY}")
if(NOT TARGET Interbase::Interbase)
add_library(Interbase::Interbase UNKNOWN IMPORTED)
set_target_properties(Interbase::Interbase PROPERTIES
IMPORTED_LOCATION "${Interbase_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Interbase_INCLUDE_DIRS};")
endif()
endif()
mark_as_advanced(Interbase_INCLUDE_DIR Interbase_LIBRARY)
include(FeatureSummary)
set_package_properties(Interbase PROPERTIES
URL "https://www.embarcadero.com/products/interbase"
DESCRIPTION "Interbase client library")

40
cmake/FindLibb2.cmake Normal file
View File

@ -0,0 +1,40 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Blake2 contains a reference implementation, libb2 is a more efficient
# implementation of a subset of Blake2 functions and should be preferred.
# This Find module only searches for libb2 for that reason.
if(TARGET Libb2::Libb2)
set(Libb2_FOUND TRUE)
return()
endif()
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(Libb2 IMPORTED_TARGET "libb2")
if (TARGET PkgConfig::Libb2)
add_library(Libb2::Libb2 INTERFACE IMPORTED)
target_link_libraries(Libb2::Libb2 INTERFACE PkgConfig::Libb2)
set(Libb2_FOUND TRUE)
endif()
else()
find_path(LIBB2_INCLUDE_DIR NAMES blake2.h)
find_library(LIBB2_LIBRARY NAMES b2)
if(LIBB2_LIBRARY AND LIBB2_INCLUDE_DIR)
add_library(Libb2::Libb2 UNKNOWN IMPORTED)
set_target_properties(Libb2::Libb2 PROPERTIES
IMPORTED_LOCATION ${LIBB2_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${LIBB2_INCLUDE_DIR}
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libb2 REQUIRED_VARS
LIBB2_LIBRARY
LIBB2_INCLUDE_DIR
)
endif()

10
cmake/FindLibproxy.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(Libproxy IMPORTED_TARGET "libproxy-1.0")
if (NOT TARGET PkgConfig::Libproxy)
set(Libproxy_FOUND 0)
endif()

View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(Libsystemd IMPORTED_TARGET "libsystemd")
if (NOT TARGET PkgConfig::Libsystemd)
set(Libsystemd_FOUND 0)
endif()

10
cmake/FindLibudev.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(Libudev IMPORTED_TARGET "libudev")
if (NOT TARGET PkgConfig::Libudev)
set(Libudev_FOUND 0)
endif()

10
cmake/FindMtdev.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(Mtdev IMPORTED_TARGET "mtdev")
if (NOT TARGET PkgConfig::Mtdev)
set(Mtdev_FOUND 0)
endif()

100
cmake/FindMySQL.cmake Normal file
View File

@ -0,0 +1,100 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# FindMySQL
# ---------
#
# Try to locate the mysql client library.
#
# By default, pkg-config is used, if available.
# If pkg-config is not available or if you want to disable it, set the ``MySQL_ROOT`` variable.
# The following variables can be set to control the behavior of this find module.
#
# ``MySQL_ROOT``
# The root directory of the mysql client library's installation.
# ``MySQL_INCLUDE_DIR``
# The directory containing the include files of the mysql client library.
# If not set, the directory is detected within ``MySQL_ROOT`` using find_path.
# ``MySQL_LIBRARY_DIR``
# The directory containing the binaries of the mysql client library.
# This is used to detect ``MySQL_LIBRARY`` and passed as HINT to find_library.
# ``MySQL_LIBRARY``
# The file path to the mysql client library.
# ``MySQL_LIBRARY_DEBUG``
# The file path to the mysql client library for the DEBUG configuration.
#
# If the mysql client library is found, this will define the following variables:
#
# ``MySQL_FOUND``
# True if the mysql library is available
# ``MySQL_INCLUDE_DIRS``
# The mysql include directories
# ``MySQL_LIBRARIES``
# The mysql libraries for linking
#
# If ``MySQL_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``MySQL::MySQL``
# The mysql client library
if(NOT DEFINED MySQL_ROOT)
find_package(PkgConfig QUIET)
endif()
if(PkgConfig_FOUND AND NOT DEFINED MySQL_ROOT)
pkg_check_modules(PC_MySQL QUIET "mysqlclient")
set(MySQL_include_dir_hints ${PC_MySQL_INCLUDEDIR})
set(MySQL_library_hints ${PC_MySQL_LIBDIR})
set(MySQL_library_hints_debug "")
else()
set(MySQL_include_dir_hints "")
if(NOT DEFINED MySQL_LIBRARY_DIR)
set(MySQL_LIBRARY_DIR "${MySQL_ROOT}/lib")
endif()
set(MySQL_library_hints "${MySQL_LIBRARY_DIR}")
set(MySQL_library_hints_debug "${MySQL_LIBRARY_DIR}/debug")
endif()
find_path(MySQL_INCLUDE_DIR
NAMES mysql.h
HINTS "${MySQL_include_dir_hints}"
PATH_SUFFIXES mysql mariadb)
find_library(MySQL_LIBRARY
NO_PACKAGE_ROOT_PATH
NAMES libmysql mysql mysqlclient libmariadb mariadb
HINTS ${MySQL_library_hints})
if(MySQL_library_hints_debug)
find_library(MySQL_LIBRARY_DEBUG
NO_PACKAGE_ROOT_PATH
NAMES libmysql mysql mysqlclient libmariadb mariadb
HINTS ${MySQL_library_hints_debug})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
if(MySQL_FOUND)
set(MySQL_INCLUDE_DIRS "${MySQL_INCLUDE_DIR}")
set(MySQL_LIBRARIES "${MySQL_LIBRARY}")
if(NOT TARGET MySQL::MySQL)
add_library(MySQL::MySQL UNKNOWN IMPORTED)
set_target_properties(MySQL::MySQL PROPERTIES
IMPORTED_LOCATION "${MySQL_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${MySQL_INCLUDE_DIRS}")
if(MySQL_LIBRARY_DEBUG)
set_target_properties(MySQL::MySQL PROPERTIES
IMPORTED_LOCATION_DEBUG "${MySQL_LIBRARY_DEBUG}")
endif()
endif()
endif()
mark_as_advanced(MySQL_INCLUDE_DIR MySQL_LIBRARY)
include(FeatureSummary)
set_package_properties(MySQL PROPERTIES
URL "https://www.mysql.com"
DESCRIPTION "MySQL client library")

53
cmake/FindOracle.cmake Normal file
View File

@ -0,0 +1,53 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# FindOracle
# ---------
#
# Try to locate the oracle client library.
# If found, this will define the following variables:
#
# ``Oracle_FOUND``
# True if the oracle library is available
# ``Oracle_INCLUDE_DIRS``
# The oracle include directories
# ``Oracle_LIBRARIES``
# The oracle libraries for linking
#
# If ``Oracle_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``Oracle::Oracle``
# The oracle instant client library
find_path(Oracle_INCLUDE_DIR
NAMES oci.h
HINTS ${Oracle_INCLUDE_DIR})
set(ORACLE_OCI_NAMES clntsh ociei oraociei12 oci)
find_library(Oracle_LIBRARY
NAMES ${ORACLE_OCI_NAMES}
HINTS ${Oracle_LIBRARY_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Oracle DEFAULT_MSG Oracle_LIBRARY Oracle_INCLUDE_DIR)
if(Oracle_FOUND)
set(Oracle_INCLUDE_DIRS "${Oracle_INCLUDE_DIR}")
set(Oracle_LIBRARIES "${Oracle_LIBRARY}")
if(NOT TARGET Oracle::OCI)
add_library(Oracle::OCI UNKNOWN IMPORTED)
set_target_properties(Oracle::OCI PROPERTIES
IMPORTED_LOCATION "${Oracle_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Oracle_INCLUDE_DIRS}")
endif()
endif()
mark_as_advanced(Oracle_INCLUDE_DIR Oracle_LIBRARY)
include(FeatureSummary)
set_package_properties(Oracle PROPERTIES
URL "https://www.oracle.com"
DESCRIPTION "Oracle client library")

26
cmake/FindPPS.cmake Normal file
View File

@ -0,0 +1,26 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Find the PPS library
# Will make the target PPS::PPS available when found.
if(TARGET PPS::PPS)
set(PPS_FOUND TRUE)
return()
endif()
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()

318
cmake/FindPostgreSQL.cmake Normal file
View File

@ -0,0 +1,318 @@
# Copyright (C) 2000-2022 Kitware, Inc. and Contributors.
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#[=======================================================================[.rst:
FindPostgreSQL
--------------
Find the PostgreSQL installation.
IMPORTED Targets
^^^^^^^^^^^^^^^^
.. versionadded:: 3.14
This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL``
if PostgreSQL has been found.
Result Variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``PostgreSQL_FOUND``
True if PostgreSQL is found.
``PostgreSQL_LIBRARIES``
the PostgreSQL libraries needed for linking
``PostgreSQL_INCLUDE_DIRS``
the directories of the PostgreSQL headers
``PostgreSQL_LIBRARY_DIRS``
the link directories for PostgreSQL libraries
``PostgreSQL_VERSION_STRING``
the version of PostgreSQL found
``PostgreSQL_TYPE_INCLUDE_DIR``
the directories of the PostgreSQL server headers
Components
^^^^^^^^^^
This module contains additional ``Server`` component, that forcibly checks
for the presence of server headers. Note that ``PostgreSQL_TYPE_INCLUDE_DIR``
is set regardless of the presence of the ``Server`` component in find_package call.
#]=======================================================================]
# ----------------------------------------------------------------------------
# History:
# This module is derived from the module originally found in the VTK source tree.
#
# ----------------------------------------------------------------------------
# Note:
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
# version number of the implementation of PostgreSQL.
# In Windows the default installation of PostgreSQL uses that as part of the path.
# E.g C:\Program Files\PostgreSQL\8.4.
# Currently, the following version numbers are known to this module:
# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
#
# To use this variable just do something like this:
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
# This will mean that the versions you set here will be found first in the order
# specified before the default ones are searched.
#
# ----------------------------------------------------------------------------
# You may need to manually set:
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
# If FindPostgreSQL.cmake cannot find the include files or the library files.
#
# ----------------------------------------------------------------------------
# The following variables are set if PostgreSQL is found:
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
#
# The ``PostgreSQL::PostgreSQL`` imported target is also created.
#
# ----------------------------------------------------------------------------
# If you have installed PostgreSQL in a non-standard location.
# (Please note that in the following comments, it is assumed that <Your Path>
# points to the root directory of the include directory of PostgreSQL.)
# Then you have three options.
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
# installed PostgreSQL, e.g. <Your Path>.
#
# ----------------------------------------------------------------------------
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
include("${CMAKE_ROOT}/Modules/FindPostgreSQL.cmake")
return()
endif()
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
"13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
# Define additional search paths for root directories.
set( PostgreSQL_ROOT_DIRECTORIES
ENV PostgreSQL_ROOT
${PostgreSQL_ROOT}
)
foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})
if(WIN32)
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/lib")
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/include")
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
"PostgreSQL/${suffix}/include/server")
endif()
if(UNIX)
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
"postgresql${suffix}"
"pgsql-${suffix}/lib")
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
"postgresql${suffix}"
"postgresql/${suffix}"
"pgsql-${suffix}/include")
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
"postgresql${suffix}/server"
"postgresql/${suffix}/server"
"pgsql-${suffix}/include/server")
endif()
endforeach()
#
# Look for an installation.
#
find_path(PostgreSQL_INCLUDE_DIR
NAMES libpq-fe.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
pgsql
postgresql
include
${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
find_path(PostgreSQL_TYPE_INCLUDE_DIR
NAMES catalog/pg_type.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
postgresql
pgsql/server
postgresql/server
include/server
${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES}
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
# The PostgreSQL library.
set (PostgreSQL_LIBRARY_TO_FIND pq)
# Setting some more prefixes for the library
set (PostgreSQL_LIB_PREFIX "")
if ( WIN32 )
set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
endif()
function(__postgresql_find_library _name)
find_library(${_name}
NAMES ${ARGN}
PATHS
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
lib
${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
)
endfunction()
# For compatibility with versions prior to this multi-config search, honor
# any PostgreSQL_LIBRARY that is already specified and skip the search.
if(PostgreSQL_LIBRARY)
set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}")
get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH)
else()
__postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND})
__postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d)
include(SelectLibraryConfigurations)
select_library_configurations(PostgreSQL)
mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG)
if(PostgreSQL_LIBRARY_RELEASE)
get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH)
elseif(PostgreSQL_LIBRARY_DEBUG)
get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH)
else()
set(PostgreSQL_LIBRARY_DIR "")
endif()
endif()
if (PostgreSQL_INCLUDE_DIR)
# Some platforms include multiple pg_config.hs for multi-lib configurations
# This is a temporary workaround. A better solution would be to compile
# a dummy c file and extract the value of the symbol.
file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION_NUM[\t ]+.*")
if(pgsql_version_str)
string(REGEX REPLACE "^#define[\t ]+PG_VERSION_NUM[\t ]+([0-9]*).*"
"\\1" _PostgreSQL_VERSION_NUM "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
if (_PostgreSQL_VERSION_NUM)
# 9.x and older encoding
if (_PostgreSQL_VERSION_NUM LESS 100000)
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100")
math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100")
set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}")
unset(_PostgreSQL_major_version)
unset(_PostgreSQL_minor_version)
unset(_PostgreSQL_patch_version)
else ()
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000")
set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}")
unset(_PostgreSQL_major_version)
unset(_PostgreSQL_minor_version)
endif ()
else ()
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
if(pgsql_version_str)
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
endif ()
unset(_PostgreSQL_VERSION_NUM)
unset(pgsql_version_str)
endif()
if("Server" IN_LIST PostgreSQL_FIND_COMPONENTS)
set(PostgreSQL_Server_FOUND TRUE)
if(NOT PostgreSQL_TYPE_INCLUDE_DIR)
set(PostgreSQL_Server_FOUND FALSE)
endif()
endif()
# Did we find anything?
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PostgreSQL
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
HANDLE_COMPONENTS
VERSION_VAR PostgreSQL_VERSION_STRING)
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
function(__postgresql_import_library _target _var _config)
if(_config)
set(_config_suffix "_${_config}")
else()
set(_config_suffix "")
endif()
set(_lib "${${_var}${_config_suffix}}")
if(EXISTS "${_lib}")
if(_config)
set_property(TARGET ${_target} APPEND PROPERTY
IMPORTED_CONFIGURATIONS ${_config})
endif()
set_target_properties(${_target} PROPERTIES
IMPORTED_LOCATION${_config_suffix} "${_lib}")
endif()
endfunction()
# Now try to get the include and library path.
if(PostgreSQL_FOUND)
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR})
if(PostgreSQL_TYPE_INCLUDE_DIR)
list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR})
endif()
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR})
if (NOT TARGET PostgreSQL::PostgreSQL)
add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED)
set_target_properties(PostgreSQL::PostgreSQL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIRS}")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "RELEASE")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "DEBUG")
endif ()
endif()
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR)
cmake_policy(POP)

24
cmake/FindSlog2.cmake Normal file
View File

@ -0,0 +1,24 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Find the Slog2 library
# Will make the target Slog2::Slog2 available when found.
if(TARGET Slog2::Slog2)
set(Slog2_FOUND TRUE)
return()
endif()
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::Slog2 INTERFACE IMPORTED)
target_link_libraries(Slog2::Slog2 INTERFACE ${Slog2_LIBRARY})
target_include_directories(Slog2::Slog2 INTERFACE ${Slog2_INCLUDE_DIR})
endif()

10
cmake/FindTslib.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(Tslib IMPORTED_TARGET "tslib")
if (NOT TARGET PkgConfig::Tslib)
set(Tslib_FOUND 0)
endif()

View File

@ -0,0 +1,54 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapAtomic::WrapAtomic)
set(WrapAtomic_FOUND ON)
return()
endif()
include(CheckCXXSourceCompiles)
set (atomic_test_sources "#include <atomic>
#include <cstdint>
int main(int, char **)
{
volatile std::atomic<char> size_1;
volatile std::atomic<short> size_2;
volatile std::atomic<int> size_4;
volatile std::atomic<int64_t> size_8;
++size_1;
++size_2;
++size_4;
++size_8;
(void)size_1.load(std::memory_order_relaxed);
(void)size_2.load(std::memory_order_relaxed);
(void)size_4.load(std::memory_order_relaxed);
(void)size_8.load(std::memory_order_relaxed);
return 0;
}")
check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC)
if(NOT HAVE_STDATOMIC)
set(_req_libraries "${CMAKE_REQUIRED_LIBRARIES}")
set(atomic_LIB "-latomic")
set(CMAKE_REQUIRED_LIBRARIES ${atomic_LIB})
check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC_WITH_LIB)
set(CMAKE_REQUIRED_LIBRARIES "${_req_libraries}")
endif()
add_library(WrapAtomic::WrapAtomic INTERFACE IMPORTED)
if(HAVE_STDATOMIC_WITH_LIB)
# atomic_LIB is already found above.
target_link_libraries(WrapAtomic::WrapAtomic INTERFACE ${atomic_LIB})
endif()
set(WrapAtomic_FOUND 1)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapAtomic DEFAULT_MSG WrapAtomic_FOUND)

View File

@ -0,0 +1,20 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET WrapBacktrace::WrapBacktrace)
set(WrapBacktrace_FOUND ON)
return()
endif()
find_package(Backtrace)
if(Backtrace_FOUND)
add_library(WrapBacktrace::WrapBacktrace INTERFACE IMPORTED)
target_link_libraries(WrapBacktrace::WrapBacktrace
INTERFACE ${Backtrace_LIBRARY})
target_include_directories(WrapBacktrace::WrapBacktrace
INTERFACE ${Backtrace_INCLUDE_DIR})
set(WrapBacktrace_FOUND ON)
else()
set(WrapBacktrace_FOUND OFF)
endif()

100
cmake/FindWrapBrotli.cmake Normal file
View File

@ -0,0 +1,100 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET WrapBrotli::WrapBrotliDec)
set(WrapBrotli_FOUND ON)
return()
endif()
# From VCPKG
find_package(unofficial-brotli CONFIG QUIET)
if (unofficial-brotli_FOUND)
add_library(WrapBrotli::WrapBrotliDec INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliDec INTERFACE unofficial::brotli::brotlidec)
add_library(WrapBrotli::WrapBrotliEnc INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliEnc INTERFACE unofficial::brotli::brotlienc)
add_library(WrapBrotli::WrapBrotliCommon INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliCommon INTERFACE unofficial::brotli::brotlicommon)
set(WrapBrotli_FOUND ON)
else()
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(libbrotlidec QUIET IMPORTED_TARGET "libbrotlidec")
if (libbrotlidec_FOUND)
add_library(WrapBrotli::WrapBrotliDec INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliDec INTERFACE PkgConfig::libbrotlidec)
set(WrapBrotli_FOUND ON)
endif()
pkg_check_modules(libbrotlienc QUIET IMPORTED_TARGET "libbrotlienc")
if (libbrotlienc_FOUND)
add_library(WrapBrotli::WrapBrotliEnc INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliEnc INTERFACE PkgConfig::libbrotlienc)
set(WrapBrotli_FOUND ON)
endif()
pkg_check_modules(libbrotlicommon QUIET IMPORTED_TARGET "libbrotlicommon")
if (libbrotlicommon_FOUND)
add_library(WrapBrotli::WrapBrotliCommon INTERFACE IMPORTED)
target_link_libraries(WrapBrotli::WrapBrotliCommon INTERFACE PkgConfig::libbrotlicommon)
set(WrapBrotli_FOUND ON)
endif()
else()
find_path(BROTLI_INCLUDE_DIR NAMES "brotli/decode.h")
foreach(lib_name BrotliDec BrotliEnc BrotliCommon)
string(TOLOWER ${lib_name} lower_lib_name)
find_library(${lib_name}_LIBRARY_RELEASE
NAMES ${lower_lib_name} ${lower_lib_name}-static)
find_library(${lib_name}_LIBRARY_DEBUG
NAMES ${lower_lib_name}d ${lower_lib_name}-staticd
${lower_lib_name} ${lower_lib_name}-static)
include(SelectLibraryConfigurations)
select_library_configurations(${lib_name})
if (BROTLI_INCLUDE_DIR AND ${lib_name}_LIBRARY)
set(${lib_name}_FOUND TRUE)
endif()
if (${lib_name}_FOUND AND NOT TARGET WrapBrotli::Wrap${lib_name})
add_library(WrapBrotli::Wrap${lib_name} UNKNOWN IMPORTED)
set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
IMPORTED_LOCATION "${${lib_name}_LIBRARY}")
if(${lib_name}_LIBRARY_RELEASE)
foreach(config_name RELEASE RELWITHDEBINFO MINSIZEREL)
set_property(TARGET WrapBrotli::Wrap${lib_name} APPEND PROPERTY
IMPORTED_CONFIGURATIONS ${config_name})
set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
IMPORTED_LOCATION_${config_name} "${${lib_name}_LIBRARY_RELEASE}")
endforeach()
endif()
if(${lib_name}_LIBRARY_DEBUG)
set_property(TARGET WrapBrotli::Wrap${lib_name} APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
IMPORTED_LOCATION_DEBUG "${${lib_name}_LIBRARY_DEBUG}")
endif()
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapBrotli REQUIRED_VARS
BrotliDec_FOUND BrotliEnc_FOUND BrotliCommon_FOUND)
if (WrapBrotli_FOUND)
set_property(TARGET WrapBrotli::WrapBrotliDec APPEND PROPERTY
INTERFACE_LINK_LIBRARIES WrapBrotli::WrapBrotliCommon)
set_property(TARGET WrapBrotli::WrapBrotliEnc APPEND PROPERTY
INTERFACE_LINK_LIBRARIES WrapBrotli::WrapBrotliCommon)
endif()
endif()
endif()

50
cmake/FindWrapDBus1.cmake Normal file
View File

@ -0,0 +1,50 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# DBus1 is buggy and breaks PKG_CONFIG environment.
# Work around that:-/
# See https://gitlab.freedesktop.org/dbus/dbus/issues/267 for more information
# When doing top-level static Qt builds, we need to protect against double creation of the dbus
# target.
if(DBus1_FOUND OR WrapDBus1_FOUND OR TARGET dbus-1)
set(WrapDBus1_FOUND 1)
return()
endif()
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 ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
if(DEFINED __qt_dbus_pcd)
set(ENV{PKG_CONFIG_DIR} "${__qt_dbus_pcd}")
else()
unset(ENV{PKG_CONFIG_DIR})
endif()
if(DEFINED __qt_dbus_pcp)
set(ENV{PKG_CONFIG_PATH} "${__qt_dbus_pcp}")
else()
unset(ENV{PKG_CONFIG_PATH})
endif()
if(DEFINED __qt_dbus_pcl)
set(ENV{PKG_CONFIG_LIBDIR} "${__qt_dbus_pcl}")
else()
unset(ENV{PKG_CONFIG_LIBDIR})
endif()
if(DBus1_FOUND)
set(WrapDBus1_FOUND 1)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapDBus1 REQUIRED_VARS
DBus1_LIBRARY DBus1_INCLUDE_DIR WrapDBus1_FOUND
VERSION_VAR DBus1_VERSION)

View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_freetype
FRIENDLY_PACKAGE_NAME "Freetype"
WRAP_PACKAGE_TARGET "WrapFreetype::WrapFreetype"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapFreetype_FOUND"
BUNDLED_PACKAGE_NAME "BundledFreetype"
BUNDLED_PACKAGE_TARGET "BundledFreetype"
SYSTEM_PACKAGE_NAME "WrapSystemFreetype"
SYSTEM_PACKAGE_TARGET "WrapSystemFreetype::WrapSystemFreetype"
)

View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_harfbuzz
FRIENDLY_PACKAGE_NAME "Harfbuzz"
WRAP_PACKAGE_TARGET "WrapHarfbuzz::WrapHarfbuzz"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapHarfbuzz_FOUND"
BUNDLED_PACKAGE_NAME "BundledHarfbuzz"
BUNDLED_PACKAGE_TARGET "BundledHarfbuzz"
SYSTEM_PACKAGE_NAME "WrapSystemHarfbuzz"
SYSTEM_PACKAGE_TARGET "WrapSystemHarfbuzz::WrapSystemHarfbuzz"
)

14
cmake/FindWrapJpeg.cmake Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_jpeg
FRIENDLY_PACKAGE_NAME "Jpeg"
WRAP_PACKAGE_TARGET "WrapJpeg::WrapJpeg"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapJpeg_FOUND"
BUNDLED_PACKAGE_NAME "BundledLibjpeg"
BUNDLED_PACKAGE_TARGET "BundledLibjpeg"
SYSTEM_PACKAGE_NAME "WrapSystemJpeg"
SYSTEM_PACKAGE_TARGET "WrapSystemJpeg::WrapSystemJpeg"
)

View File

@ -0,0 +1,52 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapOpenGL::WrapOpenGL)
set(WrapOpenGL_FOUND ON)
return()
endif()
set(WrapOpenGL_FOUND OFF)
find_package(OpenGL ${WrapOpenGL_FIND_VERSION})
if (OpenGL_FOUND)
set(WrapOpenGL_FOUND ON)
add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED)
if(APPLE)
# On Darwin platforms FindOpenGL sets IMPORTED_LOCATION to the absolute path of the library
# within the framework. This ends up as an absolute path link flag, which we don't want,
# because that makes our .prl files un-relocatable.
# Extract the framework path instead, and use that in INTERFACE_LINK_LIBRARIES,
# which CMake ends up transforming into a reloctable -framework flag.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/20871 for details.
get_target_property(__opengl_fw_lib_path OpenGL::GL IMPORTED_LOCATION)
if(__opengl_fw_lib_path)
get_filename_component(__opengl_fw_path "${__opengl_fw_lib_path}" DIRECTORY)
endif()
if(NOT __opengl_fw_path)
# Just a safety measure in case if no OpenGL::GL target exists.
set(__opengl_fw_path "-framework OpenGL")
endif()
find_library(WrapOpenGL_AGL NAMES AGL)
if(WrapOpenGL_AGL)
set(__opengl_agl_fw_path "${WrapOpenGL_AGL}")
endif()
if(NOT __opengl_agl_fw_path)
set(__opengl_agl_fw_path "-framework AGL")
endif()
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_fw_path})
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_agl_fw_path})
else()
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapOpenGL DEFAULT_MSG WrapOpenGL_FOUND)

View File

@ -0,0 +1,42 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapOpenSSL::WrapOpenSSL)
set(WrapOpenSSL_FOUND ON)
return()
endif()
set(WrapOpenSSL_FOUND OFF)
# Reuse logic from the headers find script.
find_package(WrapOpenSSLHeaders ${WrapOpenSSL_FIND_VERSION})
if(TARGET OpenSSL::SSL)
if(WIN32)
get_target_property(libType OpenSSL::Crypto TYPE)
if(libType STREQUAL "ALIAS")
get_target_property(writableLib OpenSSL::Crypto ALIASED_TARGET)
else()
set(writableLib OpenSSL::Crypto)
endif()
set_property(TARGET ${writableLib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 crypt32)
unset(libType)
unset(writableLib)
endif()
set(WrapOpenSSL_FOUND ON)
add_library(WrapOpenSSL::WrapOpenSSL INTERFACE IMPORTED)
target_link_libraries(WrapOpenSSL::WrapOpenSSL INTERFACE OpenSSL::SSL)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapOpenSSL
REQUIRED_VARS
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
)

View File

@ -0,0 +1,45 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapOpenSSLHeaders::WrapOpenSSLHeaders)
set(WrapOpenSSLHeaders_FOUND ON)
return()
endif()
set(WrapOpenSSLHeaders_FOUND OFF)
# When cross-compiling (to Android for example), we need to add the OPENSSL_ROOT_DIR as a root path,
# otherwise the value would just be appended to the sysroot, which is wrong.
if(OPENSSL_ROOT_DIR)
set(__find_wrap_openssl_headers_backup_root_dir "${CMAKE_FIND_ROOT_PATH}")
list(APPEND CMAKE_FIND_ROOT_PATH "${OPENSSL_ROOT_DIR}")
endif()
find_package(OpenSSL ${WrapOpenSSLHeaders_FIND_VERSION})
if(OPENSSL_ROOT_DIR)
set(CMAKE_FIND_ROOT_PATH "${__find_wrap_openssl_headers_backup_root_dir}")
endif()
# We are interested only in include headers. The libraries might be missing, so we can't check the
# _FOUND variable.
if(OPENSSL_INCLUDE_DIR)
set(WrapOpenSSLHeaders_FOUND ON)
add_library(WrapOpenSSLHeaders::WrapOpenSSLHeaders INTERFACE IMPORTED)
target_include_directories(WrapOpenSSLHeaders::WrapOpenSSLHeaders INTERFACE
${OPENSSL_INCLUDE_DIR})
set_target_properties(WrapOpenSSLHeaders::WrapOpenSSLHeaders PROPERTIES
_qt_is_nolink_target TRUE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapOpenSSLHeaders
REQUIRED_VARS
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
)

14
cmake/FindWrapPCRE2.cmake Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_pcre2
FRIENDLY_PACKAGE_NAME "PCRE2"
WRAP_PACKAGE_TARGET "WrapPCRE2::WrapPCRE2"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapPCRE2_FOUND"
BUNDLED_PACKAGE_NAME "BundledPcre2"
BUNDLED_PACKAGE_TARGET "BundledPcre2"
SYSTEM_PACKAGE_NAME "WrapSystemPCRE2"
SYSTEM_PACKAGE_TARGET "WrapSystemPCRE2::WrapSystemPCRE2"
)

14
cmake/FindWrapPNG.cmake Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_png
FRIENDLY_PACKAGE_NAME "PNG"
WRAP_PACKAGE_TARGET "WrapPNG::WrapPNG"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapPNG_FOUND"
BUNDLED_PACKAGE_NAME "BundledLibpng"
BUNDLED_PACKAGE_TARGET "BundledLibpng"
SYSTEM_PACKAGE_NAME "WrapSystemPNG"
SYSTEM_PACKAGE_TARGET "WrapSystemPNG::WrapSystemPNG"
)

43
cmake/FindWrapRt.cmake Normal file
View File

@ -0,0 +1,43 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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::WrapRt)
set(WrapRt_FOUND ON)
return()
endif()
set(WrapRt_FOUND OFF)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
find_library(LIBRT rt)
cmake_push_check_state()
if(LIBRT)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}")
endif()
check_cxx_source_compiles("
#include <unistd.h>
#include <time.h>
int main(int, char **) {
timespec ts; clock_gettime(CLOCK_REALTIME, &ts);
}" HAVE_GETTIME)
cmake_pop_check_state()
if(HAVE_GETTIME)
set(WrapRt_FOUND ON)
add_library(WrapRt::WrapRt INTERFACE IMPORTED)
if (LIBRT)
target_link_libraries(WrapRt::WrapRt INTERFACE "${LIBRT}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapRt DEFAULT_MSG WrapRt_FOUND)

View File

@ -0,0 +1,85 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapSystemDoubleConversion::WrapSystemDoubleConversion)
set(WrapSystemDoubleConversion_FOUND ON)
return()
endif()
set(WrapSystemDoubleConversion_REQUIRED_VARS "__double_conversion_found")
# Find either Config package or Find module.
# Upstream can be built either with CMake and then provides a Config file, or with Scons in which
# case there's no Config file.
# A Find module might be provided by a 3rd party, for example Conan might generate a Find module.
find_package(double-conversion ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
set(__double_conversion_target_name "double-conversion::double-conversion")
if(double-conversion_FOUND AND TARGET "${__double_conversion_target_name}")
set(__double_conversion_found TRUE)
# This ensures the Config file is shown in the fphsa message.
if(double-conversion_CONFIG)
list(PREPEND WrapSystemDoubleConversion_REQUIRED_VARS
double-conversion_CONFIG)
endif()
endif()
if(NOT __double_conversion_found)
list(PREPEND WrapSystemDoubleConversion_REQUIRED_VARS
DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR)
find_path(DOUBLE_CONVERSION_INCLUDE_DIR
NAMES
double-conversion/double-conversion.h
)
find_library(DOUBLE_CONVERSION_LIBRARY_RELEASE NAMES double-conversion)
# We assume a possible debug build of this library to be named with a d suffix.
# Adjust accordingly if a different naming scheme is established.
find_library(DOUBLE_CONVERSION_LIBRARY_DEBUG NAMES double-conversiond)
include(SelectLibraryConfigurations)
select_library_configurations(DOUBLE_CONVERSION)
mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
set(DOUBLE_CONVERSION_INCLUDE_DIRS "${DOUBLE_CONVERSION_INCLUDE_DIR}")
if(DOUBLE_CONVERSION_LIBRARIES AND DOUBLE_CONVERSION_INCLUDE_DIRS)
set(__double_conversion_found TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
set(__double_conversion_fphsa_args "")
if(double-conversion_VERSION)
set(WrapSystemDoubleConversion_VERSION "${double-conversion_VERSION}")
list(APPEND __double_conversion_fphsa_args VERSION_VAR WrapSystemDoubleConversion_VERSION)
endif()
find_package_handle_standard_args(WrapSystemDoubleConversion
REQUIRED_VARS ${WrapSystemDoubleConversion_REQUIRED_VARS}
${__double_conversion_fphsa_args})
if(WrapSystemDoubleConversion_FOUND)
add_library(WrapSystemDoubleConversion::WrapSystemDoubleConversion INTERFACE IMPORTED)
if(TARGET "${__double_conversion_target_name}")
target_link_libraries(WrapSystemDoubleConversion::WrapSystemDoubleConversion
INTERFACE "${__double_conversion_target_name}")
else()
target_link_libraries(WrapSystemDoubleConversion::WrapSystemDoubleConversion
INTERFACE ${DOUBLE_CONVERSION_LIBRARIES})
target_include_directories(WrapSystemDoubleConversion::WrapSystemDoubleConversion
INTERFACE ${DOUBLE_CONVERSION_INCLUDE_DIRS})
endif()
endif()
unset(__double_conversion_target_name)
unset(__double_conversion_found)
unset(__double_conversion_fphsa_args)
include(FeatureSummary)
set_package_properties(WrapSystemDoubleConversion PROPERTIES
URL "https://github.com/google/double-conversion"
DESCRIPTION "double-conversion library")

View File

@ -0,0 +1,53 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapSystemFreetype::WrapSystemFreetype)
set(WrapSystemFreetype_FOUND TRUE)
return()
endif()
set(WrapSystemFreetype_REQUIRED_VARS __freetype_found)
# 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 ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION}
CONFIG NAMES Freetype freetype QUIET)
if(NOT Freetype_FOUND)
find_package(Freetype ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET MODULE)
endif()
if(Freetype_FOUND)
# vcpkg defines a lower case target name, while upstream Find module defines a prefixed
# upper case name.
set(__freetype_potential_target_names Freetype::Freetype freetype)
foreach(__freetype_potential_target_name ${__freetype_potential_target_names})
if(TARGET "${__freetype_potential_target_name}")
set(__freetype_target_name "${__freetype_potential_target_name}")
set(__freetype_found TRUE)
break()
endif()
endforeach()
endif()
if(FREETYPE_LIBRARIES)
list(PREPEND WrapSystemFreetype_REQUIRED_VARS FREETYPE_LIBRARIES)
endif()
if(Freetype_VERSION)
set(WrapSystemFreetype_VERSION "${Freetype_VERSION}")
elseif(FREETYPE_VERSION_STRING)
set(WrapSystemFreetype_VERSION "${FREETYPE_VERSION_STRING}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemFreetype
REQUIRED_VARS ${WrapSystemFreetype_REQUIRED_VARS}
VERSION_VAR WrapSystemFreetype_VERSION)
if(WrapSystemFreetype_FOUND)
add_library(WrapSystemFreetype::WrapSystemFreetype INTERFACE IMPORTED)
target_link_libraries(WrapSystemFreetype::WrapSystemFreetype
INTERFACE "${__freetype_target_name}")
endif()
unset(__freetype_target_name)
unset(__freetype_found)

View File

@ -0,0 +1,83 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapSystemHarfbuzz::WrapSystemHarfbuzz)
set(WrapSystemHarfbuzz_FOUND TRUE)
return()
endif()
set(WrapSystemHarfbuzz_REQUIRED_VARS __harfbuzz_found)
find_package(harfbuzz ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
# Gentoo has some buggy version of a harfbuzz Config file. Check if include paths are valid.
set(__harfbuzz_target_name "harfbuzz::harfbuzz")
if(harfbuzz_FOUND AND TARGET "${__harfbuzz_target_name}")
get_property(__harfbuzz_include_paths TARGET "${__harfbuzz_target_name}"
PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
foreach(__harfbuzz_include_dir ${__harfbuzz_include_paths})
if(NOT EXISTS "${__harfbuzz_include_dir}")
# Must be the broken Gentoo harfbuzzConfig.cmake file. Try to use pkg-config instead.
set(__harfbuzz_broken_config_file TRUE)
break()
endif()
endforeach()
set(__harfbuzz_found TRUE)
if(harfbuzz_VERSION)
set(WrapSystemHarfbuzz_VERSION "${harfbuzz_VERSION}")
endif()
endif()
if(__harfbuzz_broken_config_file OR NOT __harfbuzz_found)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_HARFBUZZ IMPORTED_TARGET "harfbuzz")
if(PC_HARFBUZZ_FOUND)
set(__harfbuzz_target_name "PkgConfig::PC_HARFBUZZ")
set(__harfbuzz_find_include_dirs_hints
HINTS ${PC_HARFBUZZ_INCLUDEDIR})
set(__harfbuzz_find_library_hints
HINTS ${PC_HARFBUZZ_LIBDIR})
if(PC_HARFBUZZ_VERSION)
set(WrapSystemHarfbuzz_VERSION "${PC_HARFBUZZ_VERSION}")
endif()
else()
set(__harfbuzz_target_name "Harfbuzz::Harfbuzz")
endif()
find_path(HARFBUZZ_INCLUDE_DIRS
NAMES harfbuzz/hb.h
${__harfbuzz_find_include_dirs_hints})
find_library(HARFBUZZ_LIBRARIES
NAMES harfbuzz
${__harfbuzz_find_library_hints})
if(HARFBUZZ_INCLUDE_DIRS AND HARFBUZZ_LIBRARIES)
set(__harfbuzz_found TRUE)
if(NOT PC_HARFBUZZ_FOUND)
add_library(${__harfbuzz_target_name} UNKNOWN IMPORTED)
list(TRANSFORM HARFBUZZ_INCLUDE_DIRS APPEND "/harfbuzz")
set_target_properties(${__harfbuzz_target_name} PROPERTIES
IMPORTED_LOCATION "${HARFBUZZ_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIRS}"
)
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemHarfbuzz
REQUIRED_VARS ${WrapSystemHarfbuzz_REQUIRED_VARS}
VERSION_VAR WrapSystemHarfbuzz_VERSION)
if(WrapSystemHarfbuzz_FOUND)
add_library(WrapSystemHarfbuzz::WrapSystemHarfbuzz INTERFACE IMPORTED)
target_link_libraries(WrapSystemHarfbuzz::WrapSystemHarfbuzz
INTERFACE "${__harfbuzz_target_name}")
endif()
unset(__harfbuzz_target_name)
unset(__harfbuzz_find_include_dirs_hints)
unset(__harfbuzz_find_library_hints)
unset(__harfbuzz_found)
unset(__harfbuzz_include_dir)
unset(__harfbuzz_broken_config_file)

View File

@ -0,0 +1,35 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET WrapSystemJpeg::WrapSystemJpeg)
set(WrapSystemJpeg_FOUND TRUE)
return()
endif()
set(WrapSystemJpeg_REQUIRED_VARS __jpeg_found)
find_package(JPEG ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
set(__jpeg_target_name "JPEG::JPEG")
if(JPEG_FOUND AND TARGET "${__jpeg_target_name}")
set(__jpeg_found TRUE)
endif()
if(JPEG_LIBRARIES)
list(PREPEND WrapSystemJpeg_REQUIRED_VARS JPEG_LIBRARIES)
endif()
if(JPEG_VERSION)
set(WrapSystemJpeg_VERSION "${JPEG_VERSION}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemJpeg
REQUIRED_VARS ${WrapSystemJpeg_REQUIRED_VARS}
VERSION_VAR WrapSystemJpeg_VERSION)
if(WrapSystemJpeg_FOUND)
add_library(WrapSystemJpeg::WrapSystemJpeg INTERFACE IMPORTED)
target_link_libraries(WrapSystemJpeg::WrapSystemJpeg
INTERFACE "${__jpeg_target_name}")
endif()
unset(__jpeg_target_name)
unset(__jpeg_found)

View File

@ -0,0 +1,43 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET WrapSystemMd4c::WrapSystemMd4c)
set(WrapSystemMd4c_FOUND TRUE)
return()
endif()
set(WrapSystemMd4c_REQUIRED_VARS __md4c_found)
find_package(md4c ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
set(__md4c_target_name "md4c::md4c")
if(md4c_FOUND)
set(__md4c_found TRUE)
# md4c provides a md4c::md4c target but
# older versions create a md4c target without
# namespace. If we find the old variant create
# a namespaced target out of the md4c target.
if(TARGET md4c AND NOT TARGET ${__md4c_target_name})
add_library(${__md4c_target_name} INTERFACE IMPORTED)
target_link_libraries(${__md4c_target_name} INTERFACE md4c)
endif()
if(md4c_VERSION)
set(WrapSystemMd4c_VERSION "${md4c_VERSION}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemMd4c
REQUIRED_VARS ${WrapSystemMd4c_REQUIRED_VARS}
VERSION_VAR WrapSystemMd4c_VERSION)
if(WrapSystemMd4c_FOUND)
add_library(WrapSystemMd4c::WrapSystemMd4c INTERFACE IMPORTED)
target_link_libraries(WrapSystemMd4c::WrapSystemMd4c
INTERFACE "${__md4c_target_name}")
endif()
unset(__md4c_found)
unset(__md4c_target_name)

View File

@ -0,0 +1,62 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET WrapSystemPCRE2::WrapSystemPCRE2)
set(WrapSystemPCRE2_FOUND TRUE)
return()
endif()
set(WrapSystemPCRE2_REQUIRED_VARS __pcre2_found)
find_package(PCRE2 ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} COMPONENTS 16BIT QUIET)
set(__pcre2_target_name "PCRE2::16BIT")
if(PCRE2_FOUND AND TARGET "${__pcre2_target_name}")
# Hunter case.
set(__pcre2_found TRUE)
if(PCRE2_VERSION)
set(WrapSystemPCRE2_VERSION "${PCRE2_VERSION}")
endif()
endif()
if(NOT __pcre2_found)
list(PREPEND WrapSystemPCRE2_REQUIRED_VARS PCRE2_LIBRARIES PCRE2_INCLUDE_DIRS)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_PCRE2 QUIET "libpcre2-16")
find_path(PCRE2_INCLUDE_DIRS
NAMES pcre2.h
HINTS ${PC_PCRE2_INCLUDEDIR})
find_library(PCRE2_LIBRARY_RELEASE
NAMES pcre2-16
HINTS ${PC_PCRE2_LIBDIR})
find_library(PCRE2_LIBRARY_DEBUG
NAMES pcre2-16d pcre2-16
HINTS ${PC_PCRE2_LIBDIR})
include(SelectLibraryConfigurations)
select_library_configurations(PCRE2)
if(PC_PCRE2_VERSION)
set(WrapSystemPCRE2_VERSION "${PC_PCRE2_VERSION}")
endif()
if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
set(__pcre2_found TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemPCRE2
REQUIRED_VARS ${WrapSystemPCRE2_REQUIRED_VARS}
VERSION_VAR WrapSystemPCRE2_VERSION)
if(WrapSystemPCRE2_FOUND)
add_library(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE IMPORTED)
if(TARGET "${__pcre2_target_name}")
target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE "${__pcre2_target_name}")
else()
target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_LIBRARIES})
target_include_directories(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
endif()
endif()
unset(__pcre2_target_name)
unset(__pcre2_found)

View File

@ -0,0 +1,42 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapSystemPNG::WrapSystemPNG)
set(WrapSystemPNG_FOUND TRUE)
return()
endif()
set(WrapSystemPNG_REQUIRED_VARS __png_found)
find_package(PNG ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
set(__png_target_name "PNG::PNG")
if(PNG_FOUND AND TARGET "${__png_target_name}")
set(__png_found TRUE)
if(PNG_VERSION)
set(WrapSystemPNG_VERSION "${PNG_VERSION}")
endif()
endif()
if(PNG_LIBRARIES)
list(PREPEND WrapSystemPNG_REQUIRED_VARS PNG_LIBRARIES)
endif()
if(PNG_VERSION)
set(WrapSystemPNG_VERSION "${PNG_VERSION}")
elseif(PNG_VERSION_STRING)
set(WrapSystemPNG_VERSION "${PNG_VERSION_STRING}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemPNG
REQUIRED_VARS ${WrapSystemPNG_REQUIRED_VARS}
VERSION_VAR WrapSystemPNG_VERSION)
if(WrapSystemPNG_FOUND)
add_library(WrapSystemPNG::WrapSystemPNG INTERFACE IMPORTED)
target_link_libraries(WrapSystemPNG::WrapSystemPNG
INTERFACE "${__png_target_name}")
endif()
unset(__png_target_name)
unset(__png_found)

View File

@ -0,0 +1,32 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapSystemZLIB::WrapSystemZLIB)
set(WrapSystemZLIB_FOUND ON)
return()
endif()
set(WrapSystemZLIB_FOUND OFF)
find_package(ZLIB ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION})
if(ZLIB_FOUND)
set(WrapSystemZLIB_FOUND ON)
add_library(WrapSystemZLIB::WrapSystemZLIB INTERFACE IMPORTED)
if(APPLE)
# On Darwin platforms FindZLIB sets IMPORTED_LOCATION to the absolute path of the library
# within the framework. This ends up as an absolute path link flag, which we don't want,
# because that makes our .prl files un-relocatable and also breaks iOS simulator_and_device
# SDK switching in Xcode.
# Just pass a linker flag instead.
target_link_libraries(WrapSystemZLIB::WrapSystemZLIB INTERFACE "-lz")
else()
target_link_libraries(WrapSystemZLIB::WrapSystemZLIB INTERFACE ZLIB::ZLIB)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemZLIB DEFAULT_MSG WrapSystemZLIB_FOUND)

View File

@ -0,0 +1,23 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapVulkan::WrapVulkan)
set(WrapVulkan_FOUND ON)
return()
endif()
set(WrapVulkan_FOUND OFF)
find_package(Vulkan ${WrapVulkan_FIND_VERSION} QUIET)
if(Vulkan_FOUND)
set(WrapVulkan_FOUND ON)
add_library(WrapVulkan::WrapVulkan INTERFACE IMPORTED)
target_link_libraries(WrapVulkan::WrapVulkan INTERFACE Vulkan::Vulkan)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapVulkan DEFAULT_MSG Vulkan_LIBRARY Vulkan_INCLUDE_DIR)

View File

@ -0,0 +1,55 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# 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 WrapVulkanHeaders::WrapVulkanHeaders)
set(WrapVulkanHeaders_FOUND ON)
return()
endif()
set(WrapVulkanHeaders_FOUND OFF)
find_package(Vulkan ${WrapVulkanHeaders_FIND_VERSION} QUIET)
# We are interested only in include headers. The libraries might be missing, so we can't check the
# _FOUND variable.
if(Vulkan_INCLUDE_DIR)
set(WrapVulkanHeaders_FOUND ON)
add_library(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE IMPORTED)
target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE
${Vulkan_INCLUDE_DIR})
set_target_properties(WrapVulkanHeaders::WrapVulkanHeaders PROPERTIES
_qt_is_nolink_target TRUE)
set_target_properties(WrapVulkanHeaders::WrapVulkanHeaders PROPERTIES
_qt_skip_include_dir_for_pri TRUE)
# Also propagate MoltenVK include directory on Apple platforms if found.
if(APPLE)
# Check for the LunarG Vulkan SDK folder structure.
set(__qt_molten_vk_include_path "${Vulkan_INCLUDE_DIR}/../../MoltenVK/include")
get_filename_component(
__qt_molten_vk_include_path
"${__qt_molten_vk_include_path}" ABSOLUTE)
if(EXISTS "${__qt_molten_vk_include_path}")
target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE
${__qt_molten_vk_include_path})
endif()
# Check for homebrew molten-vk folder structure
set(__qt_molten_vk_homebrew_include_path "${Vulkan_INCLUDE_DIR}/../../include")
get_filename_component(
__qt_molten_vk_homebrew_include_path
"${__qt_molten_vk_homebrew_include_path}" ABSOLUTE)
if(EXISTS "${__qt_molten_vk_homebrew_include_path}")
target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE
${__qt_molten_vk_homebrew_include_path})
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapVulkanHeaders DEFAULT_MSG Vulkan_INCLUDE_DIR)

14
cmake/FindWrapZLIB.cmake Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_zlib
FRIENDLY_PACKAGE_NAME "ZLIB"
WRAP_PACKAGE_TARGET "WrapZLIB::WrapZLIB"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapZLIB_FOUND"
BUNDLED_PACKAGE_NAME "BundledZLIB"
BUNDLED_PACKAGE_TARGET "BundledZLIB"
SYSTEM_PACKAGE_NAME "WrapSystemZLIB"
SYSTEM_PACKAGE_TARGET "WrapSystemZLIB::WrapSystemZLIB"
)

91
cmake/FindWrapZSTD.cmake Normal file
View File

@ -0,0 +1,91 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# FindZstd
# ---------
#
# Try to locate the Zstd library.
# If found, this will define the following variables:
#
# ``WrapZSTD_FOUND``
# True if the zstd library is available
# ``ZSTD_INCLUDE_DIRS``
# The zstd include directories
# ``ZSTD_LIBRARIES``
# The zstd libraries for linking
#
# If ``WrapZSTD_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``WrapZSTD::WrapZSTD``
# The zstd library
find_package(zstd CONFIG QUIET)
include(FindPackageHandleStandardArgs)
if(TARGET zstd::libzstd_static OR TARGET zstd::libzstd_shared)
find_package_handle_standard_args(WrapZSTD
REQUIRED_VARS zstd_VERSION VERSION_VAR zstd_VERSION)
if(TARGET zstd::libzstd_static)
set(zstdtargetsuffix "_static")
else()
set(zstdtargetsuffix "_shared")
endif()
if(NOT TARGET WrapZSTD::WrapZSTD)
add_library(WrapZSTD::WrapZSTD INTERFACE IMPORTED)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
INTERFACE_LINK_LIBRARIES "zstd::libzstd${zstdtargetsuffix}")
endif()
else()
find_package(PkgConfig QUIET)
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_LIBRARY_RELEASE
NAMES zstd zstd_static
HINTS ${PC_ZSTD_LIBDIR}
)
find_library(ZSTD_LIBRARY_DEBUG
NAMES zstdd zstd_staticd zstd zstd_static
HINTS ${PC_ZSTD_LIBDIR}
)
include(SelectLibraryConfigurations)
select_library_configurations(ZSTD)
if(PC_ZSTD_VERSION)
set(WrapZSTD_VERSION "${PC_ZSTD_VERSION}")
endif()
find_package_handle_standard_args(WrapZSTD
REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS
VERSION_VAR WrapZSTD_VERSION)
if(WrapZSTD_FOUND AND NOT TARGET WrapZSTD::WrapZSTD)
add_library(WrapZSTD::WrapZSTD UNKNOWN IMPORTED)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION "${ZSTD_LIBRARY}")
if(ZSTD_LIBRARY_RELEASE)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
endif()
if(ZSTD_LIBRARY_DEBUG)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
endif()
endif()
mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES ZSTD_LIBRARY_RELEASE ZSTD_LIBRARY_DEBUG)
endif()
include(FeatureSummary)
set_package_properties(WrapZSTD PROPERTIES
URL "https://github.com/facebook/zstd"
DESCRIPTION "ZSTD compression library")

View File

@ -0,0 +1,10 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(XKB_COMMON_X11 IMPORTED_TARGET "xkbcommon-x11>=0.4.1")
if (NOT TARGET PkgConfig::XKB_COMMON_X11)
set(XKB_COMMON_X11_FOUND 0)
endif()

14
cmake/FindXRender.cmake Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
if(NOT TARGET PkgConfig::XRender)
pkg_check_modules(XRender IMPORTED_TARGET "xrender")
if (NOT TARGET PkgConfig::XRender)
set(XRender_FOUND 0)
endif()
else()
set(XRender_FOUND 1)
endif()

View File

@ -0,0 +1,12 @@
{
"name": "${target}",
"repository": "${lower_case_project_name}",
"version": "${PROJECT_VERSION}",${extra_module_information}
"built_with": {${extra_build_information}
"compiler_id": "${CMAKE_CXX_COMPILER_ID}",
"compiler_target": "${CMAKE_CXX_COMPILER_TARGET}",
"compiler_version": "${CMAKE_CXX_COMPILER_VERSION}",
"cross_compiled": ${cross_compilation},
"target_system": "${CMAKE_SYSTEM_NAME}"
}
}

View File

@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
bindir=${prefix}/@INSTALL_BINDIR@
libexecdir=${prefix}/@INSTALL_LIBEXECDIR@
libdir=${prefix}/@INSTALL_LIBDIR@
includedir=${prefix}/@INSTALL_INCLUDEDIR@
$<$<BOOL:@contains_mkspecs@>:mkspecsdir=${prefix}/@INSTALL_MKSPECSDIR@>
$<1: >
Name: @pkgconfig_name@
Description: @pkgconfig_description@
Version: @PROJECT_VERSION@
Libs: $<$<NOT:@is_interface_library@>:-L${libdir} -l@pkgconfig_file@> @link_options@
Cflags: @include_dirs@ @compile_defs@
Requires: $<JOIN:$<REMOVE_DUPLICATES:@target_requires@>, >

View File

@ -0,0 +1,29 @@
@PACKAGE_INIT@
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
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@AdditionalTargetInfo.cmake")
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
endif()
endif()
foreach(extra_cmake_include @extra_cmake_includes@)
include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
endforeach()

View File

@ -0,0 +1,385 @@
macro(qt_internal_get_add_library_option_args option_args)
set(${option_args}
SHARED
STATIC
MODULE
INTERFACE
NO_UNITY_BUILD
)
endmacro()
# Helper to create a library using the public _qt_internal_add_library function.
#
# The difference to _qt_internal_add_library is that MODULE is replaced with STATIC in a static
# Qt build.
# Everything else is just prepation for option validating.
function(qt_internal_add_common_qt_library_helper target)
qt_internal_get_add_library_option_args(option_args)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${option_args}"
""
""
)
_qt_internal_validate_all_args_are_parsed(arg)
if(arg_SHARED)
set(arg_SHARED SHARED)
else()
set(arg_SHARED "")
endif()
if(arg_MODULE)
set(arg_MODULE MODULE)
else()
set(arg_MODULE "")
endif()
if(arg_STATIC)
set(arg_STATIC STATIC)
else()
set(arg_STATIC "")
endif()
if(arg_INTERFACE)
set(arg_INTERFACE INTERFACE)
else()
set(arg_INTERFACE "")
endif()
if(arg_MODULE AND NOT BUILD_SHARED_LIBS)
set(arg_MODULE STATIC)
endif()
_qt_internal_add_library(${target} ${arg_STATIC} ${arg_SHARED} ${arg_MODULE} ${arg_INTERFACE})
if(arg_NO_UNITY_BUILD)
set_property(TARGET "${target}" PROPERTY UNITY_BUILD OFF)
endif()
qt_internal_mark_as_internal_library(${target})
endfunction()
# Wrapper function to create a regular cmake target and forward all the
# arguments collected by the conversion script.
function(qt_internal_add_cmake_library target)
qt_internal_get_add_library_option_args(option_args)
set(single_args
OUTPUT_DIRECTORY
ARCHIVE_INSTALL_DIRECTORY
INSTALL_DIRECTORY
)
set(multi_args
${__default_private_args}
${__default_public_args}
)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${option_args}"
"${single_args}"
"${multi_args}"
)
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_validate_no_unity_build(arg)
qt_remove_args(library_helper_args
ARGS_TO_REMOVE
${single_args}
${multi_args}
ALL_ARGS
${option_args}
${single_args}
${multi_args}
ARGS
${ARGN}
)
qt_internal_add_common_qt_library_helper(${target} ${library_helper_args})
qt_skip_warnings_are_errors_when_repo_unclean("${target}")
if (arg_OUTPUT_DIRECTORY)
set_target_properties(${target} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
)
endif()
qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES}
SYSTEM_INCLUDE_DIRECTORIES
${arg_SYSTEM_INCLUDE_DIRECTORIES}
PUBLIC_INCLUDE_DIRECTORIES
${arg_PUBLIC_INCLUDE_DIRECTORIES}
PUBLIC_DEFINES
${arg_PUBLIC_DEFINES}
DEFINES
${arg_DEFINES}
PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
LIBRARIES ${arg_LIBRARIES} Qt::PlatformCommonInternal
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}
NO_UNITY_BUILD # Disabled by default
)
endfunction()
# This function replaces qmake's qt_helper_lib feature. It is intended to
# compile 3rdparty libraries as part of the build.
#
function(qt_internal_add_3rdparty_library target)
qt_internal_get_add_library_option_args(library_option_args)
set(option_args
EXCEPTIONS
INSTALL
SKIP_AUTOMOC
)
set(single_args
OUTPUT_DIRECTORY
QMAKE_LIB_NAME
)
set(multi_args
${__default_private_args}
${__default_public_args}
)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${library_option_args};${option_args}"
"${single_args}"
"${multi_args}"
)
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_validate_no_unity_build(arg)
qt_remove_args(library_helper_args
ARGS_TO_REMOVE
${option_args}
${single_args}
${multi_args}
ALL_ARGS
${library_option_args}
${option_args}
${single_args}
${multi_args}
ARGS
${ARGN}
)
qt_internal_add_common_qt_library_helper(${target} ${library_helper_args})
set_target_properties(${target} PROPERTIES
_qt_module_interface_name "${target}"
_qt_package_version "${PROJECT_VERSION}"
_qt_package_name "${INSTALL_CMAKE_NAMESPACE}${target}"
_qt_module_is_3rdparty_library TRUE
)
set(export_properties
"_qt_module_interface_name"
"_qt_package_version"
"_qt_package_name"
"_qt_module_is_3rdparty_library"
)
set_property(TARGET ${target}
APPEND PROPERTY
EXPORT_PROPERTIES "${export_properties}")
qt_internal_add_qt_repo_known_module(${target})
qt_internal_add_target_aliases(${target})
_qt_internal_apply_strict_cpp(${target})
qt_skip_warnings_are_errors_when_repo_unclean("${target}")
set_target_properties(${target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
RUNTIME_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
ARCHIVE_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
_qt_module_skip_depends_include TRUE
)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_is_3rdparty_library)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_skip_depends_include)
qt_handle_multi_config_output_dirs("${target}")
set_target_properties(${target} PROPERTIES
OUTPUT_NAME "${INSTALL_CMAKE_NAMESPACE}${target}"
)
if(NOT arg_INTERFACE)
qt_set_common_target_properties(${target})
endif()
if(NOT arg_SKIP_AUTOMOC)
qt_autogen_tools_initial_setup(${target})
endif()
if(NOT arg_EXCEPTIONS AND NOT arg_INTERFACE)
qt_internal_set_exceptions_flags("${target}" FALSE)
elseif(arg_EXCEPTIONS)
qt_internal_set_exceptions_flags("${target}" TRUE)
endif()
qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES}
PUBLIC_INCLUDE_DIRECTORIES
${arg_PUBLIC_INCLUDE_DIRECTORIES}
PUBLIC_DEFINES
${arg_PUBLIC_DEFINES}
DEFINES
${arg_DEFINES}
PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
LIBRARIES ${arg_LIBRARIES} Qt::PlatformModuleInternal
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
LINK_OPTIONS ${arg_LINK_OPTIONS}
PUBLIC_LINK_OPTIONS ${arg_PUBLIC_LINK_OPTIONS}
MOC_OPTIONS ${arg_MOC_OPTIONS}
ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
NO_UNITY_BUILD
)
if(NOT BUILD_SHARED_LIBS OR arg_INSTALL)
qt_generate_3rdparty_lib_pri_file("${target}" "${arg_QMAKE_LIB_NAME}" pri_file)
if(pri_file)
qt_install(FILES "${pri_file}" DESTINATION "${INSTALL_MKSPECSDIR}/modules")
endif()
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(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
configure_package_config_file(
"${QT_CMAKE_DIR}/Qt3rdPartyLibraryConfig.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}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${INSTALL_CMAKE_NAMESPACE}${target}"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
)
qt_install(FILES
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersionImpl.cmake"
DESTINATION "${config_install_dir}"
COMPONENT Devel
)
qt_install(TARGETS ${target}
EXPORT "${export_name}"
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
)
qt_install(EXPORT ${export_name}
NAMESPACE "${QT_CMAKE_EXPORT_NAMESPACE}::"
DESTINATION "${config_install_dir}"
)
qt_internal_export_additional_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}"
)
qt_internal_export_modern_cmake_config_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}"
)
set(debug_install_dir "${INSTALL_LIBDIR}")
if (MINGW)
set(debug_install_dir "${INSTALL_BINDIR}")
endif()
qt_enable_separate_debug_info(${target} "${debug_install_dir}")
qt_internal_install_pdb_files(${target} "${INSTALL_LIBDIR}")
endif()
if(BUILD_SHARED_LIBS AND MSVC)
set_target_properties(${target} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION OFF
)
endif()
endfunction()
function(qt_install_3rdparty_library_wrap_config_extra_file target)
if(TARGET "${target}")
set(use_bundled "ON")
else()
set(use_bundled "OFF")
endif()
set(QT_USE_BUNDLED_${target} "${use_bundled}" CACHE INTERNAL "")
set(extra_cmake_code "set(QT_USE_BUNDLED_${target} ${use_bundled} CACHE INTERNAL \"\")")
configure_file(
"${QT_CMAKE_DIR}/QtFindWrapConfigExtra.cmake.in"
"${QT_CONFIG_BUILD_DIR}/${INSTALL_CMAKE_NAMESPACE}/FindWrap${target}ConfigExtra.cmake"
@ONLY
)
qt_install(FILES
"${QT_CONFIG_BUILD_DIR}/${INSTALL_CMAKE_NAMESPACE}/FindWrap${target}ConfigExtra.cmake"
DESTINATION "${QT_CONFIG_INSTALL_DIR}/${INSTALL_CMAKE_NAMESPACE}"
COMPONENT Devel
)
endfunction()
# This function implements qmake's qt_helper_lib MODULE_EXT_HEADERS and MODULE_EXT_HEADERS_DIR features.
# It creates a header-only module exposing a subset or all headers of a 3rd-party library.
function(qt_internal_add_3rdparty_header_module target)
set(single_args
EXTERNAL_HEADERS_DIR
)
set(multi_args
EXTERNAL_HEADERS
)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${option_args}"
"${single_args}"
"${multi_args}"
)
_qt_internal_validate_all_args_are_parsed(arg)
qt_internal_add_module(${target}
INTERNAL_MODULE
HEADER_MODULE
NO_CONFIG_HEADER_FILE
EXTERNAL_HEADERS ${arg_EXTERNAL_HEADERS}
EXTERNAL_HEADERS_DIR ${arg_EXTERNAL_HEADERS_DIR}
)
set_target_properties(${target} PROPERTIES
_qt_module_is_3rdparty_header_library TRUE
_qt_module_skip_depends_include TRUE
)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_is_3rdparty_header_library)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_skip_depends_include)
endfunction()

View File

@ -0,0 +1,278 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#
# 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_internal_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."
)
define_property(TARGET
PROPERTY
QT_ANDROID_FEATURES
BRIEF_DOCS
"Qt Module android feature list."
FULL_DOCS
"Qt Module android feature list."
)
define_property(TARGET
PROPERTY
QT_ANDROID_ABIS
BRIEF_DOCS
"List of ABIs that the target packages are built with."
FULL_DOCS
"List of ABIs that the target packages are built with."
)
function(qt_internal_android_dependencies_content target file_content_out)
get_target_property(arg_JAR_DEPENDENCIES ${target} QT_ANDROID_JAR_DEPENDENCIES)
get_target_property(arg_BUNDLED_JAR_DEPENDENCIES ${target} QT_ANDROID_BUNDLED_JAR_DEPENDENCIES)
get_target_property(arg_LIB_DEPENDENCIES ${target} QT_ANDROID_LIB_DEPENDENCIES)
get_target_property(arg_LIB_DEPENDENCY_REPLACEMENTS ${target} QT_ANDROID_LIB_DEPENDENCY_REPLACEMENTS)
get_target_property(arg_BUNDLED_FILES ${target} QT_ANDROID_BUNDLED_FILES)
get_target_property(arg_PERMISSIONS ${target} QT_ANDROID_PERMISSIONS)
get_target_property(arg_FEATURES ${target} QT_ANDROID_FEATURES)
if ((NOT arg_JAR_DEPENDENCIES)
AND (NOT arg_BUNDLED_JAR_DEPENDENCIES)
AND (NOT arg_LIB_DEPENDENCIES)
AND (NOT arg_LIB_DEPENDENCY_REPLACEMENTS)
AND (NOT arg_BUNDLED_FILES)
AND (NOT arg_PERMISSIONS)
AND (NOT arg_FEATURES))
# None of the values were set, so there's nothing to do
return()
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()
set(file_contents "")
# 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()
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${jar_file} jar_file_unix_path)
string(APPEND file_contents "<jar file=\"${jar_file_unix_path}\" ${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_class)
if (init_class)
set(init_class "initClass=\"${init_class}\"")
endif()
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${bundle_file} jar_bundle_unix_path)
string(APPEND file_contents
"<jar bundling=\"1\" file=\"${jar_bundle_unix_path}\" ${init_class} />\n")
endforeach()
endif()
# Lib Dependencies
if(arg_LIB_DEPENDENCIES)
foreach(lib IN LISTS arg_LIB_DEPENDENCIES)
string(REPLACE ".so" "_${CMAKE_ANDROID_ARCH_ABI}.so" lib ${lib})
section(${lib} ":" lib_file lib_extends)
if (lib_extends)
set(lib_extends "extends=\"${lib_extends}\"")
endif()
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${lib_file} lib_file_unix_path)
string(APPEND file_contents "<lib file=\"${lib_file_unix_path}\" ${lib_extends} />\n")
endforeach()
endif()
# Lib Dependencies Replacements
if(arg_LIB_DEPENDENCY_REPLACEMENTS)
foreach(lib IN LISTS arg_LIB_DEPENDENCY_REPLACEMENTS)
string(REPLACE ".so" "_${CMAKE_ANDROID_ARCH_ABI}.so" lib ${lib})
section(${lib} ":" lib_file lib_replacement)
if (lib_replacement)
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${lib_replacement} lib_replacement_unix_path)
set(lib_replacement "replaces=\"${lib_replacement_unix_path}\"")
endif()
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${lib_file} lib_file_unix_path)
string(APPEND file_contents
"<lib file=\"${lib_file_unix_path}\" ${lib_replacement} />\n")
endforeach()
endif()
# Bundled files
if(arg_BUNDLED_FILES)
foreach(bundled_file IN LISTS arg_BUNDLED_FILES)
# Use unix path to allow using files on any host platform.
file(TO_CMAKE_PATH ${bundled_file} file_unix_path)
string(APPEND file_contents "<bundled file=\"${file_unix_path}\" />\n")
endforeach()
endif()
# Android Permissions
if(arg_PERMISSIONS)
foreach(permission IN LISTS arg_PERMISSIONS)
string(APPEND file_contents "<permission name=\"${permission}\" />\n")
endforeach()
endif()
# Android Features
if(arg_FEATURES)
foreach(feature IN LISTS arg_FEATURES)
string(APPEND file_contents "<feature name=\"${feature}\" />\n")
endforeach()
endif()
set(${file_content_out} ${file_contents} PARENT_SCOPE)
endfunction()
# Generate Qt Module -android-dependencies.xml required by the
# androiddeploytoolqt to successfully copy all the plugins and other dependent
# items into the APK
function(qt_internal_android_dependencies target)
get_target_property(target_type "${target}" TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
return()
endif()
# Get plugins for the current module
get_target_property(module_plugin_types ${target} MODULE_PLUGIN_TYPES)
# Get depends for the current module
qt_internal_android_dependencies_content(${target} file_contents)
# Get plugins from the module's plugin types and get their dependencies
foreach(plugin ${QT_KNOWN_PLUGINS})
get_target_property(iter_known_plugin_type ${plugin} QT_PLUGIN_TYPE)
foreach(plugin_type ${module_plugin_types})
if (plugin_type STREQUAL iter_known_plugin_type)
qt_internal_android_dependencies_content(${plugin} plugin_file_contents)
string(APPEND file_contents ${plugin_file_contents})
endif()
endforeach()
endforeach()
if ((NOT module_plugin_types)
AND (NOT file_contents))
# 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()
string(PREPEND file_contents "<lib name=\"${target_name}_${CMAKE_ANDROID_ARCH_ABI}\"><depends>\n")
string(PREPEND file_contents "<rules><dependencies>\n")
# Module plugins
if(module_plugin_types)
foreach(plugin IN LISTS module_plugin_types)
string(APPEND file_contents "<bundled file=\"${INSTALL_PLUGINSDIR}/${plugin}\" />\n")
endforeach()
endif()
string(APPEND file_contents "</depends></lib>\n")
string(APPEND file_contents "</dependencies></rules>")
qt_path_join(dependency_file "${QT_BUILD_DIR}" "${INSTALL_LIBDIR}" "${target_name}_${CMAKE_ANDROID_ARCH_ABI}-android-dependencies.xml")
file(WRITE ${dependency_file} ${file_contents})
get_target_property(target_install_dir ${target} QT_ANDROID_MODULE_INSTALL_DIR)
if (NOT target_install_dir)
message(SEND_ERROR "qt_internal_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()

147
cmake/QtAppHelpers.cmake Normal file
View File

@ -0,0 +1,147 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# This function creates a CMake target for a Qt internal app.
# Such projects had a load(qt_app) command.
function(qt_internal_add_app target)
cmake_parse_arguments(PARSE_ARGV 1 arg
"NO_INSTALL;INSTALL_VERSIONED_LINK;EXCEPTIONS;NO_UNITY_BUILD"
"${__default_target_info_args};INSTALL_DIR"
"${__default_private_args};PUBLIC_LIBRARIES"
)
_qt_internal_validate_all_args_are_parsed(arg)
set(exceptions "")
if(arg_EXCEPTIONS)
set(exceptions EXCEPTIONS)
endif()
if(DEFINED arg_INSTALL_DIR)
set(forward_install_dir INSTALL_DIRECTORY ${arg_INSTALL_DIR})
else()
set(forward_install_dir "")
set(arg_INSTALL_DIR ${INSTALL_BINDIR})
endif()
set(output_directory "${QT_BUILD_DIR}/${arg_INSTALL_DIR}")
set(no_install "")
if(arg_NO_INSTALL)
set(no_install NO_INSTALL)
endif()
if(arg_PUBLIC_LIBRARIES)
message(WARNING
"qt_internal_add_app's PUBLIC_LIBRARIES option is deprecated, and will be removed in "
"a future Qt version. Use the LIBRARIES option instead.")
endif()
qt_internal_library_deprecation_level(deprecation_define)
if(arg_NO_UNITY_BUILD)
set(arg_NO_UNITY_BUILD "NO_UNITY_BUILD")
else()
set(arg_NO_UNITY_BUILD "")
endif()
qt_internal_add_executable("${target}"
QT_APP
DELAY_RC
DELAY_TARGET_INFO
OUTPUT_DIRECTORY "${output_directory}"
${exceptions}
${no_install}
${arg_NO_UNITY_BUILD}
${forward_install_dir}
SOURCES ${arg_SOURCES}
NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES}
DEFINES
${arg_DEFINES}
${deprecation_define}
LIBRARIES
${arg_LIBRARIES}
${arg_PUBLIC_LIBRARIES}
Qt::PlatformAppInternal
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}
TARGET_VERSION ${arg_TARGET_VERSION}
TARGET_PRODUCT ${arg_TARGET_PRODUCT}
TARGET_DESCRIPTION ${arg_TARGET_DESCRIPTION}
TARGET_COMPANY ${arg_TARGET_COMPANY}
TARGET_COPYRIGHT ${arg_TARGET_COPYRIGHT}
# If you are putting anything after these, make sure that
# qt_set_target_info_properties knows how to process them
)
qt_internal_add_target_aliases("${target}")
_qt_internal_apply_strict_cpp("${target}")
qt_internal_adjust_main_config_runtime_output_dir("${target}" "${output_directory}")
# To mimic the default behaviors of qt_app.prf, we by default enable GUI Windows applications,
# but don't enable macOS bundles.
# Bundles are enabled in a separate set_target_properties call if an Info.plist file
# is provided.
# Similarly, the Windows GUI flag is disabled in a separate call
# if CONFIG += console was encountered during conversion.
set_target_properties("${target}" PROPERTIES WIN32_EXECUTABLE TRUE)
# Consider every app as user facing tool.
set_property(GLOBAL APPEND PROPERTY QT_USER_FACING_TOOL_TARGETS ${target})
# Install versioned link if requested.
if(NOT arg_NO_INSTALL AND arg_INSTALL_VERSIONED_LINK)
qt_internal_install_versioned_link(WORKING_DIRECTORY "${arg_INSTALL_DIR}"
TARGETS ${target})
endif()
qt_add_list_file_finalizer(qt_internal_finalize_app ${target})
endfunction()
function(qt_internal_get_title_case value out_var)
if(NOT value)
set(${out_var} "" PARENT_SCOPE)
return()
endif()
string(SUBSTRING "${value}" 0 1 first_char)
string(TOUPPER "${first_char}" first_char_upper)
string(SUBSTRING "${value}" 1 -1 rest_of_value)
set(title_value "${first_char_upper}${rest_of_value}")
set(${out_var} "${title_value}" PARENT_SCOPE)
endfunction()
function(qt_internal_update_app_target_info_properties target)
# First update the delayed properties with any values that might have been set after the
# qt_internal_add_app() call.
qt_internal_update_delayed_target_info_properties(${target})
# Set defaults in case if no values were set.
get_target_property(target_version ${target} QT_DELAYED_TARGET_VERSION)
if(NOT target_version)
set_target_properties(${target} PROPERTIES QT_DELAYED_TARGET_VERSION "${PROJECT_VERSION}")
endif()
get_target_property(target_description ${target} QT_DELAYED_TARGET_DESCRIPTION)
if(NOT target_description)
qt_internal_get_title_case("${target}" upper_name)
set_target_properties(${target} PROPERTIES QT_DELAYED_TARGET_DESCRIPTION "Qt ${upper_name}")
endif()
# Finally set the final values.
qt_internal_set_target_info_properties_from_delayed_properties("${target}")
endfunction()
function(qt_internal_finalize_app target)
qt_internal_update_app_target_info_properties("${target}")
if(WIN32)
_qt_internal_generate_win32_rc_file("${target}")
endif()
# Rpaths need to be applied in the finalizer, because the MACOSX_BUNDLE property might be
# set after a qt_internal_add_app call.
qt_apply_rpaths(TARGET "${target}" INSTALL_PATH "${INSTALL_BINDIR}" RELATIVE_RPATH)
qt_internal_apply_staging_prefix_build_rpath_workaround()
endfunction()

497
cmake/QtAutoDetect.cmake Normal file
View File

@ -0,0 +1,497 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#
# Collection of auto detection routines to improve the user experience when
# building Qt from source.
#
# Make sure to not run detection when building standalone tests, because the detection was already
# done when initially configuring qtbase.
function(qt_internal_ensure_static_qt_config)
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Qt statically or dynamically" FORCE)
endif()
if(BUILD_SHARED_LIBS)
message(FATAL_ERROR
"Building Qt for ${CMAKE_SYSTEM_NAME} as shared libraries is not supported.")
endif()
endfunction()
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicWasmToolchainHelpers.cmake")
function(qt_auto_detect_wasm)
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "wasm-emscripten" OR "${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "wasm-emscripten-64")
if (NOT DEFINED ENV{EMSDK})
message(FATAL_ERROR
"Can't find an Emscripten SDK! Make sure the EMSDK environment variable is "
"available by activating and sourcing the emscripten sdk. Also ensure emcc is in "
"your path.")
endif()
if(NOT DEFINED QT_AUTODETECT_WASM_IS_DONE)
message(STATUS "Extracting Emscripten SDK info from EMSDK env var: $ENV{EMSDK}")
__qt_internal_get_emroot_path_suffix_from_emsdk_env(EMROOT_PATH)
__qt_internal_query_emsdk_version("${EMROOT_PATH}" TRUE CMAKE_EMSDK_REGEX_VERSION)
set(EMCC_VERSION "${CMAKE_EMSDK_REGEX_VERSION}" CACHE STRING INTERNAL FORCE)
if(NOT DEFINED BUILD_SHARED_LIBS)
qt_internal_ensure_static_qt_config()
endif()
# Find toolchain file
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
__qt_internal_get_emscripten_cmake_toolchain_file_path_from_emsdk_env(
"${EMROOT_PATH}" wasm_toolchain_file)
set(CMAKE_TOOLCHAIN_FILE "${wasm_toolchain_file}" CACHE STRING "" FORCE)
endif()
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
message(STATUS
"Emscripten ${EMCC_VERSION} toolchain file detected at ${CMAKE_TOOLCHAIN_FILE}")
else()
__qt_internal_show_error_no_emscripten_toolchain_file_found_when_building_qt()
endif()
__qt_internal_get_emcc_recommended_version(recommended_version)
set(QT_EMCC_RECOMMENDED_VERSION "${recommended_version}" CACHE STRING INTERNAL FORCE)
set(QT_AUTODETECT_WASM_IS_DONE TRUE CACHE BOOL "")
else()
message(STATUS
"Reusing cached Emscripten ${EMCC_VERSION} toolchain file detected at "
"${CMAKE_TOOLCHAIN_FILE}")
endif()
endif()
endfunction()
function(qt_auto_detect_cmake_generator)
if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT QT_SILENCE_CMAKE_GENERATOR_WARNING)
message(WARNING
"The officially supported CMake generator for building Qt is Ninja. "
"You are using: '${CMAKE_GENERATOR}' instead. "
"Thus, you might encounter issues. Use at your own risk.")
endif()
endfunction()
function(qt_auto_detect_android)
# We assume an Android build if any of the ANDROID_* cache variables are set.
if(DEFINED ANDROID_SDK_ROOT
OR DEFINED ANDROID_NDK_ROOT
OR DEFINED ANDROID_ABI
OR DEFINED ANDROID_NATIVE_ABI_LEVEL
OR DEFINED ANDROID_STL)
set(android_detected TRUE)
else()
set(android_detected FALSE)
endif()
# Auto-detect NDK root
if(NOT DEFINED ANDROID_NDK_ROOT AND DEFINED ANDROID_SDK_ROOT)
file(GLOB ndk_versions LIST_DIRECTORIES true RELATIVE "${ANDROID_SDK_ROOT}/ndk"
"${ANDROID_SDK_ROOT}/ndk/*")
unset(ndk_root)
if(NOT ndk_versions STREQUAL "")
# Use the NDK with the highest version number.
if(CMAKE_VERSION VERSION_LESS 3.18)
list(SORT ndk_versions)
list(REVERSE ndk_versions)
else()
list(SORT ndk_versions COMPARE NATURAL ORDER DESCENDING)
endif()
list(GET ndk_versions 0 ndk_root)
string(PREPEND ndk_root "${ANDROID_SDK_ROOT}/ndk/")
else()
# Fallback: use the deprecated "ndk-bundle" directory within the SDK root.
set(ndk_root "${ANDROID_SDK_ROOT}/ndk-bundle")
if(NOT IS_DIRECTORY "${ndk_root}")
unset(ndk_root)
endif()
endif()
if(DEFINED ndk_root)
message(STATUS "Android NDK detected: ${ndk_root}")
set(ANDROID_NDK_ROOT "${ndk_root}" CACHE STRING "")
endif()
endif()
# Auto-detect toolchain file
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ANDROID_NDK_ROOT)
set(toolchain_file "${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake")
if(EXISTS "${toolchain_file}")
message(STATUS "Android toolchain file within NDK detected: ${toolchain_file}")
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" CACHE STRING "")
else()
message(FATAL_ERROR "Cannot find the toolchain file '${toolchain_file}'. "
"Please specify the toolchain file with -DCMAKE_TOOLCHAIN_FILE=<file>.")
endif()
endif()
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND android_detected)
message(FATAL_ERROR "An Android build was requested, but no Android toolchain file was "
"specified nor detected.")
endif()
if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID)
# Peek into the toolchain file and check if it looks like an Android one.
if(NOT android_detected)
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)
endif()
endif()
if(android_detected)
message(STATUS "Android build detected, checking configuration defaults...")
# ANDROID_NATIVE_API_LEVEL is an just an alias to ANDROID_PLATFORM, check for both
if(NOT DEFINED ANDROID_PLATFORM AND NOT DEFINED ANDROID_NATIVE_API_LEVEL)
message(STATUS "Neither ANDROID_PLATFORM nor ANDROID_NATIVE_API_LEVEL were specified, using API level 23 as default")
set(ANDROID_PLATFORM "android-23" CACHE STRING "")
set(ANDROID_NATIVE_API_LEVEL 23 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 build detected")
endif()
endfunction()
function(qt_auto_detect_vcpkg)
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)
message(STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}")
if(DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
message(STATUS "VCPKG_CHAINLOAD_TOOLCHAIN_FILE is: ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
endif()
endif()
endfunction()
function(qt_auto_detect_ios)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
message(STATUS "Using internal CMake ${CMAKE_SYSTEM_NAME} toolchain file.")
# The QT_UIKIT_SDK check simulates the input.sdk condition for simulator_and_device in
# configure.json.
# If the variable is explicitly provided, assume simulator_and_device to be off.
if(QT_UIKIT_SDK)
set(simulator_and_device OFF)
else()
# Default to simulator_and_device when an explicit sdk is not requested.
# Requires CMake 3.17.0+.
set(simulator_and_device ON)
endif()
message(STATUS "simulator_and_device set to: \"${simulator_and_device}\".")
# Choose relevant architectures.
# Using a non Xcode generator requires explicit setting of the
# architectures, otherwise compilation fails with unknown defines.
if(simulator_and_device)
set(osx_architectures "arm64;x86_64")
elseif(QT_UIKIT_SDK STREQUAL "iphoneos")
set(osx_architectures "arm64")
elseif(QT_UIKIT_SDK STREQUAL "iphonesimulator")
set(osx_architectures "x86_64")
else()
if(NOT DEFINED QT_UIKIT_SDK)
message(FATAL_ERROR "Please provide a value for -DQT_UIKIT_SDK."
" Possible values: iphoneos, iphonesimulator.")
else()
message(FATAL_ERROR
"Unknown SDK argument given to QT_UIKIT_SDK: ${QT_UIKIT_SDK}.")
endif()
endif()
# For non simulator_and_device builds, we need to explicitly set the SYSROOT aka the sdk
# value.
if(QT_UIKIT_SDK)
set(CMAKE_OSX_SYSROOT "${QT_UIKIT_SDK}" CACHE STRING "")
endif()
set(CMAKE_OSX_ARCHITECTURES "${osx_architectures}" CACHE STRING "")
qt_internal_ensure_static_qt_config()
# Disable qt rpaths for iOS, just like mkspecs/common/uikit.conf does, due to those
# bundles not being able to use paths outside the app bundle. Not sure this is strictly
# needed though.
set(QT_DISABLE_RPATH "OFF" CACHE BOOL "Disable automatic Qt rpath handling." FORCE)
endif()
endfunction()
function(qt_auto_detect_cmake_config)
if(CMAKE_CONFIGURATION_TYPES)
# Allow users to specify this option.
if(NOT QT_MULTI_CONFIG_FIRST_CONFIG)
list(GET CMAKE_CONFIGURATION_TYPES 0 first_config_type)
set(QT_MULTI_CONFIG_FIRST_CONFIG "${first_config_type}")
set(QT_MULTI_CONFIG_FIRST_CONFIG "${first_config_type}" PARENT_SCOPE)
endif()
set(CMAKE_TRY_COMPILE_CONFIGURATION "${QT_MULTI_CONFIG_FIRST_CONFIG}" PARENT_SCOPE)
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
# Create build-<config>.ninja files for all specified configurations.
set(CMAKE_CROSS_CONFIGS "all" CACHE STRING "")
# The configuration that will be considered the main one (for example when
# configuring standalone tests with a single-config generator like Ninja).
set(CMAKE_DEFAULT_BUILD_TYPE "${QT_MULTI_CONFIG_FIRST_CONFIG}" CACHE STRING "")
# By default when ninja is called without parameters, it will build all configurations.
set(CMAKE_DEFAULT_CONFIGS "all" CACHE STRING "")
endif()
endif()
endfunction()
function(qt_auto_detect_cyclic_toolchain)
if(CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "/qt.toolchain.cmake$")
message(FATAL_ERROR
"Woah there! You can't use the Qt generated qt.toolchain.cmake file to configure "
"qtbase, because that will create a toolchain file that includes itself!\n"
"Did you accidentally use qt-cmake to configure qtbase? Make sure to remove the "
"CMakeCache.txt file, and configure qtbase with 'cmake' instead of 'qt-cmake'.")
endif()
endfunction()
function(qt_internal_get_darwin_sdk_version out_var)
if(APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(sdk_name "iphoneos")
else()
# Default to macOS
set(sdk_name "macosx")
endif()
set(xcrun_version_arg "--show-sdk-version")
execute_process(COMMAND /usr/bin/xcrun --sdk ${sdk_name} ${xcrun_version_arg}
OUTPUT_VARIABLE sdk_version
ERROR_VARIABLE xcrun_error)
if(NOT sdk_version)
message(FATAL_ERROR
"Can't determine darwin ${sdk_name} SDK version. Error: ${xcrun_error}")
endif()
string(STRIP "${sdk_version}" sdk_version)
set(${out_var} "${sdk_version}" PARENT_SCOPE)
endif()
endfunction()
function(qt_internal_get_xcode_version out_var)
if(APPLE)
execute_process(COMMAND /usr/bin/xcrun xcodebuild -version
OUTPUT_VARIABLE xcode_version
ERROR_VARIABLE xcrun_error)
string(REPLACE "\n" " " xcode_version "${xcode_version}")
string(STRIP "${xcode_version}" xcode_version)
set(${out_var} "${xcode_version}" PARENT_SCOPE)
endif()
endfunction()
function(qt_auto_detect_darwin)
if(APPLE)
# If no CMAKE_OSX_DEPLOYMENT_TARGET is provided, default to a value that Qt defines.
# This replicates the behavior in mkspecs/common/macx.conf where
# QMAKE_MACOSX_DEPLOYMENT_TARGET is set.
set(description
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
if(NOT CMAKE_SYSTEM_NAME)
# macOS
set(version "11.0")
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(version "14.0")
endif()
if(version)
set(CMAKE_OSX_DEPLOYMENT_TARGET "${version}" CACHE STRING "${description}")
endif()
endif()
qt_internal_get_darwin_sdk_version(darwin_sdk_version)
set(QT_MAC_SDK_VERSION "${darwin_sdk_version}" CACHE STRING "Darwin SDK version.")
qt_internal_get_xcode_version(xcode_version)
set(QT_MAC_XCODE_VERSION "${xcode_version}" CACHE STRING "Xcode version.")
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
if(NOT CMAKE_SYSTEM_NAME STREQUAL iOS AND arch_count GREATER 0)
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
if(arch STREQUAL "arm64e")
message(WARNING "Applications built against an arm64e Qt architecture will "
"likely fail to run on Apple Silicon. Consider targeting "
"'arm64' instead.")
endif()
endforeach()
endif()
endif()
endfunction()
function(qt_auto_detect_macos_universal)
if(APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL iOS)
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
set(is_universal "OFF")
if(arch_count GREATER 1)
set(is_universal "ON")
endif()
set(QT_IS_MACOS_UNIVERSAL "${is_universal}" CACHE INTERNAL "Build universal Qt for macOS")
endif()
endfunction()
function(qt_auto_detect_pch)
set(default_value "ON")
if(CMAKE_OSX_ARCHITECTURES AND CMAKE_VERSION VERSION_LESS 3.18.0 AND NOT QT_FORCE_PCH)
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
# CMake versions lower than 3.18 don't support PCH when multiple architectures are set.
# This is the case for simulator_and_device builds.
if(arch_count GREATER 1)
set(default_value "OFF")
message(WARNING "PCH support disabled due to usage of multiple architectures.")
endif()
endif()
option(BUILD_WITH_PCH "Build Qt using precompiled headers?" "${default_value}")
endfunction()
function(qt_auto_detect_win32_arm)
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "win32-arm64-msvc")
set(CMAKE_SYSTEM_NAME "Windows" CACHE STRING "")
set(CMAKE_SYSTEM_VERSION "10" CACHE STRING "")
set(CMAKE_SYSTEM_PROCESSOR "arm64" CACHE STRING "")
endif()
endfunction()
function(qt_auto_detect_linux_x86)
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "linux-g++-32" AND NOT QT_NO_AUTO_DETECT_LINUX_X86)
# Add flag to ensure code is compiled for 32bit x86 ABI aka i386 or its flavors.
set(__qt_toolchain_common_flags_init "-m32")
if(NOT QT_NO_OVERRIDE_LANG_FLAGS_INIT)
set(CMAKE_C_FLAGS_INIT "${__qt_toolchain_common_flags_init}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_INIT "${__qt_toolchain_common_flags_init}" PARENT_SCOPE)
set(CMAKE_ASM_FLAGS_INIT "${__qt_toolchain_common_flags_init}" PARENT_SCOPE)
endif()
# Each distro places arch-specific libraries according to its own file system layout.
#
# https://wiki.debian.org/Multiarch/TheCaseForMultiarch
# https://wiki.ubuntu.com/MultiarchSpec
# https://wiki.gentoo.org/wiki/Project:AMD64/Multilib_layout
# https://wiki.archlinux.org/title/official_repositories#multilib
# https://documentation.suse.com/sles/15-SP3/html/SLES-all/cha-64bit.html
# https://pilotlogic.com/sitejoom/index.php/wiki?id=398
# https://unix.stackexchange.com/questions/458069/multilib-and-multiarch
#
# CMake can usually find 32 bit libraries just fine on its own.
# find_library will use prefixes from CMAKE_PREFIX_PATH / CMAKE_SYSTEM_PREFIX_PATH
# and add arch-specific lib folders like 'lib/i386-linux-gnu' on debian based systems
# or lib32/lib64 on other distros.
# The problem is that if no 32 bit library is found, a 64 bit one might get picked up.
# That's why we need to specify additional ignore paths.
#
# The paths used in the code below are Ubuntu specific.
# You can opt out of using them if you are using a different distro, but then you need to
# specify appropriate paths yourself in your own CMake toolchain file.
#
# Note that to absolutely ensure no x86_64 library is picked up on a multiarch /
# multilib-enabled system, you might need to specify extra directories in
# CMAKE_INGORE_PATH for each sub-directory containing a library.
#
# For example to exclude /usr/lib/x86_64-linux-gnu/mit-krb5/libgssapi_krb5.so
# you need to add /usr/lib/x86_64-linux-gnu/mit-krb5 explicitly to CMAKE_IGNORE_PATH.
# Adding just /usr/lib/x86_64-linux-gnu to either CMAKE_IGNORE_PATH or
# CMAKE_IGNORE_PREFIX_PATH is not enough.
#
# Another consideration are results returned by CMake's pkg_check_modules which uses
# pkg-config.
# CMAKE_IGNORE_PATH is not read by pkg_check_modules, but CMAKE_PREFIX_PATH
# values are passed as additional prefixes to look for .pc files, IN ADDITION to the default
# prefixes searched by pkg-config of each specific distro.
# For example on Ubuntu, the default searched paths on an x86_64 host are:
# /usr/local/lib/x86_64-linux-gnu/pkgconfig
# /usr/local/lib/pkgconfig
# /usr/local/share/pkgconfig
# /usr/lib/x86_64-linux-gnu/pkgconfig
# /usr/lib/pkgconfig
# /usr/share/pkgconfig
# To ensure the x86_64 packages are not picked up, the PKG_CONFIG_LIBDIR environment
# variable can be overridden with an explicit list of prefixes.
# Again, the paths below are Ubuntu specific.
if(NOT QT_NO_OVERRIDE_CMAKE_IGNORE_PATH)
set(linux_x86_ignore_path "/usr/lib/x86_64-linux-gnu;/lib/x86_64-linux-gnu")
set(CMAKE_IGNORE_PATH "${linux_x86_ignore_path}" PARENT_SCOPE)
set_property(GLOBAL PROPERTY
_qt_internal_linux_x86_ignore_path "${linux_x86_ignore_path}")
endif()
if(NOT QT_NO_OVERRIDE_PKG_CONFIG_LIBDIR)
set(pc_config_libdir "")
list(APPEND pc_config_libdir "/usr/local/lib/i386-linux-gnu/pkgconfig")
list(APPEND pc_config_libdir "/usr/local/lib/pkgconfig")
list(APPEND pc_config_libdir "/usr/local/share/pkgconfig")
list(APPEND pc_config_libdir "/usr/lib/i386-linux-gnu/pkgconfig")
list(APPEND pc_config_libdir "/usr/lib/pkgconfig")
list(APPEND pc_config_libdir "/usr/share/pkgconfig")
list(JOIN pc_config_libdir ":" pc_config_libdir)
set_property(GLOBAL PROPERTY
_qt_internal_linux_x86_pc_config_libdir "${pc_config_libdir}")
# Overrides the default prefix list.
set(ENV{PKG_CONFIG_LIBDIR} "${pc_config_libdir}")
# Overrides the additional prefixes list.
set(ENV{PKG_CONFIG_DIR} "")
endif()
endif()
endfunction()
function(qt_auto_detect_integrity)
if(
# Qt's custom CMake toolchain file sets this value.
CMAKE_SYSTEM_NAME STREQUAL "Integrity" OR
# Upstream CMake expects this name, but we don't currently use it in Qt.
CMAKE_SYSTEM_NAME STREQUAL "GHS-MULTI"
)
qt_internal_ensure_static_qt_config()
endif()
endfunction()
# Let CMake load our custom platform modules.
# CMake-provided platform modules take precedence.
if(NOT QT_AVOID_CUSTOM_PLATFORM_MODULES)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/platforms")
endif()
qt_auto_detect_cmake_generator()
qt_auto_detect_cyclic_toolchain()
qt_auto_detect_cmake_config()
qt_auto_detect_darwin()
qt_auto_detect_macos_universal()
qt_auto_detect_ios()
qt_auto_detect_android()
qt_auto_detect_vcpkg()
qt_auto_detect_pch()
qt_auto_detect_wasm()
qt_auto_detect_win32_arm()
qt_auto_detect_linux_x86()
qt_auto_detect_integrity()

View File

@ -0,0 +1,184 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Initial autogen setup for a target to specify certain CMake properties which are common
# to all autogen tools. Also enable AUTOMOC by default.
function(qt_autogen_tools_initial_setup target)
set_property(TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set_property(TARGET "${target}" APPEND PROPERTY COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION)
set_directory_properties(PROPERTIES
QT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
QT_VERSION_MINOR ${PROJECT_VERSION_MINOR}
QT_VERSION_PATCH ${PROJECT_VERSION_PATCH}
)
qt_enable_autogen_tool(${target} "moc" ON)
endfunction()
# Enables or disables an autogen tool like moc, uic or rcc on ${target}.
function(qt_enable_autogen_tool target tool enable)
string(TOUPPER "${tool}" captitalAutogenTool)
get_target_property(tool_enabled ${target} AUTO${captitalAutogenTool})
get_target_property(autogen_target_depends ${target} AUTOGEN_TARGET_DEPENDS)
if(NOT autogen_target_depends)
set(autogen_target_depends "")
endif()
set(tool_executable "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::${tool}>")
set(tool_target_name ${QT_CMAKE_EXPORT_NAMESPACE}::${tool})
if(enable)
list(APPEND autogen_target_depends ${tool_target_name})
else()
list(REMOVE_ITEM autogen_target_depends ${tool_target_name})
endif()
# f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96 in qtbase introduced a new macro
# that the moc scanner has to look for. Inform the CMake moc scanner about it.
if(tool STREQUAL "moc" AND enable)
set_target_properties("${target}" PROPERTIES
AUTOMOC_MACRO_NAMES "Q_OBJECT;Q_GADGET;Q_GADGET_EXPORT;Q_NAMESPACE;Q_NAMESPACE_EXPORT;Q_ENUM_NS")
if (TARGET Qt::Platform)
get_target_property(_abi_tag Qt::Platform qt_libcpp_abi_tag)
if (_abi_tag)
set_property(TARGET "${target}" APPEND PROPERTY
AUTOMOC_MOC_OPTIONS --libcpp-abi-version "${_abi_tag}"
)
endif()
endif()
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)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "${__default_private_args}")
_qt_internal_validate_all_args_are_parsed(arg)
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()
# Complete manual moc invocation with full control.
# Use AUTOMOC whenever possible.
# INCLUDE_DIRECTORIES specifies a list of include directories used by 'moc'.
# INCLUDE_DIRECTORY_TARGETS specifies a list of targets to extract the INTERFACE_INCLUDE_DIRECTORIES
# property and use it as the 'moc' include directories.
function(qt_manual_moc result)
cmake_parse_arguments(arg
""
"OUTPUT_MOC_JSON_FILES"
"FLAGS;INCLUDE_DIRECTORIES;INCLUDE_DIRECTORY_TARGETS"
${ARGN})
set(moc_files)
set(metatypes_json_list)
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:$<CONFIG>>:_$<CONFIG>>")
set(moc_parameters ${arg_FLAGS} -o "${outfile}" "${infile}")
foreach(dir IN ITEMS ${arg_INCLUDE_DIRECTORIES})
list(APPEND moc_parameters
"-I\n${dir}")
endforeach()
foreach(dep IN ITEMS ${arg_INCLUDE_DIRECTORY_TARGETS})
set(include_expr "$<TARGET_PROPERTY:${dep},INTERFACE_INCLUDE_DIRECTORIES>")
list(APPEND moc_parameters
"$<$<BOOL:${include_expr}>:-I\n$<JOIN:${include_expr},\n-I\n>>")
if(APPLE AND TARGET ${dep})
get_target_property(is_versionless ${dep} _qt_is_versionless_target)
if(is_versionless)
string(REGEX REPLACE "^Qt::(.*)" "\\1" dep "${dep}")
set(dep "${QT_CMAKE_EXPORT_NAMESPACE}::${dep}")
endif()
get_target_property(alias_dep ${dep} ALIASED_TARGET)
if(alias_dep)
set(dep ${alias_dep})
endif()
get_target_property(loc ${dep} IMPORTED_LOCATION)
string(REGEX REPLACE "(.*)/Qt[^/]+\\.framework.*" "\\1" loc "${loc}")
if(loc)
list(APPEND moc_parameters "\n-F\n${loc}\n")
endif()
endif()
endforeach()
set(metatypes_byproducts)
if (arg_OUTPUT_MOC_JSON_FILES)
set(moc_json_file "${outfile}.json")
list(APPEND moc_parameters --output-json)
list(APPEND metatypes_json_list "${outfile}.json")
set(metatypes_byproducts "${outfile}.json")
endif()
if (TARGET Qt::Platform)
get_target_property(_abi_tag Qt::Platform qt_libcpp_abi_tag)
if (_abi_tag)
list(APPEND moc_parameters --libcpp-abi-version "${_abi_tag}")
endif()
endif()
string (REPLACE ";" "\n" moc_parameters "${moc_parameters}")
file(GENERATE OUTPUT "${moc_parameters_file}" CONTENT "${moc_parameters}\n")
add_custom_command(OUTPUT "${outfile}" ${metatypes_byproducts}
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)
# Register generated json files
if (arg_OUTPUT_MOC_JSON_FILES)
set(${arg_OUTPUT_MOC_JSON_FILES} "${metatypes_json_list}" PARENT_SCOPE)
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()

View File

@ -0,0 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
## 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()

View File

@ -0,0 +1,286 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(CheckCXXSourceCompiles)
function(qt_run_config_test_architecture)
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT
"" CACHE INTERNAL "Test variables that should be exported" FORCE)
# Compile test to find the target architecture and sub-architectures.
set(flags "")
qt_get_platform_try_compile_vars(platform_try_compile_vars)
list(APPEND flags ${platform_try_compile_vars})
list(TRANSFORM flags PREPEND " " OUTPUT_VARIABLE flags_indented)
list(JOIN flags_indented "\n" flags_indented)
message(STATUS
"Building architecture extraction project with the following CMake arguments:")
list(POP_BACK CMAKE_MESSAGE_CONTEXT _context)
message(NOTICE ${flags_indented})
list(APPEND CMAKE_MESSAGE_CONTEXT ${_context})
try_compile(
_arch_result
"${CMAKE_CURRENT_BINARY_DIR}/config.tests/arch"
"${CMAKE_CURRENT_SOURCE_DIR}/config.tests/arch"
arch
CMAKE_FLAGS ${flags}
OUTPUT_VARIABLE arch_test_output
)
if (NOT _arch_result)
message(FATAL_ERROR
"Failed to build architecture extraction project. Build output:\n ${arch_test_output}")
endif()
set(_arch_file_suffix "${CMAKE_EXECUTABLE_SUFFIX}")
# With emscripten the application entry point is a .js file (to be run with node for example),
# but the real "data" is in the .wasm file, so that's where we need to look for the ABI, etc.
# information.
if (WASM)
set(_arch_file_suffix ".wasm")
endif()
set(arch_test_location "config.tests/arch")
if(QT_MULTI_CONFIG_FIRST_CONFIG)
string(APPEND arch_test_location "/${QT_MULTI_CONFIG_FIRST_CONFIG}")
endif()
set(arch_dir "${CMAKE_CURRENT_BINARY_DIR}/${arch_test_location}")
file(GLOB arch_dir_globbed_files RELATIVE "${arch_dir}" "${arch_dir}/*")
list(JOIN arch_dir_globbed_files "\n" arch_dir_globbed_files)
set(_arch_file
"${CMAKE_CURRENT_BINARY_DIR}/${arch_test_location}/architecture_test${_arch_file_suffix}")
if (NOT EXISTS "${_arch_file}")
message(FATAL_ERROR
"Failed to find compiled architecture detection executable at ${_arch_file}. \
The following files were found at: ${arch_dir} \
${arch_dir_globbed_files}")
endif()
message(STATUS "Extracting architecture info from ${_arch_file}.")
file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8
REGEX "==Qt=magic=Qt==")
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)
list(SUBLIST _arch_lines 0 5 arch_lines_fewer)
list(JOIN arch_lines_fewer "\n" arch_lines_output)
message(FATAL_ERROR
"Failed to extract architecture data from file. \
Here are the first few lines extracted:\n${arch_lines_output}")
endif()
set(TEST_architecture 1 CACHE INTERNAL "Ran the architecture test")
set(TEST_architecture_arch "${_architecture}" CACHE INTERNAL "Target machine architecture")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_architecture_arch)
set(TEST_subarch 1 CACHE INTERNAL "Ran machine subArchitecture test")
set(TEST_subarch_result "${_sub_architecture}" CACHE INTERNAL "Target sub-architectures")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_subarch_result)
foreach(it ${_sub_architecture})
# Equivalent to qmake's QT_CPU_FEATURES.$arch.
set(TEST_arch_${TEST_architecture_arch}_subarch_${it} 1 CACHE INTERNAL "Target sub architecture result")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_arch_${TEST_architecture_arch}_subarch_${it})
endforeach()
set(TEST_buildAbi "${_build_abi}" CACHE INTERNAL "Target machine buildAbi")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_buildAbi)
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
list(JOIN _sub_architecture " " subarch_summary)
set_property(GLOBAL PROPERTY qt_configure_subarch_summary "${subarch_summary}")
endfunction()
function(qt_run_linker_version_script_support)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; };
VERS_2 { global: sym; }
VERS_1;
")
if(DEFINED CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
else()
set(CMAKE_REQUIRED_FLAGS "")
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
# Pass the linker that the main project uses to the version script compile test.
qt_internal_get_active_linker_flags(linker_flags)
if(linker_flags)
set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
endif()
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()
# Also makes no sense with MSVC-style command-line
if(MSVC)
set(HAVE_LD_VERSION_SCRIPT OFF)
endif()
set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_ld_version_script)
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
endfunction()
function(qt_internal_ensure_latest_win_nt_api)
if(NOT WIN32)
return()
endif()
check_cxx_source_compiles([=[
#include <windows.h>
#if !defined(_WIN32_WINNT) && !defined(WINVER)
#error "_WIN32_WINNT and WINVER are not defined"
#endif
#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0A00)
#error "_WIN32_WINNT version too low"
#endif
#if defined(WINVER) && (WINVER < 0x0A00)
#error "WINVER version too low"
#endif
int main() { return 0; }
]=] HAVE_WIN10_WIN32_WINNT)
if(NOT HAVE_WIN10_WIN32_WINNT)
list(APPEND QT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0A00 WINVER=0x0A00)
set(QT_PLATFORM_DEFINITIONS ${QT_PLATFORM_DEFINITIONS}
CACHE STRING "Qt platform specific pre-processor defines" FORCE)
endif()
endfunction()
function(qt_run_qtbase_config_tests)
qt_run_config_test_architecture()
qt_internal_ensure_latest_win_nt_api()
endfunction()
# The qmake build of android does not perform the right architecture tests and
# forcefully disables sse4 on android x86. We have to mimic this behavior
# for now
if (CMAKE_ANDROID_ARCH_ABI STREQUAL x86)
set(QT_FEATURE_sse4_1 OFF CACHE BOOL INTERNAL FORCE)
set(QT_FEATURE_sse4_2 OFF CACHE BOOL INTERNAL FORCE)
set(TEST_subarch_sse4_1 FALSE CACHE BOOL INTERNAL FORCE)
set(TEST_subarch_sse4_2 FALSE CACHE BOOL INTERNAL FORCE)
endif()
qt_run_qtbase_config_tests()
function(qt_internal_print_cmake_darwin_info)
if(APPLE)
if(NOT CMAKE_OSX_ARCHITECTURES)
set(default_osx_arch " (defaults to ${CMAKE_SYSTEM_PROCESSOR})")
endif()
message(STATUS "CMAKE_OSX_ARCHITECTURES: \"${CMAKE_OSX_ARCHITECTURES}\"${default_osx_arch}")
message(STATUS "CMAKE_OSX_SYSROOT: \"${CMAKE_OSX_SYSROOT}\"")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: \"${CMAKE_OSX_DEPLOYMENT_TARGET}\"")
message(STATUS "QT_MAC_SDK_VERSION: \"${QT_MAC_SDK_VERSION}\"")
message(STATUS "QT_MAC_XCODE_VERSION: \"${QT_MAC_XCODE_VERSION}\"")
if(DEFINED CACHE{QT_IS_MACOS_UNIVERSAL})
message(STATUS "QT_IS_MACOS_UNIVERSAL: \"${QT_IS_MACOS_UNIVERSAL}\"")
endif()
if(QT_UIKIT_SDK)
message(STATUS "QT_UIKIT_SDK: \"${QT_UIKIT_SDK}\"")
endif()
qt_internal_get_first_osx_arch(osx_first_arch)
if(osx_first_arch)
message(STATUS "Configure tests main architecture (in multi-arch build): \"${osx_first_arch}\"")
endif()
endif()
endfunction()
qt_internal_print_cmake_darwin_info()
function(qt_internal_print_cmake_host_and_target_info)
message(STATUS "CMAKE_VERSION: \"${CMAKE_VERSION}\"")
message(STATUS "CMAKE_HOST_SYSTEM: \"${CMAKE_HOST_SYSTEM}\"")
message(STATUS "CMAKE_HOST_SYSTEM_NAME: \"${CMAKE_HOST_SYSTEM_NAME}\"")
message(STATUS "CMAKE_HOST_SYSTEM_VERSION: \"${CMAKE_HOST_SYSTEM_VERSION}\"")
message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR: \"${CMAKE_HOST_SYSTEM_PROCESSOR}\"")
message(STATUS "CMAKE_SYSTEM: \"${CMAKE_SYSTEM_NAME}\"")
message(STATUS "CMAKE_SYSTEM_NAME: \"${CMAKE_SYSTEM_NAME}\"")
message(STATUS "CMAKE_SYSTEM_VERSION: \"${CMAKE_SYSTEM_VERSION}\"")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: \"${CMAKE_SYSTEM_PROCESSOR}\"")
message(STATUS "CMAKE_CROSSCOMPILING: \"${CMAKE_CROSSCOMPILING}\"")
endfunction()
qt_internal_print_cmake_host_and_target_info()
function(qt_internal_print_prefix_info)
message(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"")
message(STATUS "CMAKE_STAGING_PREFIX: \"${CMAKE_STAGING_PREFIX}\"")
message(STATUS "QT_BUILD_DIR: \"${QT_BUILD_DIR}\"")
message(STATUS "QT_INSTALL_DIR: \"${QT_INSTALL_DIR}\"")
message(STATUS "QT_WILL_INSTALL: \"${QT_WILL_INSTALL}\"")
endfunction()
qt_internal_print_prefix_info()
function(qt_internal_print_cmake_compiler_info)
message(STATUS "CMAKE_C_COMPILER: \"${CMAKE_C_COMPILER}\" (${CMAKE_C_COMPILER_VERSION})")
message(STATUS "CMAKE_CXX_COMPILER: \"${CMAKE_CXX_COMPILER}\" (${CMAKE_CXX_COMPILER_VERSION})")
if(CMAKE_OBJC_COMPILER)
message(STATUS "CMAKE_OBJC_COMPILER: \"${CMAKE_OBJC_COMPILER}\" (${CMAKE_OBJC_COMPILER_VERSION})")
endif()
if(CMAKE_OBJCXX_COMPILER)
message(STATUS "CMAKE_OBJCXX_COMPILER: \"${CMAKE_OBJCXX_COMPILER}\" (${CMAKE_OBJCXX_COMPILER_VERSION})")
endif()
endfunction()
qt_internal_print_cmake_compiler_info()
function(qt_internal_print_cmake_windows_info)
if(MSVC_VERSION)
message(STATUS "MSVC_VERSION: \"${MSVC_VERSION}\"")
endif()
if(MSVC_TOOLSET_VERSION)
message(STATUS "MSVC_TOOLSET_VERSION: \"${MSVC_TOOLSET_VERSION}\"")
endif()
endfunction()
qt_internal_print_cmake_windows_info()
function(qt_internal_print_cmake_android_info)
if(ANDROID)
message(STATUS "ANDROID_TOOLCHAIN: \"${ANDROID_TOOLCHAIN}\"")
message(STATUS "ANDROID_NDK: \"${ANDROID_NDK}\"")
message(STATUS "ANDROID_ABI: \"${ANDROID_ABI}\"")
message(STATUS "ANDROID_PLATFORM: \"${ANDROID_PLATFORM}\"")
message(STATUS "ANDROID_NATIVE_API_LEVEL: \"${ANDROID_NATIVE_API_LEVEL}\"")
message(STATUS "ANDROID_STL: \"${ANDROID_STL}\"")
message(STATUS "ANDROID_PIE: \"${ANDROID_PIE}\"")
message(STATUS "ANDROID_CPP_FEATURES: \"${ANDROID_CPP_FEATURES}\"")
message(STATUS "ANDROID_ALLOW_UNDEFINED_SYMBOLS: \"${ANDROID_ALLOW_UNDEFINED_SYMBOLS}\"")
message(STATUS "ANDROID_ARM_MODE: \"${ANDROID_ARM_MODE}\"")
message(STATUS "ANDROID_ARM_NEON: \"${ANDROID_ARM_NEON}\"")
message(STATUS "ANDROID_DISABLE_FORMAT_STRING_CHECKS: \"${ANDROID_DISABLE_FORMAT_STRING_CHECKS}\"")
message(STATUS "ANDROID_LLVM_TRIPLE: \"${ANDROID_LLVM_TRIPLE}\"")
endif()
endfunction()
qt_internal_print_cmake_android_info()

View File

@ -0,0 +1,415 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
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}")
set(__qt_bin_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_BINDIR}")
set(__qt_libexec_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_LIBEXECDIR}")
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
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}
${__GlobalConfig_install_dir_absolute})
qt_path_join(__qt_bin_dir_absolute
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_bin_dir_absolute})
qt_path_join(__qt_libexec_dir_absolute
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_libexec_dir_absolute})
endif()
# Compute relative path from $qt_prefix/bin dir to global CMake config install dir, to use in the
# unix-y qt-cmake shell script, to make it work even if the installed Qt is relocated.
file(RELATIVE_PATH
__GlobalConfig_relative_path_from_bin_dir_to_cmake_config_dir
${__qt_bin_dir_absolute} ${__GlobalConfig_install_dir_absolute})
# 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})
set(__build_internals_standalone_test_template_dir "QtStandaloneTestTemplateProject")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake"
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
@ONLY
)
write_basic_package_version_file(
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${INSTALL_CMAKE_NAMESPACE}BuildInternals"
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersion.cmake"
)
qt_install(FILES
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersion.cmake"
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersionImpl.cmake"
"${__build_internals_build_dir}/QtBuildInternalsExtra.cmake"
DESTINATION "${__build_internals_install_dir}"
COMPONENT Devel
)
qt_copy_or_install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}"
DESTINATION "${__build_internals_install_dir}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}/CMakeLists.txt")
include(QtToolchainHelpers)
qt_internal_create_toolchain_file()
include(QtWrapperScriptHelpers)
qt_internal_create_wrapper_scripts()
## 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:${INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore>
)
qt_feature_module_begin(NO_MODULE
PUBLIC_FILE src/corelib/global/qconfig.h
PRIVATE_FILE src/corelib/global/qconfig_p.h
)
include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
# Do what mkspecs/features/uikit/default_pre.prf does, aka enable sse2 for
# simulator_and_device_builds.
qt_internal_get_first_osx_arch(__qt_osx_first_arch)
set(__qt_apple_silicon_arches "arm64;arm64e")
if(MACOS AND QT_IS_MACOS_UNIVERSAL
AND __qt_osx_first_arch IN_LIST __qt_apple_silicon_arches)
# The test in configure.cmake will not be run, but we know that
# the compiler supports these intrinsics
set(QT_FORCE_FEATURE_x86intrin ON CACHE INTERNAL "Force-enable x86 intrinsics due to platform requirements.")
set(__QtFeature_custom_enabled_cache_variables
TEST_x86intrin
FEATURE_x86intrin
QT_FEATURE_x86intrin)
endif()
if(MACOS AND QT_IS_MACOS_UNIVERSAL AND __qt_osx_first_arch STREQUAL "x86_64")
set(QT_FORCE_FEATURE_neon ON CACHE INTERNAL "Force enable neon due to platform requirements.")
set(__QtFeature_custom_enabled_cache_variables
TEST_subarch_neon
FEATURE_neon
QT_FEATURE_neon)
endif()
qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_")
# The version script support check has to happen after we determined which linker is going
# to be used. The linker decision happens in the qtbase/configure.cmake file that is processed
# above.
qt_run_linker_version_script_support()
qt_generate_global_config_pri_file()
qt_generate_global_module_pri_file()
qt_generate_global_device_pri_file()
qt_generate_qmake_and_qtpaths_wrapper_for_target()
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:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}/QtCore>
)
add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
include(QtPlatformTargetHelpers)
qt_internal_setup_public_platform_target()
# defines PlatformCommonInternal PlatformModuleInternal PlatformPluginInternal PlatformToolInternal
include(QtInternalTargets)
qt_internal_run_common_config_tests()
# Setup sanitizer options for qtbase directory scope based on features computed above.
qt_internal_set_up_sanitizer_options()
include("${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake")
set(__export_targets Platform
GlobalConfig
GlobalConfigPrivate
PlatformCommonInternal
PlatformModuleInternal
PlatformPluginInternal
PlatformAppInternal
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})
# Save minimum required CMake version to use Qt.
qt_internal_get_supported_min_cmake_version_for_using_qt(supported_min_version_for_using_qt)
qt_internal_get_computed_min_cmake_version_for_using_qt(computed_min_version_for_using_qt)
# Get the lower and upper policy range to embed into the Qt6 config file.
qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
# Generate and install Qt6 config file. Make sure it happens after the global feature evaluation so
# they can be accessed in the Config file if needed.
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/QtConfig.cmake.in"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
INSTALL_DESTINATION "${__GlobalConfig_install_dir}"
)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/QtConfigExtras.cmake.in"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigExtras.cmake"
@ONLY
)
write_basic_package_version_file(
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${INSTALL_CMAKE_NAMESPACE}"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake"
)
qt_install(FILES
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigExtras.cmake"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake"
"${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersionImpl.cmake"
DESTINATION "${__GlobalConfig_install_dir}"
COMPONENT Devel
)
# Install internal CMake files.
# The functions defined inside can not be used in public projects.
# They can only be used while building Qt itself.
qt_copy_or_install(FILES
cmake/ModuleDescription.json.in
cmake/PkgConfigLibrary.pc.in
cmake/Qt3rdPartyLibraryConfig.cmake.in
cmake/Qt3rdPartyLibraryHelpers.cmake
cmake/QtAndroidHelpers.cmake
cmake/QtAppHelpers.cmake
cmake/QtAutogenHelpers.cmake
cmake/QtBuild.cmake
cmake/QtBuildInformation.cmake
cmake/QtCMakeHelpers.cmake
cmake/QtCMakeVersionHelpers.cmake
cmake/QtCMakePackageVersionFile.cmake.in
cmake/QtCompilerFlags.cmake
cmake/QtCompilerOptimization.cmake
cmake/QtConfigDependencies.cmake.in
cmake/QtConfigureTimeExecutableCMakeLists.txt.in
cmake/QtDeferredDependenciesHelpers.cmake
cmake/QtDbusHelpers.cmake
cmake/QtDocsHelpers.cmake
cmake/QtExecutableHelpers.cmake
cmake/QtFileConfigure.txt.in
cmake/QtFindPackageHelpers.cmake
cmake/QtFindWrapConfigExtra.cmake.in
cmake/QtFindWrapHelper.cmake
cmake/QtFinishPkgConfigFile.cmake
cmake/QtFinishPrlFile.cmake
cmake/QtFlagHandlingHelpers.cmake
cmake/QtFrameworkHelpers.cmake
cmake/QtGenerateExtPri.cmake
cmake/QtGenerateLibHelpers.cmake
cmake/QtGenerateLibPri.cmake
cmake/QtGenerateVersionScript.cmake
cmake/QtGlobalStateHelpers.cmake
cmake/QtHeadersClean.cmake
cmake/QtInstallHelpers.cmake
cmake/QtJavaHelpers.cmake
cmake/QtLalrHelpers.cmake
cmake/QtModuleConfig.cmake.in
cmake/QtModuleDependencies.cmake.in
cmake/QtModuleHeadersCheck.cmake
cmake/QtModuleHelpers.cmake
cmake/QtModuleToolsConfig.cmake.in
cmake/QtModuleToolsDependencies.cmake.in
cmake/QtModuleToolsVersionlessTargets.cmake.in
cmake/QtNoLinkTargetHelpers.cmake
cmake/QtPkgConfigHelpers.cmake
cmake/QtPlatformAndroid.cmake
cmake/QtPlatformSupport.cmake
cmake/QtPluginConfig.cmake.in
cmake/QtPluginDependencies.cmake.in
cmake/QtPluginHelpers.cmake
cmake/QtPlugins.cmake.in
cmake/QtPostProcess.cmake
cmake/QtPostProcessHelpers.cmake
cmake/QtPrecompiledHeadersHelpers.cmake
cmake/QtUnityBuildHelpers.cmake
cmake/QtPriHelpers.cmake
cmake/QtPrlHelpers.cmake
cmake/QtPlatformTargetHelpers.cmake
cmake/QtProcessConfigureArgs.cmake
cmake/QtQmakeHelpers.cmake
cmake/QtResourceHelpers.cmake
cmake/QtRpathHelpers.cmake
cmake/QtSanitizerHelpers.cmake
cmake/QtScopeFinalizerHelpers.cmake
cmake/QtSeparateDebugInfo.Info.plist.in
cmake/QtSeparateDebugInfo.cmake
cmake/QtSetup.cmake
cmake/QtSimdHelpers.cmake
cmake/QtSingleRepoTargetSetBuildHelpers.cmake
cmake/QtStandaloneTestsConfig.cmake.in
cmake/QtSyncQtHelpers.cmake
cmake/QtTargetHelpers.cmake
cmake/QtTestHelpers.cmake
cmake/QtToolchainHelpers.cmake
cmake/QtToolHelpers.cmake
cmake/QtWasmHelpers.cmake
cmake/QtWrapperScriptHelpers.cmake
cmake/QtWriteArgsFile.cmake
cmake/modulecppexports.h.in
cmake/modulecppexports_p.h.in
cmake/qbatchedtestrunner.in.cpp
DESTINATION "${__GlobalConfig_install_dir}"
)
# Install our custom platform modules.
qt_copy_or_install(DIRECTORY cmake/platforms
DESTINATION "${__GlobalConfig_install_dir}"
)
# Install public config.tests files.
qt_copy_or_install(DIRECTORY
"config.tests/static_link_order"
"config.tests/binary_for_strip"
DESTINATION "${__GlobalConfig_install_dir}/config.tests"
)
# Install qt-internal-strip and qt-internal-ninja files.
set(__qt_internal_strip_wrappers
libexec/qt-internal-strip.in
libexec/qt-internal-strip.bat.in
libexec/qt-internal-ninja.in
libexec/qt-internal-ninja.bat.in
)
qt_copy_or_install(PROGRAMS
${__qt_internal_strip_wrappers}
DESTINATION "${__GlobalConfig_install_dir}/libexec"
)
if(QT_WILL_INSTALL)
foreach(__qt_internal_strip_wrapper ${__qt_internal_strip_wrappers})
file(COPY "${__qt_internal_strip_wrapper}"
DESTINATION "${__GlobalConfig_build_dir}/libexec")
endforeach()
endif()
# Install public CMake files.
# The functions defined inside can be used in both public projects and while building Qt.
# Usually we put such functions into Qt6CoreMacros.cmake, but that's getting bloated.
# These files will be included by Qt6Config.cmake.
set(__public_cmake_helpers
cmake/QtCopyFileIfDifferent.cmake
cmake/QtFeature.cmake
cmake/QtFeatureCommon.cmake
cmake/QtPublicAppleHelpers.cmake
cmake/QtPublicCMakeHelpers.cmake
cmake/QtPublicCMakeVersionHelpers.cmake
cmake/QtPublicFinalizerHelpers.cmake
cmake/QtPublicPluginHelpers.cmake
cmake/QtPublicTargetHelpers.cmake
cmake/QtPublicTestHelpers.cmake
cmake/QtPublicToolHelpers.cmake
cmake/QtPublicWalkLibsHelpers.cmake
cmake/QtPublicFindPackageHelpers.cmake
cmake/QtPublicDependencyHelpers.cmake
# Public CMake files that are installed next Qt6Config.cmake, but are NOT included by it.
# Instead they are included by the generated CMake toolchain file.
cmake/QtPublicWasmToolchainHelpers.cmake
)
qt_copy_or_install(FILES ${__public_cmake_helpers} DESTINATION "${__GlobalConfig_install_dir}")
# In prefix builds we also need to copy the files into the build config directory, so that the
# build-dir Qt6Config.cmake finds the files when building examples in-tree.
if(QT_WILL_INSTALL)
foreach(_public_cmake_helper ${__public_cmake_helpers})
file(COPY "${_public_cmake_helper}" DESTINATION "${__GlobalConfig_build_dir}")
endforeach()
endif()
qt_copy_or_install(DIRECTORY "cmake/3rdparty" DESTINATION "${__GlobalConfig_install_dir}")
# In prefix builds we also need to copy the files into the build config directory, so that the
# build-dir Qt6Config.cmake finds the files when building other repos in a top-level build.
if(QT_WILL_INSTALL)
file(COPY "cmake/3rdparty" DESTINATION "${__GlobalConfig_build_dir}")
endif()
# 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
)
# In prefix builds we also need to copy the files into the build config directory, so that the
# build-dir Qt6Config.cmake finds the files when building examples as ExternalProjects.
if(QT_WILL_INSTALL)
file(COPY cmake/
DESTINATION "${__GlobalConfig_build_dir}"
FILES_MATCHING PATTERN "Find*.cmake"
PATTERN "tests" EXCLUDE
PATTERN "3rdparty" EXCLUDE
)
endif()
if(MACOS)
qt_copy_or_install(FILES
cmake/macos/MacOSXBundleInfo.plist.in
DESTINATION "${__GlobalConfig_install_dir}/macos"
)
elseif(IOS)
qt_copy_or_install(FILES
cmake/ios/Info.plist.app.in
cmake/ios/LaunchScreen.storyboard
DESTINATION "${__GlobalConfig_install_dir}/ios"
)
elseif(WASM)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/wasmtestrunner/qt-wasmtestrunner.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
endif()
# Install CI support files to libexec.
qt_path_join(__qt_libexec_install_dir "${QT_INSTALL_DIR}" "${INSTALL_LIBEXECDIR}")
qt_copy_or_install(FILES coin/instructions/qmake/ensure_pro_file.cmake
DESTINATION "${__qt_libexec_install_dir}")
qt_copy_or_install(PROGRAMS "util/testrunner/qt-testrunner.py"
DESTINATION "${__qt_libexec_install_dir}")
qt_copy_or_install(PROGRAMS "util/testrunner/sanitizer-testrunner.py"
DESTINATION "${__qt_libexec_install_dir}")

580
cmake/QtBuild.cmake Normal file
View File

@ -0,0 +1,580 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
include(CMakePackageConfigHelpers)
include(QtSeparateDebugInfo)
function(qt_configure_process_path name default docstring)
# Values are computed once for qtbase, and then exported and reused for other projects.
if(NOT PROJECT_NAME STREQUAL "QtBase")
return()
endif()
# No value provided, set the default.
if(NOT DEFINED "${name}")
set("${name}" "${default}" CACHE STRING "${docstring}")
else()
get_filename_component(given_path_as_abs "${${name}}" ABSOLUTE BASE_DIR
"${CMAKE_INSTALL_PREFIX}")
file(RELATIVE_PATH rel_path "${CMAKE_INSTALL_PREFIX}"
"${given_path_as_abs}")
# If absolute path given, check that it's inside the prefix (error out if not).
# TODO: Figure out if we need to support paths that are outside the prefix.
#
# If relative path given, it's relative to the install prefix (rather than the binary dir,
# which is what qmake does for some reason).
# In both cases, store the value as a relative path.
if("${rel_path}" STREQUAL "")
# file(RELATIVE_PATH) returns an empty string if the given absolute paths are equal
set(rel_path ".")
elseif(rel_path MATCHES "^\.\./")
# INSTALL_SYSCONFDIR is allowed to be outside the prefix.
if(NOT name STREQUAL "INSTALL_SYSCONFDIR")
message(FATAL_ERROR
"Path component '${name}' is outside computed install prefix: ${rel_path} ")
return()
endif()
set("${name}" "${${name}}" CACHE STRING "${docstring}" FORCE)
else()
set("${name}" "${rel_path}" CACHE STRING "${docstring}" FORCE)
endif()
endif()
endfunction()
# Install locations:
qt_configure_process_path(INSTALL_BINDIR "bin" "Executables [PREFIX/bin]")
qt_configure_process_path(INSTALL_INCLUDEDIR "include" "Header files [PREFIX/include]")
qt_configure_process_path(INSTALL_LIBDIR "lib" "Libraries [PREFIX/lib]")
qt_configure_process_path(INSTALL_MKSPECSDIR "mkspecs" "Mkspecs files [PREFIX/mkspecs]")
qt_configure_process_path(INSTALL_ARCHDATADIR "." "Arch-dependent data [PREFIX]")
qt_configure_process_path(INSTALL_PLUGINSDIR
"${INSTALL_ARCHDATADIR}/plugins"
"Plugins [ARCHDATADIR/plugins]")
if(NOT INSTALL_MKSPECSDIR MATCHES "(^|/)mkspecs")
message(FATAL_ERROR "INSTALL_MKSPECSDIR must end with '/mkspecs'")
endif()
# Given CMAKE_CONFIG and ALL_CMAKE_CONFIGS, determines if a directory suffix needs to be appended
# to each destination, and sets the computed install target destination arguments in OUT_VAR.
# Defaults used for each of the destination types, and can be configured per destination type.
function(qt_get_install_target_default_args)
cmake_parse_arguments(PARSE_ARGV 0 arg
""
"OUT_VAR;CMAKE_CONFIG;RUNTIME;LIBRARY;ARCHIVE;INCLUDES;BUNDLE"
"ALL_CMAKE_CONFIGS")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_CMAKE_CONFIG)
message(FATAL_ERROR "No value given for CMAKE_CONFIG.")
endif()
if(NOT arg_ALL_CMAKE_CONFIGS)
message(FATAL_ERROR "No value given for ALL_CMAKE_CONFIGS.")
endif()
list(LENGTH arg_ALL_CMAKE_CONFIGS all_configs_count)
list(GET arg_ALL_CMAKE_CONFIGS 0 first_config)
set(suffix "")
if(all_configs_count GREATER 1 AND NOT arg_CMAKE_CONFIG STREQUAL first_config)
set(suffix "/${arg_CMAKE_CONFIG}")
endif()
set(runtime "${INSTALL_BINDIR}")
if(arg_RUNTIME)
set(runtime "${arg_RUNTIME}")
endif()
set(library "${INSTALL_LIBDIR}")
if(arg_LIBRARY)
set(library "${arg_LIBRARY}")
endif()
set(archive "${INSTALL_LIBDIR}")
if(arg_ARCHIVE)
set(archive "${arg_ARCHIVE}")
endif()
set(includes "${INSTALL_INCLUDEDIR}")
if(arg_INCLUDES)
set(includes "${arg_INCLUDES}")
endif()
set(bundle "${INSTALL_BINDIR}")
if(arg_BUNDLE)
set(bundle "${arg_BUNDLE}")
endif()
set(args
RUNTIME DESTINATION "${runtime}${suffix}"
LIBRARY DESTINATION "${library}${suffix}"
ARCHIVE DESTINATION "${archive}${suffix}" COMPONENT Devel
BUNDLE DESTINATION "${bundle}${suffix}"
INCLUDES DESTINATION "${includes}${suffix}")
set(${arg_OUT_VAR} "${args}" PARENT_SCOPE)
endfunction()
if (WIN32)
set(_default_libexec "${INSTALL_ARCHDATADIR}/bin")
else()
set(_default_libexec "${INSTALL_ARCHDATADIR}/libexec")
endif()
qt_configure_process_path(
INSTALL_LIBEXECDIR
"${_default_libexec}"
"Helper programs [ARCHDATADIR/bin on Windows, ARCHDATADIR/libexec otherwise]")
qt_configure_process_path(INSTALL_QMLDIR
"${INSTALL_ARCHDATADIR}/qml"
"QML imports [ARCHDATADIR/qml]")
qt_configure_process_path(INSTALL_DATADIR "." "Arch-independent data [PREFIX]")
qt_configure_process_path(INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" "Documentation [DATADIR/doc]")
qt_configure_process_path(INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations"
"Translations [DATADIR/translations]")
if(APPLE)
set(QT_DEFAULT_SYS_CONF_DIR "/Library/Preferences/Qt")
else()
set(QT_DEFAULT_SYS_CONF_DIR "etc/xdg")
endif()
qt_configure_process_path(INSTALL_SYSCONFDIR
"${QT_DEFAULT_SYS_CONF_DIR}"
"Settings used by Qt programs [PREFIX/etc/xdg]/[/Library/Preferences/Qt]")
qt_configure_process_path(INSTALL_EXAMPLESDIR "examples" "Examples [PREFIX/examples]")
qt_configure_process_path(INSTALL_TESTSDIR "tests" "Tests [PREFIX/tests]")
qt_configure_process_path(INSTALL_DESCRIPTIONSDIR
"${INSTALL_ARCHDATADIR}/modules"
"Module description files directory")
if(NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "")
set(QT_STAGING_PREFIX "${CMAKE_STAGING_PREFIX}")
else()
set(QT_STAGING_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
if(PROJECT_NAME STREQUAL "QtBase")
set(QT_COORD_TYPE double CACHE STRING "Type of qreal")
endif()
function(qt_internal_set_up_global_paths)
# Compute the values of QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR
# taking into account whether the current build is a prefix build or a non-prefix build,
# and whether it is a superbuild or non-superbuild.
# A third case is when another module or standalone tests are built against a super-built Qt.
# The layout for the third case is the same as for non-superbuilds.
#
# These values should be prepended to file paths in commands or properties,
# in order to correctly place generated Config files, generated Targets files,
# executables / libraries, when copying / installing files, etc.
#
# The build dir variables will always be absolute paths.
# The QT_INSTALL_DIR variable will have a relative path in a prefix build,
# which means that it can be empty, so use qt_join_path to prevent accidental absolute paths.
if(QT_SUPERBUILD)
# In this case, we always copy all the build products in qtbase/{bin,lib,...}
if(QT_WILL_INSTALL)
set(QT_BUILD_DIR "${QtBase_BINARY_DIR}")
set(QT_INSTALL_DIR "")
else()
if("${CMAKE_STAGING_PREFIX}" STREQUAL "")
set(QT_BUILD_DIR "${QtBase_BINARY_DIR}")
set(QT_INSTALL_DIR "${QtBase_BINARY_DIR}")
else()
set(QT_BUILD_DIR "${CMAKE_STAGING_PREFIX}")
set(QT_INSTALL_DIR "${CMAKE_STAGING_PREFIX}")
endif()
endif()
else()
if(QT_WILL_INSTALL)
# In the usual prefix build case, the build dir is the current module build dir,
# and the install dir is the prefix, so we don't set it.
set(QT_BUILD_DIR "${CMAKE_BINARY_DIR}")
set(QT_INSTALL_DIR "")
else()
# When doing a non-prefix build, both the build dir and install dir are the same,
# pointing to the qtbase build dir.
set(QT_BUILD_DIR "${QT_STAGING_PREFIX}")
set(QT_INSTALL_DIR "${QT_BUILD_DIR}")
endif()
endif()
set(__config_path_part "${INSTALL_LIBDIR}/cmake")
set(QT_CONFIG_BUILD_DIR "${QT_BUILD_DIR}/${__config_path_part}")
set(QT_CONFIG_INSTALL_DIR "${QT_INSTALL_DIR}")
if(QT_CONFIG_INSTALL_DIR)
string(APPEND QT_CONFIG_INSTALL_DIR "/")
endif()
string(APPEND QT_CONFIG_INSTALL_DIR ${__config_path_part})
set(QT_BUILD_DIR "${QT_BUILD_DIR}" PARENT_SCOPE)
set(QT_INSTALL_DIR "${QT_INSTALL_DIR}" PARENT_SCOPE)
set(QT_CONFIG_BUILD_DIR "${QT_CONFIG_BUILD_DIR}" PARENT_SCOPE)
set(QT_CONFIG_INSTALL_DIR "${QT_CONFIG_INSTALL_DIR}" PARENT_SCOPE)
endfunction()
qt_internal_set_up_global_paths()
qt_get_relocatable_install_prefix(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX)
set(QT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
# Find the path to mkspecs/, depending on whether we are building as part of a standard qtbuild,
# or a module against an already installed version of qt.
if(NOT QT_MKSPECS_DIR)
if("${QT_BUILD_INTERNALS_PATH}" STREQUAL "")
get_filename_component(QT_MKSPECS_DIR "${CMAKE_CURRENT_LIST_DIR}/../mkspecs" ABSOLUTE)
else()
# We can rely on QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX being set by
# QtBuildInternalsExtra.cmake.
get_filename_component(
QT_MKSPECS_DIR
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_MKSPECSDIR}" ABSOLUTE)
endif()
set(QT_MKSPECS_DIR "${QT_MKSPECS_DIR}" CACHE INTERNAL "")
endif()
# macOS versions 10.14 and less don't have the implementation of std::filesystem API.
if(CMAKE_HOST_APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS "19.0.0")
message(FATAL_ERROR "macOS versions less than 10.15 are not supported for building Qt.")
endif()
# the default RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
endif("${isSystemDir}" STREQUAL "-1")
# The default rpath settings for installed targets is empty.
# The rpaths will instead be computed for each target separately using qt_apply_rpaths().
# Additional rpaths can be passed via QT_EXTRA_RPATHS.
# By default this will include $ORIGIN / @loader_path, so the installation is relocatable.
# Bottom line: No need to pass anything to CMAKE_INSTALL_RPATH.
set(CMAKE_INSTALL_RPATH "" CACHE STRING "RPATH for installed binaries")
# By default, don't embed auto-determined RPATHs pointing to directories
# outside of the build tree, into the installed binaries.
# This ended up adding rpaths like ${CMAKE_INSTALL_PREFIX}/lib (or /Users/qt/work/install/lib into
# the official libraries created by the CI) into the non-qtbase libraries, plugins, etc.
#
# It should not be necessary, given that qt_apply_rpaths() already adds the necessary rpaths, either
# relocatable ones or absolute ones, depending on what the platform supports.
if(NOT QT_NO_DISABLE_CMAKE_INSTALL_RPATH_USE_LINK_PATH)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
# Ensure that GNUInstallDirs's CMAKE_INSTALL_LIBDIR points to the same lib dir that Qt was
# configured with. Currently this is important for QML plugins, which embed an rpath based
# on that value.
set(CMAKE_INSTALL_LIBDIR "${INSTALL_LIBDIR}")
function(qt_setup_tool_path_command)
if(NOT CMAKE_HOST_WIN32)
return()
endif()
set(bindir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
file(TO_NATIVE_PATH "${bindir}" bindir)
list(APPEND command COMMAND)
list(APPEND command set PATH=${bindir}$<SEMICOLON>%PATH%)
set(QT_TOOL_PATH_SETUP_COMMAND "${command}" CACHE INTERNAL "internal command prefix for tool invocations" FORCE)
# QT_TOOL_PATH_SETUP_COMMAND is deprecated. Please use _qt_internal_get_wrap_tool_script_path
# instead.
endfunction()
qt_setup_tool_path_command()
# Platform define path, etc.
if(WIN32)
set(QT_DEFAULT_PLATFORM_DEFINITIONS WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS WIN64 _WIN64)
endif()
if(MSVC)
if (CLANG)
set(QT_DEFAULT_MKSPEC win32-clang-msvc)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(QT_DEFAULT_MKSPEC win32-arm64-msvc)
else()
set(QT_DEFAULT_MKSPEC win32-msvc)
endif()
elseif(CLANG AND MINGW)
set(QT_DEFAULT_MKSPEC win32-clang-g++)
elseif(MINGW)
set(QT_DEFAULT_MKSPEC win32-g++)
endif()
if (MINGW)
list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS MINGW_HAS_SECURE_API=1)
endif()
elseif(LINUX)
if(GCC)
set(QT_DEFAULT_MKSPEC linux-g++)
elseif(CLANG)
set(QT_DEFAULT_MKSPEC linux-clang)
endif()
elseif(ANDROID)
if(GCC)
set(QT_DEFAULT_MKSPEC android-g++)
elseif(CLANG)
set(QT_DEFAULT_MKSPEC android-clang)
endif()
elseif(IOS)
set(QT_DEFAULT_MKSPEC macx-ios-clang)
elseif(APPLE)
set(QT_DEFAULT_MKSPEC macx-clang)
elseif(WASM)
if(WASM64)
set(QT_DEFAULT_MKSPEC wasm-emscripten-64)
else()
set(QT_DEFAULT_MKSPEC wasm-emscripten)
endif()
elseif(QNX)
# Certain POSIX defines are not set if we don't compile with -std=gnuXX
set(QT_ENABLE_CXX_EXTENSIONS ON)
list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _FORTIFY_SOURCE=2 _REENTRANT)
set(compiler_aarch64le aarch64le)
set(compiler_armle-v7 armv7le)
set(compiler_x86-64 x86_64)
set(compiler_x86 x86)
foreach(arch aarch64le armle-v7 x86-64 x86)
if (CMAKE_CXX_COMPILER_TARGET MATCHES "${compiler_${arch}}$")
set(QT_DEFAULT_MKSPEC qnx-${arch}-qcc)
endif()
endforeach()
elseif(FREEBSD)
if(CLANG)
set(QT_DEFAULT_MKSPEC freebsd-clang)
elseif(GCC)
set(QT_DEFAULT_MKSPEC freebsd-g++)
endif()
elseif(NETBSD)
set(QT_DEFAULT_MKSPEC netbsd-g++)
elseif(OPENBSD)
set(QT_DEFAULT_MKSPEC openbsd-g++)
elseif(SOLARIS)
if(GCC)
if(QT_64BIT)
set(QT_DEFAULT_MKSPEC solaris-g++-64)
else()
set(QT_DEFAULT_MKSPEC solaris-g++)
endif()
else()
if(QT_64BIT)
set(QT_DEFAULT_MKSPEC solaris-cc-64)
else()
set(QT_DEFAULT_MKSPEC solaris-cc)
endif()
endif()
elseif(HURD)
set(QT_DEFAULT_MKSPEC hurd-g++)
endif()
if(NOT QT_QMAKE_TARGET_MKSPEC)
set(QT_QMAKE_TARGET_MKSPEC "${QT_DEFAULT_MKSPEC}" CACHE STRING "QMake target mkspec")
endif()
if(CMAKE_CROSSCOMPILING)
set(QT_QMAKE_HOST_MKSPEC "${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_QMAKE_MKSPEC}")
else()
set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
endif()
if(NOT EXISTS "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}")
file(GLOB known_platforms
LIST_DIRECTORIES true
RELATIVE "${QT_MKSPECS_DIR}"
"${QT_MKSPECS_DIR}/*"
)
list(JOIN known_platforms "\n " known_platforms)
message(FATAL_ERROR "Unknown platform ${QT_QMAKE_TARGET_MKSPEC}\n\
Known platforms:\n ${known_platforms}")
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_NAMESPACE "" CACHE STRING "Qt Namespace")
include(QtGlobalStateHelpers)
# Reset global state:
qt_internal_clear_qt_repo_known_modules()
qt_internal_clear_qt_repo_known_plugin_types()
qt_internal_set_qt_known_plugins("")
set(QT_KNOWN_MODULES_WITH_TOOLS "" CACHE INTERNAL "Known Qt modules with tools" FORCE)
# 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()
# This is used to hold extra cmake code that should be put into QtBuildInternalsExtra.cmake file
# at the QtPostProcess stage.
set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "")
# Save the value of the current first project source dir.
# This will be /path/to/qtbase for qtbase both in a super-build and a non super-build.
# This will be /path/to/qtbase/tests when building standalone tests.
set(QT_TOP_LEVEL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Prevent warnings about object files without any symbols. This is a common
# thing in Qt as we tend to build files unconditionally, and then use ifdefs
# to compile out parts that are not relevant.
if(CMAKE_HOST_APPLE AND APPLE)
foreach(lang ASM C CXX)
# We have to tell 'ar' to not run ranlib by itself, by passing the 'S' option
set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qcS <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> qS <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols <TARGET>")
endforeach()
endif()
# Functions and macros:
# Needed for qt_internal_add_link_flags_no_undefined.
include(CheckCXXSourceCompiles)
set(__default_private_args
SOURCES
LIBRARIES
INCLUDE_DIRECTORIES
SYSTEM_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
NO_UNITY_BUILD_SOURCES
)
set(__default_public_args
PUBLIC_LIBRARIES
PUBLIC_INCLUDE_DIRECTORIES
PUBLIC_DEFINES
PUBLIC_COMPILE_OPTIONS
PUBLIC_LINK_OPTIONS
)
set(__default_private_module_args
PRIVATE_MODULE_INTERFACE
)
set(__default_target_info_args
TARGET_VERSION
TARGET_PRODUCT
TARGET_DESCRIPTION
TARGET_COMPANY
TARGET_COPYRIGHT
)
# Collection of arguments so they can be shared across qt_internal_add_executable
# and qt_internal_add_test_helper.
set(__qt_internal_add_executable_optional_args
GUI
NO_INSTALL
EXCEPTIONS
DELAY_RC
DELAY_TARGET_INFO
QT_APP
NO_UNITY_BUILD
)
set(__qt_internal_add_executable_single_args
CORE_LIBRARY
OUTPUT_DIRECTORY
INSTALL_DIRECTORY
VERSION
${__default_target_info_args}
)
set(__qt_internal_add_executable_multi_args
${__default_private_args}
${__default_public_args}
)
option(QT_CMAKE_DEBUG_EXTEND_TARGET "Debug extend_target calls in Qt's build system" OFF)
# Internal helpers available only while building Qt itself.
include(Qt3rdPartyLibraryHelpers)
include(QtAppHelpers)
include(QtAutogenHelpers)
include(QtCMakeHelpers)
include(QtDeferredDependenciesHelpers)
include(QtDbusHelpers)
include(QtDocsHelpers)
include(QtExecutableHelpers)
include(QtFindPackageHelpers)
include(QtFlagHandlingHelpers)
include(QtFrameworkHelpers)
include(QtInstallHelpers)
include(QtLalrHelpers)
include(QtModuleHelpers)
include(QtNoLinkTargetHelpers)
include(QtPluginHelpers)
include(QtPrecompiledHeadersHelpers)
include(QtUnityBuildHelpers)
include(QtPkgConfigHelpers)
include(QtPriHelpers)
include(QtPrlHelpers)
include(QtQmakeHelpers)
include(QtResourceHelpers)
include(QtRpathHelpers)
include(QtSanitizerHelpers)
include(QtScopeFinalizerHelpers)
include(QtSimdHelpers)
include(QtSingleRepoTargetSetBuildHelpers)
include(QtSyncQtHelpers)
include(QtTargetHelpers)
include(QtTestHelpers)
include(QtToolHelpers)
include(QtHeadersClean)
include(QtJavaHelpers)
if(ANDROID)
include(QtAndroidHelpers)
endif()
if(WASM)
include(QtWasmHelpers)
endif()
# Helpers that are available in public projects and while building Qt itself.
include(QtPublicAppleHelpers)
include(QtPublicCMakeHelpers)
include(QtPublicPluginHelpers)
include(QtPublicTargetHelpers)
include(QtPublicWalkLibsHelpers)
include(QtPublicFindPackageHelpers)
include(QtPublicDependencyHelpers)
include(QtPublicTestHelpers)
include(QtPublicToolHelpers)
if(CMAKE_CROSSCOMPILING)
if(NOT IS_DIRECTORY "${QT_HOST_PATH}")
message(FATAL_ERROR "You need to set QT_HOST_PATH to cross compile Qt.")
endif()
endif()
_qt_internal_determine_if_host_info_package_needed(__qt_build_requires_host_info_package)
_qt_internal_find_host_info_package("${__qt_build_requires_host_info_package}")
# Create tool script wrapper if necessary.
# TODO: Remove once all direct usages of QT_TOOL_COMMAND_WRAPPER_PATH are replaced with function
# calls.
_qt_internal_generate_tool_command_wrapper()
# This sets up the poor man's scope finalizer mechanism.
# For newer CMake versions, we use cmake_language(DEFER CALL) instead.
if(CMAKE_VERSION VERSION_LESS "3.19.0")
variable_watch(CMAKE_CURRENT_LIST_DIR qt_watch_current_list_dir)
endif()

View File

@ -0,0 +1,556 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
function(qt_print_feature_summary)
if(QT_SUPERBUILD)
qt_internal_set_message_log_level(message_log_level)
if(message_log_level)
# In a top-level build, ensure that the feature_summary is affected by the
# selected log-level.
set(CMAKE_MESSAGE_LOG_LEVEL "${message_log_level}")
endif()
endif()
include(FeatureSummary)
# Show which packages were found.
feature_summary(INCLUDE_QUIET_PACKAGES
WHAT PACKAGES_FOUND
REQUIRED_PACKAGES_NOT_FOUND
RECOMMENDED_PACKAGES_NOT_FOUND
OPTIONAL_PACKAGES_NOT_FOUND
RUNTIME_PACKAGES_NOT_FOUND
FATAL_ON_MISSING_REQUIRED_PACKAGES)
qt_internal_run_additional_summary_checks()
qt_configure_print_summary()
endfunction()
function(qt_internal_run_additional_summary_checks)
get_property(
rpath_workaround_enabled
GLOBAL PROPERTY _qt_internal_staging_prefix_build_rpath_workaround)
if(rpath_workaround_enabled)
set(message
"Due to CMAKE_STAGING_PREFIX usage and an unfixed CMake bug,
to ensure correct build time rpaths, directory-level install
rules like ninja src/gui/install will not work.
Check QTBUG-102592 for further details.")
qt_configure_add_report_entry(
TYPE NOTE
MESSAGE "${message}"
)
endif()
endfunction()
function(qt_print_build_instructions)
if((NOT PROJECT_NAME STREQUAL "QtBase" AND
NOT PROJECT_NAME STREQUAL "Qt") OR
QT_BUILD_STANDALONE_TESTS)
return()
endif()
if(QT_SUPERBUILD)
qt_internal_set_message_log_level(message_log_level)
if(message_log_level)
# In a top-level build, ensure that qt_print_build_instructions is affected by the
# selected log-level.
set(CMAKE_MESSAGE_LOG_LEVEL "${message_log_level}")
endif()
endif()
set(build_command "cmake --build . --parallel")
set(install_command "cmake --install .")
# Suggest "ninja install" for Multi-Config builds
# until https://gitlab.kitware.com/cmake/cmake/-/issues/21475 is fixed.
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
set(install_command "ninja install")
endif()
set(configure_module_command "qt-configure-module")
if(CMAKE_HOST_WIN32)
string(APPEND configure_module_command ".bat")
endif()
if("${CMAKE_STAGING_PREFIX}" STREQUAL "")
set(local_install_prefix "${CMAKE_INSTALL_PREFIX}")
else()
set(local_install_prefix "${CMAKE_STAGING_PREFIX}")
endif()
set(msg "\n")
list(APPEND msg "Qt is now configured for building. Just run '${build_command}'\n")
if(QT_WILL_INSTALL)
list(APPEND msg "Once everything is built, you must run '${install_command}'")
list(APPEND msg "Qt will be installed into '${CMAKE_INSTALL_PREFIX}'")
else()
list(APPEND msg
"Once everything is built, Qt is installed. You should NOT run '${install_command}'")
list(APPEND msg
"Note that this build cannot be deployed to other machines or devices.")
endif()
list(APPEND msg
"\nTo configure and build other Qt modules, you can use the following convenience script:
${local_install_prefix}/${INSTALL_BINDIR}/${configure_module_command}")
list(APPEND msg "\nIf reconfiguration fails for some reason, try removing 'CMakeCache.txt' \
from the build directory")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
list(APPEND msg "Alternatively, you can add the --fresh flag to your CMake flags.\n")
else()
list(APPEND msg "\n")
endif()
list(JOIN msg "\n" msg)
if(NOT QT_INTERNAL_BUILD_INSTRUCTIONS_SHOWN)
qt_configure_print_build_instructions_helper("${msg}")
endif()
set(QT_INTERNAL_BUILD_INSTRUCTIONS_SHOWN "TRUE" CACHE STRING "" FORCE)
if(QT_SUPERBUILD)
qt_internal_save_previously_found_packages()
endif()
endfunction()
function(qt_configure_print_summary_helper summary_reports force_show)
# We force show the summary by temporarily (within the scope of the function) resetting the
# current log level.
if(force_show)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
# Need 2 flushes to ensure no interleaved input is printed due to a mix of message(STATUS)
# and message(NOTICE) calls.
execute_process(COMMAND ${CMAKE_COMMAND} -E echo " ")
message(STATUS "Configure summary:\n${summary_reports}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo " ")
endif()
endfunction()
function(qt_configure_print_build_instructions_helper msg)
# We want to ensure build instructions are always shown the first time, regardless of the
# current log level.
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
message(STATUS "${msg}")
endfunction()
function(qt_configure_print_summary)
# Evaluate all recorded commands.
qt_configure_eval_commands()
set(summary_file "${CMAKE_BINARY_DIR}/config.summary")
file(WRITE "${summary_file}" "")
get_property(features_possibly_changed GLOBAL PROPERTY _qt_dirty_build)
# Show Qt-specific configuration summary.
if(__qt_configure_reports)
# We want to show the configuration summary file and log level message only on
# first configuration or when we detect a feature change, to keep most
# reconfiguration output as quiet as possible.
# Currently feature change detection is not entirely reliable.
if(NOT QT_INTERNAL_SUMMARY_INSTRUCTIONS_SHOWN OR features_possibly_changed)
set(force_show_summary TRUE)
message(
"\n"
"-- Configuration summary shown below. It has also been written to"
" ${CMAKE_BINARY_DIR}/config.summary")
message(
"-- Configure with --log-level=STATUS or higher to increase "
"CMake's message verbosity. "
"The log level does not persist across reconfigurations.")
else()
set(force_show_summary FALSE)
message(
"\n"
"-- Configuration summary has been written to"
" ${CMAKE_BINARY_DIR}/config.summary")
endif()
qt_configure_print_summary_helper(
"${__qt_configure_reports}"
${force_show_summary})
file(APPEND "${summary_file}" "${__qt_configure_reports}")
endif()
# Show Qt specific notes, warnings, errors.
if(__qt_configure_notes)
message("${__qt_configure_notes}")
file(APPEND "${summary_file}" "${__qt_configure_notes}")
endif()
if(__qt_configure_warnings)
message("${__qt_configure_warnings}")
file(APPEND "${summary_file}" "${__qt_configure_warnings}")
endif()
if(__qt_configure_errors)
message("${__qt_configure_errors}")
file(APPEND "${summary_file}" "${__qt_configure_errors}")
endif()
message("")
if(__qt_configure_an_error_occurred)
message(FATAL_ERROR "Check the configuration messages for an error that has occurred.")
endif()
file(APPEND "${summary_file}" "\n")
set(QT_INTERNAL_SUMMARY_INSTRUCTIONS_SHOWN "TRUE" CACHE STRING "" FORCE)
endfunction()
# Takes a list of arguments, and saves them to be evaluated at the end of the configuration
# phase when the configuration summary is shown.
#
# RECORD_ON_FEATURE_EVALUATION option allows to record the command even while the feature
# evaluation-only stage.
function(qt_configure_record_command)
cmake_parse_arguments(arg "RECORD_ON_FEATURE_EVALUATION"
""
"" ${ARGV})
# Don't record commands when only evaluating features of a configure.cmake file.
if(__QtFeature_only_evaluate_features AND NOT arg_RECORD_ON_FEATURE_EVALUATION)
return()
endif()
get_property(command_count GLOBAL PROPERTY qt_configure_command_count)
if(NOT DEFINED command_count)
set(command_count 0)
endif()
set_property(GLOBAL PROPERTY qt_configure_command_${command_count} "${arg_UNPARSED_ARGUMENTS}")
math(EXPR command_count "${command_count}+1")
set_property(GLOBAL PROPERTY qt_configure_command_count "${command_count}")
endfunction()
function(qt_configure_eval_commands)
get_property(command_count GLOBAL PROPERTY qt_configure_command_count)
if(NOT command_count)
set(command_count 0)
endif()
set(command_index 0)
while(command_index LESS command_count)
get_property(command_args GLOBAL PROPERTY qt_configure_command_${command_index})
if(NOT command_args)
message(FATAL_ERROR
"Empty arguments encountered while processing qt configure reports.")
endif()
list(POP_FRONT command_args command_name)
if(command_name STREQUAL ADD_SUMMARY_SECTION)
qt_configure_process_add_summary_section(${command_args})
elseif(command_name STREQUAL END_SUMMARY_SECTION)
qt_configure_process_end_summary_section(${command_args})
elseif(command_name STREQUAL ADD_REPORT_ENTRY)
qt_configure_process_add_report_entry(${command_args})
elseif(command_name STREQUAL ADD_SUMMARY_ENTRY)
qt_configure_process_add_summary_entry(${command_args})
elseif(command_name STREQUAL ADD_BUILD_TYPE_AND_CONFIG)
qt_configure_process_add_summary_build_type_and_config(${command_args})
elseif(command_name STREQUAL ADD_BUILD_MODE)
qt_configure_process_add_summary_build_mode(${command_args})
elseif(command_name STREQUAL ADD_BUILD_PARTS)
qt_configure_process_add_summary_build_parts(${command_args})
endif()
math(EXPR command_index "${command_index}+1")
endwhile()
# Propagate content to parent.
set(__qt_configure_reports "${__qt_configure_reports}" PARENT_SCOPE)
set(__qt_configure_notes "${__qt_configure_notes}" PARENT_SCOPE)
set(__qt_configure_warnings "${__qt_configure_warnings}" PARENT_SCOPE)
set(__qt_configure_errors "${__qt_configure_errors}" PARENT_SCOPE)
set(__qt_configure_an_error_occurred "${__qt_configure_an_error_occurred}" PARENT_SCOPE)
endfunction()
macro(qt_configure_add_report message)
string(APPEND __qt_configure_reports "\n${message}")
set(__qt_configure_reports "${__qt_configure_reports}" PARENT_SCOPE)
endmacro()
macro(qt_configure_add_report_padded label message)
qt_configure_get_padded_string("${__qt_configure_indent}${label}" "${message}" padded_message)
string(APPEND __qt_configure_reports "\n${padded_message}")
set(__qt_configure_reports "${__qt_configure_reports}" PARENT_SCOPE)
endmacro()
# Pad 'label' and 'value' with dots like this:
# "label ............... value"
#
# PADDING_LENGTH specifies the number of characters from the start to the last dot.
# Default is 30.
# MIN_PADDING specifies the minimum number of dots that are used for the padding.
# Default is 0.
function(qt_configure_get_padded_string label value out_var)
cmake_parse_arguments(arg "" "PADDING_LENGTH;MIN_PADDING" "" ${ARGN})
if("${arg_MIN_PADDING}" STREQUAL "")
set(arg_MIN_PADDING 0)
endif()
if(arg_PADDING_LENGTH)
set(pad_string "")
math(EXPR n "${arg_PADDING_LENGTH} - 1")
foreach(i RANGE ${n})
string(APPEND pad_string ".")
endforeach()
else()
set(pad_string ".........................................")
endif()
string(LENGTH "${label}" label_len)
string(LENGTH "${pad_string}" pad_len)
math(EXPR pad_len "${pad_len}-${label_len}")
if(pad_len LESS "0")
set(pad_len ${arg_MIN_PADDING})
endif()
string(SUBSTRING "${pad_string}" 0 "${pad_len}" pad_string)
set(output "${label} ${pad_string} ${value}")
set("${out_var}" "${output}" PARENT_SCOPE)
endfunction()
function(qt_configure_add_summary_entry)
qt_configure_record_command(ADD_SUMMARY_ENTRY ${ARGV})
endfunction()
function(qt_configure_process_add_summary_entry)
cmake_parse_arguments(PARSE_ARGV 0 arg
""
"ARGS;TYPE;MESSAGE"
"CONDITION")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_TYPE)
set(arg_TYPE "feature")
endif()
if(NOT "${arg_CONDITION}" STREQUAL "")
qt_evaluate_config_expression(condition_result ${arg_CONDITION})
if(NOT condition_result)
return()
endif()
endif()
if(arg_TYPE STREQUAL "firstAvailableFeature")
set(first_feature_found FALSE)
set(message "")
string(REPLACE " " ";" args_list "${arg_ARGS}")
foreach(feature ${args_list})
qt_feature_normalize_name("${feature}" feature)
if(NOT DEFINED QT_FEATURE_${feature})
message(FATAL_ERROR "Asking for a report on undefined feature ${feature}.")
endif()
if(QT_FEATURE_${feature})
set(first_feature_found TRUE)
set(message "${QT_FEATURE_LABEL_${feature}}")
break()
endif()
endforeach()
if(NOT first_feature_found)
set(message "<none>")
endif()
qt_configure_add_report_padded("${arg_MESSAGE}" "${message}")
elseif(arg_TYPE STREQUAL "featureList")
set(available_features "")
string(REPLACE " " ";" args_list "${arg_ARGS}")
foreach(feature ${args_list})
qt_feature_normalize_name("${feature}" feature)
if(NOT DEFINED QT_FEATURE_${feature})
message(FATAL_ERROR "Asking for a report on undefined feature ${feature}.")
endif()
if(QT_FEATURE_${feature})
list(APPEND available_features "${QT_FEATURE_LABEL_${feature}}")
endif()
endforeach()
if(NOT available_features)
set(message "<none>")
else()
list(JOIN available_features " " message)
endif()
qt_configure_add_report_padded("${arg_MESSAGE}" "${message}")
elseif(arg_TYPE STREQUAL "feature")
qt_feature_normalize_name("${arg_ARGS}" feature)
set(label "${QT_FEATURE_LABEL_${feature}}")
if(NOT label)
set(label "${feature}")
endif()
if(QT_FEATURE_${feature})
set(value "yes")
else()
set(value "no")
endif()
qt_configure_add_report_padded("${label}" "${value}")
elseif(arg_TYPE STREQUAL "message")
qt_configure_add_report_padded("${arg_ARGS}" "${arg_MESSAGE}")
endif()
endfunction()
function(qt_configure_add_summary_build_type_and_config)
qt_configure_record_command(ADD_BUILD_TYPE_AND_CONFIG ${ARGV})
endfunction()
function(qt_configure_process_add_summary_build_type_and_config)
get_property(subarch_summary GLOBAL PROPERTY qt_configure_subarch_summary)
if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES ";"))
set(message
"Building for: ${QT_QMAKE_TARGET_MKSPEC} (${CMAKE_OSX_ARCHITECTURES}), ${TEST_architecture_arch} features: ${subarch_summary})")
else()
set(message
"Building for: ${QT_QMAKE_TARGET_MKSPEC} (${TEST_architecture_arch}, CPU features: ${subarch_summary})")
endif()
qt_configure_add_report("${message}")
set(message "Compiler: ")
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
string(APPEND message "clang (Apple)")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
string(APPEND message "clang (Intel LLVM)")
elseif(CLANG)
string(APPEND message "clang")
elseif(QCC)
string(APPEND message "rim_qcc")
elseif(GCC)
string(APPEND message "gcc")
elseif(MSVC)
string(APPEND message "msvc")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GHS")
string(APPEND message "ghs")
else()
string(APPEND message "unknown (${CMAKE_CXX_COMPILER_ID})")
endif()
string(APPEND message " ${CMAKE_CXX_COMPILER_VERSION}")
qt_configure_add_report("${message}")
endfunction()
function(qt_configure_add_summary_build_mode)
qt_configure_record_command(ADD_BUILD_MODE ${ARGV})
endfunction()
function(qt_configure_process_add_summary_build_mode label)
set(message "")
if(DEFINED CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(APPEND message "debug")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
string(APPEND message "release")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
string(APPEND message "release (with debug info)")
else()
string(APPEND message "${CMAKE_BUILD_TYPE}")
endif()
elseif(DEFINED CMAKE_CONFIGURATION_TYPES)
if("Release" IN_LIST CMAKE_CONFIGURATION_TYPES
AND "Debug" IN_LIST CMAKE_CONFIGURATION_TYPES)
string(APPEND message "debug and release")
elseif("RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES
AND "Debug" IN_LIST CMAKE_CONFIGURATION_TYPES)
string(APPEND message "debug and release (with debug info)")
else()
string(APPEND message "${CMAKE_CONFIGURATION_TYPES}")
endif()
endif()
qt_configure_add_report_padded("${label}" "${message}")
endfunction()
function(qt_configure_add_summary_build_parts)
qt_configure_record_command(ADD_BUILD_PARTS ${ARGV})
endfunction()
function(qt_configure_process_add_summary_build_parts label)
qt_get_build_parts(parts)
string(REPLACE ";" " " message "${parts}")
qt_configure_add_report_padded("${label}" "${message}")
endfunction()
function(qt_configure_add_summary_section)
qt_configure_record_command(ADD_SUMMARY_SECTION ${ARGV})
endfunction()
function(qt_configure_process_add_summary_section)
cmake_parse_arguments(PARSE_ARGV 0 arg
""
"NAME"
"")
_qt_internal_validate_all_args_are_parsed(arg)
qt_configure_add_report("${__qt_configure_indent}${arg_NAME}:")
if(NOT DEFINED __qt_configure_indent)
set(__qt_configure_indent " " PARENT_SCOPE)
else()
set(__qt_configure_indent "${__qt_configure_indent} " PARENT_SCOPE)
endif()
endfunction()
function(qt_configure_end_summary_section)
qt_configure_record_command(END_SUMMARY_SECTION ${ARGV})
endfunction()
function(qt_configure_process_end_summary_section)
string(LENGTH "${__qt_configure_indent}" indent_len)
if(indent_len GREATER_EQUAL 2)
string(SUBSTRING "${__qt_configure_indent}" 2 -1 __qt_configure_indent)
set(__qt_configure_indent "${__qt_configure_indent}" PARENT_SCOPE)
endif()
endfunction()
function(qt_configure_add_report_entry)
qt_configure_record_command(ADD_REPORT_ENTRY ${ARGV})
endfunction()
function(qt_configure_add_report_error error)
message(SEND_ERROR "${error}")
qt_configure_add_report_entry(TYPE ERROR MESSAGE "${error}" CONDITION TRUE ${ARGN})
endfunction()
function(qt_configure_process_add_report_entry)
cmake_parse_arguments(PARSE_ARGV 0 arg
""
"TYPE;MESSAGE"
"CONDITION")
_qt_internal_validate_all_args_are_parsed(arg)
set(possible_types NOTE WARNING ERROR FATAL_ERROR)
if(NOT "${arg_TYPE}" IN_LIST possible_types)
message(FATAL_ERROR "qt_configure_add_report_entry: '${arg_TYPE}' is not a valid type.")
endif()
if(NOT arg_MESSAGE)
message(FATAL_ERROR "qt_configure_add_report_entry: Empty message given.")
endif()
if(arg_TYPE STREQUAL "NOTE")
set(contents_var "__qt_configure_notes")
set(prefix "Note: ")
elseif(arg_TYPE STREQUAL "WARNING")
set(contents_var "__qt_configure_warnings")
set(prefix "WARNING: ")
elseif(arg_TYPE STREQUAL "ERROR")
set(contents_var "__qt_configure_errors")
set(prefix "ERROR: ")
elseif(arg_TYPE STREQUAL "FATAL_ERROR")
set(contents_var "__qt_configure_errors")
set(prefix "FATAL ERROR: ")
endif()
if(NOT "${arg_CONDITION}" STREQUAL "")
qt_evaluate_config_expression(condition_result ${arg_CONDITION})
endif()
if("${arg_CONDITION}" STREQUAL "" OR condition_result)
set(new_report "${prefix}${arg_MESSAGE}")
string(APPEND "${contents_var}" "\n${new_report}")
if(arg_TYPE STREQUAL "ERROR" OR arg_TYPE STREQUAL "FATAL_ERROR")
set(__qt_configure_an_error_occurred "TRUE" PARENT_SCOPE)
endif()
endif()
set("${contents_var}" "${${contents_var}}" PARENT_SCOPE)
endfunction()

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(qt_single_test VERSION 6.0.0 LANGUAGES C CXX ASM)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)
include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake NO_POLICY_SCOPE)
# Get the absolute path of the passed-in project dir, relative to the current working directory
# of the calling script, rather than relative to this source directory.
# The calling script sets PWD. If not set, just use the passed-in value as-is.
if(DEFINED PWD)
get_filename_component(absolute_project_path "${QT_STANDALONE_TEST_PATH}" ABSOLUTE
BASE_DIR "${PWD}")
else()
set(absolute_project_path "${QT_STANDALONE_TEST_PATH}")
endif()
# If path does not include the drive letter, we try to add it.
get_filename_component(absolute_project_path "." REALPATH BASE_DIR "${absolute_project_path}")
if(NOT IS_DIRECTORY "${absolute_project_path}")
get_filename_component(filename "${absolute_project_path}" NAME)
get_filename_component(directory "${absolute_project_path}" DIRECTORY)
if(filename STREQUAL "CMakeLists.txt")
set(absolute_project_path "${directory}")
endif()
endif()
# Add the test project path as a subdirectory project.
add_subdirectory("${absolute_project_path}" "build_dir")

View File

@ -0,0 +1,26 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Includes QtSetup and friends for private CMake API.
qt_internal_project_setup()
qt_build_internals_set_up_private_api()
# Find all StandaloneTestsConfig.cmake files, and include them
# This will find all Qt packages that are required for standalone tests.
# It will find more packages that needed for a certain test, but will ensure any test can
# be built.
qt_get_standalone_tests_config_files_path(standalone_tests_config_path)
file(GLOB config_files "${standalone_tests_config_path}/*")
foreach(file ${config_files})
include("${file}")
endforeach()
# Set language standards after finding Core, because that's when the relevant
# feature variables are available.
qt_set_language_standards()
# Just before adding the test, change the local (non-cache) install prefix to something other than
# the Qt install prefix, so that tests don't try to install and pollute the Qt install prefix.
# Needs to be called after qt_get_standalone_tests_confg_files_path().
qt_set_up_fake_standalone_tests_install_prefix()

View File

@ -0,0 +1,170 @@
# Propagate common variables via BuildInternals package.
set(QT_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" @BUILD_SHARED_LIBS@)
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
set(INSTALL_CMAKE_NAMESPACE @INSTALL_CMAKE_NAMESPACE@)
set(QT_BUILD_INTERNALS_PATH "${CMAKE_CURRENT_LIST_DIR}")
# The relocatable install prefix is meant to be used to find things like host binaries (syncqt),
# when the CMAKE_INSTALL_PREFIX is overridden to point to a different path (like when building a
# a Qt repo using Conan, which will set a random install prefix instead of installing into the
# original Qt install prefix).
get_filename_component(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX
${CMAKE_CURRENT_LIST_DIR}/../@qt_path_from_cmake_config_dir_to_prefix@
ABSOLUTE)
# Stores in out_var the new install/staging prefix for this build.
#
# new_prefix: the new prefix for this repository
# orig_prefix: the prefix that was used when qtbase was configured
#
# On Windows hosts: if the original prefix does not start with a drive letter, this function removes
# the drive letter from the new prefix. This is needed for installation with DESTDIR set.
function(qt_internal_new_prefix out_var new_prefix orig_prefix)
if(CMAKE_HOST_WIN32)
set(drive_letter_regexp "^[a-zA-Z]:")
if(new_prefix MATCHES "${drive_letter_regexp}"
AND NOT orig_prefix MATCHES "${drive_letter_regexp}")
string(SUBSTRING "${new_prefix}" 2 -1 new_prefix)
endif()
endif()
set(${out_var} "${new_prefix}" PARENT_SCOPE)
endfunction()
# If no explicit CMAKE_INSTALL_PREFIX is provided, force set the original Qt installation prefix,
# so that further modules / repositories are installed into same original location.
# This means by default when configuring qtsvg / qtdeclarative, they will be installed the regular
# Qt installation prefix.
# If an explicit installation prefix is specified, honor it.
# This is an attempt to support Conan, aka handle installation of modules into a
# different installation prefix than the original one. Also allow to opt out via a special variable.
# In a top-level build, QtSetup.cmake takes care of setting CMAKE_INSTALL_PREFIX.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND
NOT QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX
AND NOT QT_SUPERBUILD)
set(qtbi_orig_prefix "@CMAKE_INSTALL_PREFIX@")
set(qtbi_orig_staging_prefix "@CMAKE_STAGING_PREFIX@")
qt_internal_new_prefix(qtbi_new_prefix
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}"
"${qtbi_orig_prefix}")
if(NOT qtbi_orig_staging_prefix STREQUAL ""
AND "${CMAKE_STAGING_PREFIX}" STREQUAL ""
AND NOT QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX)
qt_internal_new_prefix(qtbi_new_staging_prefix
"${qtbi_new_prefix}"
"${qtbi_orig_staging_prefix}")
set(CMAKE_STAGING_PREFIX "${qtbi_new_staging_prefix}" CACHE PATH
"Staging path prefix, prepended onto install directories on the host machine." FORCE)
set(qtbi_new_prefix "${qtbi_orig_prefix}")
endif()
set(CMAKE_INSTALL_PREFIX "${qtbi_new_prefix}" CACHE PATH
"Install path prefix, prepended onto install directories." FORCE)
unset(qtbi_orig_prefix)
unset(qtbi_new_prefix)
unset(qtbi_orig_staging_prefix)
unset(qtbi_new_staging_prefix)
endif()
# Propagate developer builds to other modules via BuildInternals package.
if(@FEATURE_developer_build@)
set(FEATURE_developer_build ON CACHE BOOL "Developer build." FORCE)
endif()
# Propagate non-prefix builds.
set(QT_WILL_INSTALL @QT_WILL_INSTALL@ CACHE BOOL
"Boolean indicating if doing a Qt prefix build (vs non-prefix build)." FORCE)
set(QT_SOURCE_TREE "@QT_SOURCE_TREE@" CACHE PATH
"A path to the source tree of the previously configured QtBase project." FORCE)
# Propagate decision of building tests and examples to other repositories.
set(QT_BUILD_TESTS @QT_BUILD_TESTS@ CACHE BOOL "Build the testing tree.")
set(QT_BUILD_EXAMPLES @QT_BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples")
set(QT_BUILD_BENCHMARKS @QT_BUILD_BENCHMARKS@ CACHE BOOL "Build Qt Benchmarks")
set(QT_BUILD_MANUAL_TESTS @QT_BUILD_MANUAL_TESTS@ CACHE BOOL "Build Qt manual tests")
set(QT_BUILD_MINIMAL_STATIC_TESTS @QT_BUILD_MINIMAL_STATIC_TESTS@ CACHE BOOL
"Build minimal subset of tests for static Qt builds")
set(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS @QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS@ CACHE BOOL
"Build minimal subset of tests for Android multi-ABI Qt builds")
set(QT_BUILD_TESTS_BATCHED @QT_BUILD_TESTS_BATCHED@ CACHE BOOL
"Should all tests be batched into a single binary.")
set(QT_BUILD_TESTS_BY_DEFAULT @QT_BUILD_TESTS_BY_DEFAULT@ CACHE BOOL
"Should tests be built as part of the default 'all' target.")
set(QT_BUILD_EXAMPLES_BY_DEFAULT @QT_BUILD_EXAMPLES_BY_DEFAULT@ CACHE BOOL
"Should examples be built as part of the default 'all' target.")
set(QT_BUILD_TOOLS_BY_DEFAULT @QT_BUILD_TOOLS_BY_DEFAULT@ CACHE BOOL
"Should tools be built as part of the default 'all' target.")
set(QT_BUILD_EXAMPLES_AS_EXTERNAL "@QT_BUILD_EXAMPLES_AS_EXTERNAL@" CACHE BOOL
"Should examples be built as ExternalProjects.")
# Propagate usage of ccache.
set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache")
# Propagate usage of unity build.
set(QT_UNITY_BUILD @QT_UNITY_BUILD@ CACHE BOOL "Enable unity (jumbo) build")
set(QT_UNITY_BUILD_BATCH_SIZE "@QT_UNITY_BUILD_BATCH_SIZE@" CACHE STRING "Unity build batch size")
# Propragate the value of WARNINGS_ARE_ERRORS.
set(WARNINGS_ARE_ERRORS "@WARNINGS_ARE_ERRORS@" CACHE BOOL "Build Qt with warnings as errors")
# Propagate usage of versioned hard link.
set(QT_CREATE_VERSIONED_HARD_LINK "@QT_CREATE_VERSIONED_HARD_LINK@" CACHE BOOL
"Enable the use of versioned hard link")
# The minimum version required to build Qt.
set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT "@supported_min_version_for_building_qt@")
set(QT_COMPUTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT "@computed_min_version_for_building_qt@")
# The lower and upper CMake version policy range as computed by qtbase.
# These values are inherited when building other Qt repositories, unless overridden
# in the respective repository .cmake.conf file.
# These are not cache variables, so that they can be overridden in each repo directory scope.
if(NOT DEFINED QT_MIN_NEW_POLICY_CMAKE_VERSION)
set(QT_MIN_NEW_POLICY_CMAKE_VERSION "@min_new_policy_version@")
endif()
if(NOT DEFINED QT_MAX_NEW_POLICY_CMAKE_VERSION)
set(QT_MAX_NEW_POLICY_CMAKE_VERSION "@max_new_policy_version@")
endif()
get_property(__qt_internal_extras_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
# We want the same build type to be used when configuring all Qt repos or standalone
# tests or single tests.
# To do that, we need to force-set the CMAKE_BUILD_TYPE cache var because CMake itself
# initializes it with the value of CMAKE_BUILD_TYPE_INIT at the start of project
# configuration, so we need to override it.
# Note the value of CMAKE_BUILD_TYPE_INIT is different based on the platform, most
# Linux and macOS platforms will have it empty, but Windows platforms will have a value.
#
# We can't reliably differentiate between a value set on the command line by the user
# and one set by CMake, so we use a few heuristics:
# 1) When using a qt.toolchain.cmake file, we rely on the toolchain file to tell us
# if a value was set by the user at initial configure time. On a 2nd run there will
# always be a value in the cache, but at that point we've already set it to whatever it needs
# to be.
# 2) If a toolchain file is not used, we rely on the value of the CMake internal
# CMAKE_BUILD_TYPE_INIT variable.
# This won't work reliably on Windows where CMAKE_BUILD_TYPE_INIT is non-empty.
#
# Both cases won't handle an empty "" config set by the user, but we claim that's an
# unsupported config when building Qt.
#
# Allow an opt out when QT_NO_FORCE_SET_CMAKE_BUILD_TYPE is set.
# Finally, don't set the variable if a multi-config generator is used. This can happen
# when qtbase is built with a single config, but a test is built with a multi-config generator.
function(qt_internal_force_set_cmake_build_type_conditionally value)
# STREQUAL check needs to be expanded variables because an undefined var is not equal to an
# empty defined var.
if("${CMAKE_BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE_INIT}"
AND NOT __qt_toolchain_cmake_build_type_before_project_call
AND NOT QT_NO_FORCE_SET_CMAKE_BUILD_TYPE
AND NOT __qt_internal_extras_is_multi_config)
set(CMAKE_BUILD_TYPE "${value}" CACHE STRING "Choose the type of build." FORCE)
endif()
endfunction()
# Extra set of exported variables
@QT_EXTRA_BUILD_INTERNALS_VARS@

235
cmake/QtCMakeHelpers.cmake Normal file
View File

@ -0,0 +1,235 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# The common implementation of qt_configure_file functionality.
macro(qt_configure_file_impl)
if(NOT arg_OUTPUT)
message(FATAL_ERROR "No output file provided to qt_configure_file.")
endif()
# We use this check for the cases when the specified CONTENT is empty. The value of arg_CONTENT
# is undefined, but we still want to create a file with empty content.
if(NOT "CONTENT" IN_LIST arg_KEYWORDS_MISSING_VALUES)
if(arg_INPUT)
message(WARNING "Both CONTENT and INPUT are specified. CONTENT will be used to generate"
" output")
endif()
set(template_name "QtFileConfigure.txt.in")
# When building qtbase, use the source template file.
# Otherwise use the installed file (basically wherever Qt6 package is found).
# This should work for non-prefix and superbuilds as well.
if(QtBase_SOURCE_DIR)
set(input_file "${QtBase_SOURCE_DIR}/cmake/${template_name}")
else()
set(input_file "${_qt_6_config_cmake_dir}/${template_name}")
endif()
set(__qt_file_configure_content "${arg_CONTENT}")
elseif(arg_INPUT)
set(input_file "${arg_INPUT}")
else()
message(FATAL_ERROR "No input value provided to qt_configure_file.")
endif()
configure_file("${input_file}" "${arg_OUTPUT}" @ONLY)
endmacro()
# qt_configure_file(OUTPUT output-file <INPUT input-file | CONTENT content>)
# input-file is relative to ${CMAKE_CURRENT_SOURCE_DIR}
# output-file is relative to ${CMAKE_CURRENT_BINARY_DIR}
#
# This function is similar to file(GENERATE OUTPUT) except it writes the content
# to the file at configure time, rather than at generate time.
#
# TODO: Once we require 3.18+, this can use file(CONFIGURE) in its implementation,
# or maybe its usage can be replaced by file(CONFIGURE). Until then, it uses
# configure_file() with a generic input file as source, when used with the CONTENT
# signature.
function(qt_configure_file)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "OUTPUT;INPUT;CONTENT" "")
qt_configure_file_impl()
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.
#
# TODO: Remove when all usage of qt_parse_all_arguments were replaced by
# cmake_parse_all_arguments(PARSEARGV) instances
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()
# Checks whether any unparsed arguments have been passed to the function at the call site.
# Use this right after `cmake_parse_arguments`.
function(_qt_internal_validate_all_args_are_parsed prefix)
if(DEFINED ${prefix}_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown arguments: (${${prefix}_UNPARSED_ARGUMENTS})")
endif()
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()
# 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)
string(JOIN "/" path ${ARGN})
set(${out_var} ${path} PARENT_SCOPE)
endfunction()
# qt_remove_args can remove arguments from an existing list of function
# arguments in order to pass a filtered list of arguments to a different function.
# Parameters:
# out_var: result of remove all arguments specified by ARGS_TO_REMOVE from ALL_ARGS
# ARGS_TO_REMOVE: Arguments to remove.
# ALL_ARGS: All arguments supplied to cmake_parse_arguments
# from which ARGS_TO_REMOVE should be removed from. We require all the
# arguments or we can't properly identify the range of the arguments detailed
# in ARGS_TO_REMOVE.
# ARGS: Arguments passed into the function, usually ${ARGV}
#
# E.g.:
# We want to forward all arguments from foo to bar, execpt ZZZ since it will
# trigger an error in bar.
#
# foo(target BAR .... ZZZ .... WWW ...)
# bar(target BAR.... WWW...)
#
# function(foo target)
# cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "BAR;ZZZ;WWW")
# qt_remove_args(forward_args
# ARGS_TO_REMOVE ${target} ZZZ
# ALL_ARGS ${target} BAR ZZZ WWW
# ARGS ${ARGV}
# )
# bar(${target} ${forward_args})
# endfunction()
#
function(qt_remove_args out_var)
cmake_parse_arguments(arg "" "" "ARGS_TO_REMOVE;ALL_ARGS;ARGS" ${ARGN})
set(result ${arg_ARGS})
foreach(arg IN LISTS arg_ARGS_TO_REMOVE)
# find arg
list(FIND result ${arg} find_result)
if (NOT find_result EQUAL -1)
# remove arg
list(REMOVE_AT result ${find_result})
list(LENGTH result result_len)
if(find_result EQUAL result_len)
# We removed the last argument, could have been an option keyword
continue()
endif()
list(GET result ${find_result} arg_current)
# remove values until we hit another arg or the end of the list
while(NOT "${arg_current}" IN_LIST arg_ALL_ARGS AND find_result LESS result_len)
list(REMOVE_AT result ${find_result})
list(LENGTH result result_len)
if (NOT find_result EQUAL result_len)
list(GET result ${find_result} arg_current)
endif()
endwhile()
endif()
endforeach()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
# Creates a regular expression that exactly matches the given string
# Found in https://gitlab.kitware.com/cmake/cmake/issues/18580
function(qt_re_escape out_var str)
string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${str}")
set(${out_var} ${regex} PARENT_SCOPE)
endfunction()
# Input: string
# Output: regex string to match the string case insensitively
# Example: "Release" -> "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$"
#
# Regular expressions like this are used in cmake_install.cmake files for case-insensitive string
# comparison.
function(qt_create_case_insensitive_regex out_var input)
set(result "^(")
string(LENGTH "${input}" n)
math(EXPR n "${n} - 1")
foreach(i RANGE 0 ${n})
string(SUBSTRING "${input}" ${i} 1 c)
string(TOUPPER "${c}" uc)
string(TOLOWER "${c}" lc)
string(APPEND result "[${uc}${lc}]")
endforeach()
string(APPEND result ")$")
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
# Gets a target property, and returns "" if the property was not found
function(qt_internal_get_target_property out_var target property)
get_target_property(result "${target}" "${property}")
if("${result}" STREQUAL "result-NOTFOUND")
set(result "")
endif()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
# Creates a wrapper ConfigVersion.cmake file to be loaded by find_package when checking for
# compatible versions. It expects a ConfigVersionImpl.cmake file in the same directory which will
# be included to do the regular version checks.
# The version check result might be overridden by the wrapper.
# package_name is used by the content of the wrapper file to include the basic package version file.
# example: Qt6Gui
# out_path should be the build path where the write the file.
function(qt_internal_write_qt_package_version_file package_name out_path)
set(extra_code "")
# Need to check for FEATURE_developer_build as well, because QT_FEATURE_developer_build is not
# yet available when configuring the file for the BuildInternals package.
if(FEATURE_developer_build OR QT_FEATURE_developer_build)
string(APPEND extra_code "
# Disabling version check because Qt was configured with -developer-build.
set(__qt_disable_package_version_check TRUE)
set(__qt_disable_package_version_check_due_to_developer_build TRUE)")
endif()
configure_file("${QT_CMAKE_DIR}/QtCMakePackageVersionFile.cmake.in" "${out_path}" @ONLY)
endfunction()

View File

@ -0,0 +1,65 @@
# Include the basic version config file to get results of regular version checking.
include("${CMAKE_CURRENT_LIST_DIR}/@package_name@ConfigVersionImpl.cmake")
set(__qt_disable_package_version_check FALSE)
# Allow to opt out of the version check.
if(QT_NO_PACKAGE_VERSION_CHECK)
set(__qt_disable_package_version_check TRUE)
endif()
# Extra CMake code begin
@extra_code@
# Extra CMake code end
if((NOT PACKAGE_VERSION_COMPATIBLE) OR PACKAGE_VERSION_UNSUITABLE)
set(__qt_package_version_incompatible TRUE)
else()
set(__qt_package_version_incompatible FALSE)
endif()
if(__qt_disable_package_version_check)
# Don't show the warning needlessly if we know that we're doing an exact search, and the
# version found is not the exactly same.
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT
AND NOT PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
endif()
# Warn if version check is disabled regardless if it's a Qt repo build or user project build.
# Allow to opt out of warning.
if(__qt_package_version_incompatible AND NOT QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING
AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
message(WARNING
"Package ${PACKAGE_FIND_NAME} with version ${PACKAGE_VERSION} was accepted as "
"compatible because QT_NO_PACKAGE_VERSION_CHECK was set to TRUE. There is no guarantee "
"the build will succeed. You can silence this warning by passing "
"-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE")
endif()
# Mark version as compatible. This is how we disable the version check.
set(PACKAGE_VERSION_COMPATIBLE TRUE)
unset(PACKAGE_VERSION_UNSUITABLE)
# If QT_REPO_MODULE_VERSION is set, that means we are building a Qt repo. Show message that one can
# disable the check if they need to.
elseif(QT_REPO_MODULE_VERSION AND __qt_package_version_incompatible)
if(PACKAGE_FIND_VERSION_RANGE)
set(__qt_package_version_message_prefix "Version range ${PACKAGE_FIND_VERSION_RANGE}")
else()
set(__qt_package_version_message_prefix "Version ${PACKAGE_FIND_VERSION}")
endif()
message(WARNING
"${__qt_package_version_message_prefix} of package ${PACKAGE_FIND_NAME} was requested but "
"an incompatible version was found: ${PACKAGE_VERSION}. You can pass "
"-DQT_NO_PACKAGE_VERSION_CHECK=TRUE to disable the version check and force the "
"incompatible version to be used. There is no guarantee the build will succeed. "
"Use at your own risk. "
"You can silence this warning by passing -DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE")
endif()
unset(__qt_disable_package_version_check)
unset(__qt_disable_package_version_check_due_to_developer_build)
unset(__qt_package_version_message_prefix)
unset(__qt_package_version_incompatible)

View File

@ -0,0 +1,232 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Returns the minimum supported CMake version required to /build/ Qt as originally advertised by Qt.
function(qt_internal_get_supported_min_cmake_version_for_building_qt out_var)
if(NOT DEFINED BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS is needed to decide the minimum CMake version. "
"It should have been set by this point.")
endif()
# First check if a value is already set in QtBuildInternalsExtras.cmake, which means we're
# building a repo other than qtbase and the minimum version was already recorded.
if(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT)
set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT}")
# We're building qtbase so the values come from .cmake.conf.
elseif(BUILD_SHARED_LIBS)
set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED}")
else()
set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC}")
endif()
set(${out_var} "${supported_version}" PARENT_SCOPE)
endfunction()
# Returns the minimum supported CMake version required to /use/ Qt as originally advertised by Qt.
function(qt_internal_get_supported_min_cmake_version_for_using_qt out_var)
if(NOT DEFINED BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS is needed to decide the minimum CMake version. "
"It should have been set by this point.")
endif()
if(BUILD_SHARED_LIBS)
set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED}")
else()
set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC}")
endif()
set(${out_var} "${supported_version}" PARENT_SCOPE)
endfunction()
# Returns the computed minimum supported CMake version required to /build/ Qt.
function(qt_internal_get_computed_min_cmake_version_for_building_qt out_var)
# An explicit override for those that take it upon themselves to fix the build system
# when using a CMake version lower than the one officially supported.
# Also useful for build testing locally with different minimum versions to observe different
# policy behaviors.
if(QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT)
set(computed_min_version "${QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT}")
# Set in QtBuildInternalsExtras.cmake, which means it was already computed as part of qtbase
# configuration.
elseif(QT_COMPUTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT)
set(computed_min_version "${QT_COMPUTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT}")
# No override was given and the version was not computed before, thus initialize with the
# default minimum.
else()
qt_internal_get_supported_min_cmake_version_for_building_qt(min_supported_version)
set(computed_min_version "${min_supported_version}")
endif()
set(${out_var} "${computed_min_version}" PARENT_SCOPE)
endfunction()
# Returns the computed minimum supported CMake version required to /use/ Qt.
function(qt_internal_get_computed_min_cmake_version_for_using_qt out_var)
# Allow overriding the required minimum CMake version for user projects, without forcing
# each project developer to have to override it manually.
if(QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT)
set(computed_min_version "${QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT}")
# No override was given, thus initialize with the default minimum.
else()
qt_internal_get_supported_min_cmake_version_for_using_qt(min_supported_version)
set(computed_min_version "${min_supported_version}")
endif()
set(${out_var} "${computed_min_version}" PARENT_SCOPE)
endfunction()
# Returns the oldest CMake version for which NEW policies should be enabled.
# It can be older than the minimum supported or computed CMake version, as it
# is only used for policy settings. The currently running CMake must not be
# older than this version though (doing so will result in an error).
function(qt_internal_get_min_new_policy_cmake_version out_var)
# QT_MIN_NEW_POLICY_CMAKE_VERSION is set either in .cmake.conf or in
# QtBuildInternalsExtras.cmake when building a child repo.
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION}")
set(${out_var} "${lower_version}" PARENT_SCOPE)
endfunction()
# Returns the latest CMake version for which NEW policies should be enabled.
# This cannot be less than the minimum CMake policy version or we will end up
# specifying a version range with the max less than the min.
function(qt_internal_get_max_new_policy_cmake_version out_var)
# QT_MAX_NEW_POLICY_CMAKE_VERSION is set either in .cmake.conf or in
# QtBuildInternalsExtras.cmake when building a child repo.
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION}")
qt_internal_get_min_new_policy_cmake_version(lower_version)
if(upper_version VERSION_LESS lower_version)
set(upper_version ${lower_version})
endif()
set(${out_var} "${upper_version}" PARENT_SCOPE)
endfunction()
function(qt_internal_check_and_warn_about_unsuitable_cmake_version)
# Don't show the warnings multiple times in a top-level build.
get_cmake_property(check_done _qt_unsuitable_cmake_version_check_done)
if(check_done)
return()
endif()
set_property(GLOBAL PROPERTY _qt_unsuitable_cmake_version_check_done TRUE)
qt_internal_warn_if_min_cmake_version_not_met()
qt_internal_warn_about_buggy_cmake_versions()
endfunction()
# Function to be used in downstream repos (like qtsvg) to require a minimum CMake version and warn
# about unsuitable cmake versions.
#
# Such repos don't have the required version information at cmake_minimum_required() time, that's
# why we provide this function to be called at a time when the info is available.
function(qt_internal_require_suitable_cmake_version)
qt_internal_check_and_warn_about_unsuitable_cmake_version()
qt_internal_get_computed_min_cmake_version_for_building_qt(computed_min_version)
if(CMAKE_VERSION VERSION_LESS computed_min_version)
set(major_minor "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
message(FATAL_ERROR
"CMake ${computed_min_version} or higher is required. "
"You are running version ${CMAKE_VERSION} "
"\nQt requires newer CMake features to build correctly. You can lower the minimum "
"required version by passing "
"-DQT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT=${major_minor} when configuring Qt. "
"Building Qt with this CMake version is not officially supported. Use at your own risk."
)
endif()
endfunction()
function(qt_internal_warn_if_min_cmake_version_not_met)
qt_internal_get_supported_min_cmake_version_for_building_qt(min_supported_version)
qt_internal_get_computed_min_cmake_version_for_building_qt(computed_min_version)
if(NOT min_supported_version STREQUAL computed_min_version
AND computed_min_version VERSION_LESS min_supported_version)
message(WARNING
"The minimum required CMake version to build Qt is: '${min_supported_version}'. "
"You have explicitly chosen to require a lower minimum CMake version: '${computed_min_version}'. "
"Building Qt with this CMake version is not officially supported. Use at your own risk.")
endif()
endfunction()
function(qt_internal_warn_about_buggy_cmake_versions)
set(unsuitable_versions "")
# Touching a library's source file causes unnecessary rebuilding of unrelated targets.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21020
list(APPEND unsuitable_versions "3.18.0")
# Ninja Multi-Config race condition overrides response files of different configurations
# https://gitlab.kitware.com/cmake/cmake/-/issues/20961
# https://gitlab.kitware.com/cmake/cmake/-/issues/21050 (follow up issue)
list(APPEND unsuitable_versions "3.18.1")
# AUTOMOC dependencies are not properly created when using Ninja Multi-Config.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21118
#
# Also until 3.18.2 inclusive, AUTOMOC dependencies are out-of-date if a previously header
# disappears (for example when upgrading a compiler)
# https://gitlab.kitware.com/cmake/cmake/-/issues/21136
#
# Also multi-arch PCH doesn't work on iOS. Can't quite find the original upstream CMake issue
# but the Qt one was detected at https://codereview.qt-project.org/c/qt/qt5/+/310947
# And a follow up issue regarding PCH and -fembed-bitcode failing.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21163
list(APPEND unsuitable_versions "3.18.2")
# Cyclic dependencies are created when mixing AUTOMOC/AUTOUIC with sources
# that have their SKIP_MOC or SKIP_UIC source file properties set to true.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21977
list(APPEND unsuitable_versions "3.20.0")
# AUTOMOC can crash or hang when using a Qt that supports moc depfiles.
# Issues reported on Windows with Ninja and Makefiles, but it could be happening
# on other platforms too.
# https://gitlab.kitware.com/cmake/cmake/-/issues/22014
list(APPEND unsuitable_versions "3.20.1")
# Cyclic dependencies can happen when the AUTOMOC / AUTOUIC include directory is added as a
# target include directory.
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6380
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6359
# https://gitlab.kitware.com/cmake/cmake/-/issues/16776
list(APPEND unsuitable_versions "3.21.0")
# Changing a C++ source file can trigger rebuilds of a lot of other source files that might
# include AUTOGEN'ed headers or sources.
# https://gitlab.kitware.com/cmake/cmake/-/issues/22531
# Fixed in 3.21.2.
list(APPEND unsuitable_versions "3.21.1")
foreach(unsuitable_version ${unsuitable_versions})
if(CMAKE_VERSION VERSION_EQUAL unsuitable_version)
message(WARNING
"The CMake version you are using is known to cause issues when building Qt. "
"Please upgrade to a newer version. "
"CMake version used: '${unsuitable_version}'")
endif()
endforeach()
# Ninja Multi-Config was introduced in 3.17, but we recommend 3.18.
set(min_nmc_cmake_version "3.18.3")
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config"
AND CMAKE_VERSION VERSION_LESS ${min_nmc_cmake_version})
message(WARNING
"You are using CMake ${CMAKE_VERSION} with the Ninja Multi-Config generator. "
"This combination is unsupported. "
"Please upgrade to at least CMake ${min_nmc_cmake_version}. ")
endif()
endfunction()
# Used to upgrade policies only when building Qt repositories.
#
# Functions don't have their own policy scope, so the policy settings modified
# here will be those of the caller's policy scope. Note that these settings
# will only apply to functions and macros defined after this function is called,
# but not to any that are already defined. Ordinary CMake code not inside a
# function or macro will be affected by these policy settings too.
function(qt_internal_upgrade_cmake_policies)
qt_internal_get_computed_min_cmake_version_for_building_qt(lower_version)
qt_internal_get_max_new_policy_cmake_version(upper_version)
cmake_minimum_required(VERSION ${lower_version}...${upper_version})
endfunction()

View File

@ -0,0 +1,34 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Enable compiler warnings by default. All compilers except MSVC support -Wall -Wextra
#
# You can disable the warnings for specific targets (for instance containing 3rd party code)
# by calling qt_disable_warnings(target). This will set the QT_COMPILE_OPTIONS_DISABLE_WARNINGS
# property checked below, and is equivalent to qmake's CONFIG += warn_off.
set(_qt_compiler_warning_flags_on "")
set(_qt_compiler_warning_flags_off "")
if (MSVC)
list(APPEND _qt_compiler_warning_flags_on /W3)
list(APPEND _qt_compiler_warning_flags_off -W0)
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GHS") # There is no -Wextra flag for GHS compiler.
list(APPEND _qt_compiler_warning_flags_on -Wall)
else()
list(APPEND _qt_compiler_warning_flags_on -Wall -Wextra)
endif()
list(APPEND _qt_compiler_warning_flags_off -w)
endif()
set(_qt_compiler_warning_flags_condition
"$<BOOL:$<TARGET_PROPERTY:QT_COMPILE_OPTIONS_DISABLE_WARNINGS>>")
set(_qt_compiler_warning_flags_genex
"$<IF:${_qt_compiler_warning_flags_condition},${_qt_compiler_warning_flags_off},${_qt_compiler_warning_flags_on}>")
# Need to replace semicolons so that the list is not wrongly expanded in the add_compile_options
# call.
string(REPLACE ";" "$<SEMICOLON>"
_qt_compiler_warning_flags_genex "${_qt_compiler_warning_flags_genex}")
add_compile_options(${_qt_compiler_warning_flags_genex})

View File

@ -0,0 +1,128 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
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}")
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_RDSEED "")
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")
set(QT_CFLAGS_AVX512VBMI2 "-arch:AVX512")
set(QT_CFLAGS_VAES "")
endif()
if(GCC OR CLANG OR 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_F16C "-mf16c")
set(QT_CFLAGS_RDRND "-mrdrnd")
set(QT_CFLAGS_RDSEED "-mrdseed")
set(QT_CFLAGS_AVX "-mavx")
set(QT_CFLAGS_AVX2 "-mavx2")
set(QT_CFLAGS_ARCH_HASWELL "-march=haswell")
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_AVX512VBMI2 "-mavx512vbmi2")
set(QT_CFLAGS_AESNI "-maes")
set(QT_CFLAGS_SHANI "-msha")
set(QT_CFLAGS_VAES "-mvaes")
if(NOT UIKIT AND NOT QT_64BIT)
set(QT_CFLAGS_NEON "-mfpu=neon")
endif()
set(QT_CFLAGS_MIPS_DSP "-mdsp")
set(QT_CFLAGS_MIPS_DSPR2 "-mdspr2")
endif()
# Fall through is important, so that more specific flags that might be missing are set by the
# previous base cases.
# This mirrors qmake's mkspecs QMAKE_CFLAGS_OPTIMIZE assignments (mostly).
#
# TODO: Missing mkspecs flags we don't handle below: win32-clang-g++, win32-clang-msvc, rtems-base
#
# gcc and clang base
if(GCC OR CLANG)
set(QT_CFLAGS_OPTIMIZE "-O2")
set(QT_CFLAGS_OPTIMIZE_FULL "-O3")
set(QT_CFLAGS_OPTIMIZE_DEBUG "-Og")
set(QT_CFLAGS_OPTIMIZE_SIZE "-Os")
if(CLANG)
set(QT_CFLAGS_OPTIMIZE_SIZE "-Oz")
endif()
endif()
# Flags that CMake might set, aka flags the compiler would see as valid values.
if(GCC OR CLANG OR QCC)
set(QT_CFLAGS_OPTIMIZE_VALID_VALUES "-O0" "-O1" "-O2" "-O3" "-Os" "-Oz")
endif()
# Windows MSVC
if(MSVC)
set(QT_CFLAGS_OPTIMIZE "-O2")
set(QT_CFLAGS_OPTIMIZE_DEBUG "-Od")
set(QT_CFLAGS_OPTIMIZE_SIZE "-O1")
set(QT_CFLAGS_OPTIMIZE_VALID_VALUES "/O2" "/O1" "/Od" "/Ob0" "/Ob1" "/Ob2" "/O0" "-O0")
if(CLANG)
set(QT_CFLAGS_OPTIMIZE_FULL "/clang:-O3")
set(QT_CFLAGS_OPTIMIZE_SIZE "/clang:-Oz")
endif()
endif()
# Android Clang
if(CLANG AND ANDROID)
if(QT_FEATURE_ltcg)
# When using LTCG, the linker cannot cope with -Oz. See QTBUG-89472 for details.
set(QT_CFLAGS_OPTIMIZE "-O2")
set(QT_CFLAGS_OPTIMIZE_FULL "-O3")
else()
set(QT_CFLAGS_OPTIMIZE "-Oz")
set(QT_CFLAGS_OPTIMIZE_FULL "-Oz")
endif()
endif()
# qcc
if (QCC)
set(QT_CFLAGS_OPTIMIZE "-O2")
set(QT_CFLAGS_OPTIMIZE_FULL "-O3")
endif()
# Emscripten Clang
if(WASM)
set(QT_CFLAGS_OPTIMIZE_DEBUG "-O2 -g") # -Og is not supported
set(QT_CFLAGS_SSE2 -O2 -msimd128 -msse -msse2)
endif()

216
cmake/QtConfig.cmake.in Normal file
View File

@ -0,0 +1,216 @@
@PACKAGE_INIT@
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@ConfigExtras.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeVersionHelpers.cmake")
__qt_internal_require_suitable_cmake_version_for_using_qt()
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
if (NOT QT_NO_CREATE_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
endif()
else()
# For examples using `find_package(...)` inside their CMakeLists.txt files:
# Make CMake's AUTOGEN detect this Qt version properly
set_directory_properties(PROPERTIES
QT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
QT_VERSION_MINOR @PROJECT_VERSION_MINOR@
QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
endif()
get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/extra-cmake-modules/find-modules")
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/kwin")
if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
# Add module directory to pick up custom Info.plist template for macOS
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/macos")
elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
# Add module directory to pick up custom Info.plist template for iOS
set(__qt_internal_cmake_ios_support_files_path "${_qt_import_prefix}/ios")
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
endif()
# Public helpers available to all Qt packages.
include("${CMAKE_CURRENT_LIST_DIR}/QtFeature.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicAppleHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFinalizerHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicPluginHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTargetHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicWalkLibsHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFindPackageHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicDependencyHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTestHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicToolHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeHelpers.cmake")
set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
"Additional directories where find(Qt6 ...) components are searched")
set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
"Additional directories where find(Qt6 ...) host Qt components are searched")
__qt_internal_collect_additional_prefix_paths(_qt_additional_packages_prefix_paths
QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
__qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefix_paths
QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
"${_qt_additional_host_packages_prefix_paths}")
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
endif()
# Propagate sanitizer flags to both internal Qt builds and user projects.
# Allow opt-out in case if downstream projects handle it in a different way.
set(QT_CONFIGURED_SANITIZER_OPTIONS "@ECM_ENABLE_SANITIZERS@")
if(QT_CONFIGURED_SANITIZER_OPTIONS
AND NOT __qt_sanitizer_options_set
AND NOT QT_NO_ADD_SANITIZER_OPTIONS)
set(ECM_ENABLE_SANITIZERS "${QT_CONFIGURED_SANITIZER_OPTIONS}")
include(
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake")
endif()
# Mark that the current directory scope has its sanitizer flags set.
set(__qt_sanitizer_options_set TRUE)
# Find required dependencies, if any.
include(CMakeFindDependencyMacro)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
_qt_internal_suggest_dependency_debugging(@INSTALL_CMAKE_NAMESPACE@
__qt_@INSTALL_CMAKE_NAMESPACE@_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
if(NOT @INSTALL_CMAKE_NAMESPACE@_FOUND)
# Clear the components, no need to look for them if dependencies were not found, otherwise
# you get a wall of recursive error messages.
set(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS "")
endif()
endif()
set(_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET)
if(@INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
set(_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET QUIET)
endif()
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(__qt_use_no_default_path_for_qt_packages "")
endif()
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
if(NOT "${QT_HOST_PATH}" STREQUAL ""
AND "${module}" MATCHES "Tools$"
AND NOT "${module}" MATCHES "UiTools$"
AND NOT "${module}" MATCHES "ShaderTools$"
AND NOT "${module}" MATCHES "^Tools$"
AND NOT QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION)
# Make sure that a Qt*Tools package is also looked up in QT_HOST_PATH.
# But don't match QtShaderTools and QtTools which are cross-compiled target package names.
# Allow opt out just in case.
get_filename_component(__qt_find_package_host_qt_path
"${Qt@PROJECT_VERSION_MAJOR@HostInfo_DIR}/.." ABSOLUTE)
set(__qt_backup_cmake_prefix_path "${CMAKE_PREFIX_PATH}")
set(__qt_backup_cmake_find_root_path "${CMAKE_FIND_ROOT_PATH}")
list(PREPEND CMAKE_PREFIX_PATH "${__qt_find_package_host_qt_path}"
${_qt_additional_host_packages_prefix_paths})
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}"
${_qt_additional_host_packages_root_paths})
endif()
_qt_internal_save_find_package_context_for_debugging(@INSTALL_CMAKE_NAMESPACE@${module})
if(NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
PATHS
${_qt_cmake_dir}
${_qt_additional_packages_prefix_paths}
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
${__qt_find_package_host_qt_path}
${_qt_additional_host_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
endif()
if(NOT "${__qt_find_package_host_qt_path}" STREQUAL "")
set(CMAKE_PREFIX_PATH "${__qt_backup_cmake_prefix_path}")
set(CMAKE_FIND_ROOT_PATH "${__qt_backup_cmake_find_root_path}")
unset(__qt_backup_cmake_prefix_path)
unset(__qt_backup_cmake_find_root_path)
unset(__qt_find_package_host_qt_path)
endif()
if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
set(_qt_expected_component_config_path
"${_qt_cmake_dir}/@INSTALL_CMAKE_NAMESPACE@${module}/@INSTALL_CMAKE_NAMESPACE@${module}Config.cmake")
get_filename_component(
_qt_expected_component_dir_path "${_qt_expected_component_config_path}" DIRECTORY)
set(_qt_component_not_found_msg
"\nExpected Config file at \"${_qt_expected_component_config_path}\"")
if(EXISTS "${_qt_expected_component_config_path}")
string(APPEND _qt_component_not_found_msg " exists \n")
else()
string(APPEND _qt_component_not_found_msg " does NOT exist\n")
endif()
set(_qt_candidate_component_dir_path "${@INSTALL_CMAKE_NAMESPACE@${module}_DIR}")
if(_qt_candidate_component_dir_path AND
NOT _qt_expected_component_dir_path STREQUAL _qt_candidate_component_dir_path)
string(APPEND _qt_component_not_found_msg
"\n@INSTALL_CMAKE_NAMESPACE@${module}_DIR was computed by CMake or specified on the "
"command line by the user: \"${_qt_candidate_component_dir_path}\" "
"\nThe expected and computed paths are different, which might be the reason for "
"the package not to be found.")
endif()
if(@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
set(_Qt_NOTFOUND_MESSAGE
"${_Qt_NOTFOUND_MESSAGE}Failed to find required Qt component \"${module}\". ${_qt_component_not_found_msg}")
set(_qt_full_component_name "@INSTALL_CMAKE_NAMESPACE@${module}")
_qt_internal_suggest_dependency_debugging(${_qt_full_component_name}
_qt_full_component_name _Qt_NOTFOUND_MESSAGE)
unset(_qt_full_component_name)
break()
elseif(NOT @INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
message(WARNING
"Failed to find optional Qt component \"${module}\". ${_qt_component_not_found_msg}")
endif()
unset(_qt_expected_component_config_path)
unset(_qt_expected_component_dir_path)
unset(_qt_candidate_component_dir_path)
unset(_qt_component_not_found_msg)
endif()
endforeach()
if(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS AND _Qt_NOTFOUND_MESSAGE)
set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
unset(_Qt_NOTFOUND_MESSAGE)
endif()
if(@INSTALL_CMAKE_NAMESPACE@_FOUND
AND COMMAND _qt_internal_override_example_install_dir_to_dot
AND NOT _qt_internal_example_dir_set_to_dot)
_qt_internal_override_example_install_dir_to_dot()
endif()
__qt_internal_defer_promote_targets_in_dir_scope_to_global()
if(CMAKE_VERSION VERSION_LESS 3.21)
__qt_internal_check_link_order_matters()
__qt_internal_check_cmp0099_available()
endif()

View File

@ -0,0 +1,24 @@
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
set(__qt_platform_requires_host_info_package "@platform_requires_host_info_package@")
set(__qt_platform_initial_qt_host_path "@qt_host_path_absolute@")
set(__qt_platform_initial_qt_host_path_cmake_dir "@qt_host_path_cmake_dir_absolute@")
_qt_internal_setup_qt_host_path(
"${__qt_platform_requires_host_info_package}"
"${__qt_platform_initial_qt_host_path}"
"${__qt_platform_initial_qt_host_path_cmake_dir}")
_qt_internal_find_host_info_package(${__qt_platform_requires_host_info_package})
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_third_party_deps "@third_party_deps@")
@third_party_extra@
# Don't propagate REQUIRED so we don't immediately FATAL_ERROR, rather let the find_dependency calls
# set _NOT_FOUND_MESSAGE which will be displayed by the includer of the Dependencies file.
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED FALSE)
_qt_internal_find_third_party_dependencies(@INSTALL_CMAKE_NAMESPACE@ __qt_third_party_deps)
set(@INSTALL_CMAKE_NAMESPACE@_FOUND TRUE)

View File

@ -0,0 +1,2 @@
set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT "@supported_min_version_for_using_qt@")
set(QT_COMPUTED_MIN_CMAKE_VERSION_FOR_USING_QT "@computed_min_version_for_using_qt@")

View File

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.16)
project(@configure_time_target@ LANGUAGES CXX)
set(packages "@packages@")
set(defines @defines@)
set(compile_options @compile_options@)
set(link_options @link_options@)
set(output_directory @output_directory@)
foreach(package IN LISTS packages)
find_package(${package} REQUIRED)
endforeach()
add_executable(@configure_time_target@ @win32@ @macosx_bundle@ @sources@)
set_target_properties(@configure_time_target@ PROPERTIES
INCLUDE_DIRECTORIES "@include_directories@"
RUNTIME_OUTPUT_DIRECTORY "${output_directory}"
)
target_compile_options(@configure_time_target@ PRIVATE ${compile_options})
target_compile_definitions(@configure_time_target@ PRIVATE ${defines})
target_link_options(@configure_time_target@ PRIVATE ${link_options})

View File

@ -0,0 +1,18 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# copy_if_different works incorrect in Windows if file size if bigger than 2GB.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/23052 and QTBUG-99491 for details.
cmake_minimum_required(VERSION 3.16)
set(copy_strategy "copy_if_different")
if(CMAKE_HOST_WIN32)
file(SIZE "${SRC_FILE_PATH}" size)
# If file size is bigger than 2GB copy it unconditionally
if(size GREATER_EQUAL 2147483648)
set(copy_strategy "copy")
endif()
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E ${copy_strategy} "${SRC_FILE_PATH}" "${DST_FILE_PATH}")

70
cmake/QtDbusHelpers.cmake Normal file
View File

@ -0,0 +1,70 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# helper to set up a qdbusxml2cpp rule
function(qt_create_qdbusxml2cpp_command target infile)
cmake_parse_arguments(PARSE_ARGV 2 arg
"ADAPTOR;INTERFACE"
"BASENAME"
"FLAGS")
_qt_internal_validate_all_args_are_parsed(arg)
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")
set(header_file_full "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h")
set(source_file_full "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.cpp")
add_custom_command(OUTPUT "${header_file_full}" "${source_file_full}"
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp ${arg_FLAGS} "${option}"
"${header_file}:${source_file}" "${absolute_in_file_path}"
DEPENDS "${absolute_in_file_path}" ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND_EXPAND_LISTS
VERBATIM)
target_sources("${target}" PRIVATE
"${header_file_full}"
"${source_file_full}"
)
endfunction()

View File

@ -0,0 +1,31 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Defers the connection 'dependent' -> 'dependency'
#
# The actual connection can be made by calling qt_internal_add_deferred_dependencies.
#
function(qt_internal_defer_dependency dependent dependency)
set_property(GLOBAL APPEND PROPERTY QT_DEFERRED_DEPENDENCIES ${doc_target} ${tool_target})
endfunction()
# Adds dependencies between targets that have been deferred by calling qt_internal_defer_dependency.
#
# This function checks whether the connection can be made (the dependency target exists).
# If the connection cannot be made, the deferred connection is left in the global property.
# Potentially, some later call to qt_internal_add_deferred_dependencies will add it.
#
function(qt_internal_add_deferred_dependencies)
unset(unknown_deps)
get_property(deferred_deps GLOBAL PROPERTY QT_DEFERRED_DEPENDENCIES)
while(deferred_deps)
list(POP_FRONT deferred_deps dependent)
list(POP_FRONT deferred_deps dependency)
if (TARGET ${dependency})
add_dependencies(${dependent} ${dependency})
else()
list(APPEND unknown_deps ${dependent} ${dependency})
endif()
endwhile()
set_property(GLOBAL PROPERTY QT_DEFERRED_DEPENDENCIES ${unknown_deps})
endfunction()

255
cmake/QtDocsHelpers.cmake Normal file
View File

@ -0,0 +1,255 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# This function adds a dependency between a doc-generating target like 'generate_docs_Gui'
# and the necessary tool target like 'qdoc'.
#
# If the target is not yet existing, save the dependency connection in a global property.
# The dependency is then added near the end of the top-level build after all subdirectories have
# been handled.
function(qt_internal_add_doc_tool_dependency doc_target tool_name)
qt_get_tool_target_name(tool_target ${tool_name})
if(TARGET ${tool_target})
add_dependencies(${doc_target} ${tool_target})
else()
qt_internal_defer_dependency(${doc_target} ${tool_target})
endif()
endfunction()
function(qt_internal_add_docs)
if(${ARGC} EQUAL 1)
# Function called from old generated CMakeLists.txt that was missing the target parameter
return()
endif()
if(NOT ${ARGC} EQUAL 2)
message(FATAL_ERROR "qt_add_docs called with the wrong number of arguments. Should be qt_add_docs(target path_to_project.qdocconf).")
return()
endif()
set(target ${ARGV0})
set(doc_project ${ARGV1})
# If a target is not built (which can happen for tools when crosscompiling), we shouldn't try
# to generate docs.
if(NOT TARGET "${target}")
return()
endif()
set(tool_dependencies_enabled TRUE)
if(NOT "${QT_HOST_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}")
elseif(QT_SUPERBUILD)
set(doc_tools_bin "${QtBase_BINARY_DIR}/${INSTALL_BINDIR}")
set(doc_tools_libexec "${QtBase_BINARY_DIR}/${INSTALL_LIBEXECDIR}")
else()
set(doc_tools_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
set(doc_tools_libexec "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}")
endif()
set(qdoc_bin "${doc_tools_bin}/qdoc${CMAKE_EXECUTABLE_SUFFIX}")
set(qtattributionsscanner_bin "${doc_tools_libexec}/qtattributionsscanner${CMAKE_EXECUTABLE_SUFFIX}")
set(qhelpgenerator_bin "${doc_tools_libexec}/qhelpgenerator${CMAKE_EXECUTABLE_SUFFIX}")
get_target_property(target_type ${target} TYPE)
if (NOT target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(target_bin_dir ${target} BINARY_DIR)
get_target_property(target_source_dir ${target} SOURCE_DIR)
else()
set(target_bin_dir ${CMAKE_CURRENT_BINARY_DIR})
set(target_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
endif()
set(doc_output_dir "${target_bin_dir}/.doc")
# Generate include dir list
set(target_include_dirs_file "${doc_output_dir}/$<CONFIG>/includes.txt")
set(prop_prefix "")
if(target_type STREQUAL "INTERFACE_LIBRARY")
set(prop_prefix "INTERFACE_")
endif()
set(include_path_prop "${prop_prefix}INCLUDE_DIRECTORIES")
set(include_paths_property "$<TARGET_PROPERTY:${target},${include_path_prop}>")
if (NOT target_type STREQUAL "UTILITY")
file(GENERATE
OUTPUT ${target_include_dirs_file}
CONTENT "$<$<BOOL:${include_paths_property}>:-I$<JOIN:${include_paths_property},\n-I>>"
)
set(include_path_args "@${target_include_dirs_file}")
else()
set(include_path_args "")
endif()
get_filename_component(doc_target "${doc_project}" NAME_WLE)
if (QT_WILL_INSTALL)
set(qdoc_output_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}/${doc_target}")
set(qdoc_qch_output_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}")
set(index_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}")
else()
set(qdoc_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${doc_target}")
set(qdoc_qch_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
set(index_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
endif()
# qtattributionsscanner
add_custom_target(qattributionsscanner_${target}
COMMAND ${qtattributionsscanner_bin}
${PROJECT_SOURCE_DIR}
--basedir "${PROJECT_SOURCE_DIR}/.."
--filter "QDocModule=${doc_target}"
-o "${target_bin_dir}/codeattributions.qdoc"
)
# prepare docs target
set(prepare_qdoc_args
-outputdir "${qdoc_output_dir}"
"${target_source_dir}/${doc_project}"
-prepare
-indexdir "${index_dir}"
-no-link-errors
"${include_path_args}"
)
if(NOT QT_BUILD_ONLINE_DOCS)
list(PREPEND prepare_qdoc_args
-installdir "${QT_INSTALL_DIR}/${INSTALL_DOCDIR}"
)
endif()
if(QT_SUPERBUILD)
set(qt_install_docs_env "${QtBase_BINARY_DIR}/${INSTALL_DOCDIR}")
elseif(QT_WILL_INSTALL)
set(qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
else()
set(qt_install_docs_env "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
endif()
set(qdoc_env_args
"QT_INSTALL_DOCS=\"${qt_install_docs_env}\""
"QT_VERSION=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
"QT_VER=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
"QT_VERSION_TAG=${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}"
"BUILDDIR=${target_bin_dir}"
)
add_custom_target(prepare_docs_${target}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
${qdoc_bin}
${prepare_qdoc_args}
)
add_dependencies(prepare_docs_${target} qattributionsscanner_${target})
if(NOT TARGET sync_all_public_headers)
add_custom_target(sync_all_public_headers)
endif()
add_dependencies(prepare_docs_${target} sync_all_public_headers)
# generate docs target
set(generate_qdoc_args
-outputdir "${qdoc_output_dir}"
"${target_source_dir}/${doc_project}"
-generate
-indexdir "${index_dir}"
"${include_path_args}"
)
if(NOT QT_BUILD_ONLINE_DOCS)
list(PREPEND generate_qdoc_args
-installdir "${QT_INSTALL_DIR}/${INSTALL_DOCDIR}"
)
endif()
foreach(target_prefix generate_top_level_docs generate_repo_docs generate_docs)
set(depends_arg "")
if(tool_dependencies_enabled)
set(depends_arg DEPENDS ${qdoc_bin})
endif()
add_custom_target(${target_prefix}_${target}
${depends_arg}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args} ${qdoc_bin} ${generate_qdoc_args})
endforeach()
add_dependencies(generate_docs_${target} prepare_docs_${target})
add_dependencies(generate_repo_docs_${target} ${qt_docs_prepare_target_name})
add_dependencies(generate_top_level_docs_${target} prepare_docs)
add_dependencies(generate_docs generate_top_level_docs_${target})
# html docs target
add_custom_target(html_docs_${target})
add_dependencies(html_docs_${target} generate_docs_${target})
# generate .qch
set(qch_file_name ${doc_target}.qch)
set(qch_file_path ${qdoc_qch_output_dir}/${qch_file_name})
foreach(target_prefix qch_top_level_docs qch_repo_docs qch_docs)
set(depends_arg "")
if(tool_dependencies_enabled)
set(depends_arg DEPENDS ${qhelpgenerator_bin})
endif()
add_custom_target(${target_prefix}_${target}
${depends_arg}
COMMAND ${qhelpgenerator_bin}
"${qdoc_output_dir}/${doc_target}.qhp"
-o "${qch_file_path}"
)
endforeach()
add_dependencies(qch_docs_${target} generate_docs_${target})
add_dependencies(qch_repo_docs_${target} ${qt_docs_generate_target_name})
add_dependencies(qch_top_level_docs_${target} generate_docs)
add_dependencies(qch_docs qch_top_level_docs_${target})
if (QT_WILL_INSTALL)
install(DIRECTORY "${qdoc_output_dir}/"
DESTINATION "${INSTALL_DOCDIR}/${doc_target}"
COMPONENT _install_html_docs_${target}
EXCLUDE_FROM_ALL
)
add_custom_target(install_html_docs_${target}
COMMAND ${CMAKE_COMMAND}
--install "${CMAKE_BINARY_DIR}"
--component _install_html_docs_${target}
COMMENT "Installing html docs for target ${target}"
)
install(FILES "${qch_file_path}"
DESTINATION "${INSTALL_DOCDIR}"
COMPONENT _install_qch_docs_${target}
EXCLUDE_FROM_ALL
)
add_custom_target(install_qch_docs_${target}
COMMAND ${CMAKE_COMMAND}
--install "${CMAKE_BINARY_DIR}"
--component _install_qch_docs_${target}
COMMENT "Installing qch docs for target ${target}"
)
else()
# Don't need to do anything when not installing
add_custom_target(install_html_docs_${target})
add_custom_target(install_qch_docs_${target})
endif()
add_custom_target(install_docs_${target})
add_dependencies(install_docs_${target} install_html_docs_${target} install_qch_docs_${target})
add_custom_target(docs_${target})
add_dependencies(docs_${target} html_docs_${target})
add_dependencies(docs_${target} qch_docs_${target})
add_dependencies(${qt_docs_prepare_target_name} prepare_docs_${target})
add_dependencies(${qt_docs_generate_target_name} generate_repo_docs_${target})
add_dependencies(${qt_docs_qch_target_name} qch_repo_docs_${target})
add_dependencies(${qt_docs_install_html_target_name} install_html_docs_${target})
add_dependencies(${qt_docs_install_qch_target_name} install_qch_docs_${target})
# Make sure that the necessary tools are built when running,
# for example 'cmake --build . --target generate_docs'.
if(tool_dependencies_enabled)
qt_internal_add_doc_tool_dependency(qattributionsscanner_${target} qtattributionsscanner)
qt_internal_add_doc_tool_dependency(prepare_docs_${target} qdoc)
qt_internal_add_doc_tool_dependency(qch_docs_${target} qhelpgenerator)
endif()
endfunction()

View File

@ -0,0 +1,493 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# This function creates a CMake target for a generic console or GUI binary.
# Please consider to use a more specific version target like the one created
# by qt_add_test or qt_add_tool below.
# One-value Arguments:
# CORE_LIBRARY
# The argument accepts 'Bootstrap' or 'None' values. If the argument value is set to
# 'Bootstrap' the Qt::Bootstrap library is linked to the executable instead of Qt::Core.
# The 'None' value points that core library is not necessary and avoids linking neither
# Qt::Core or Qt::Bootstrap libraries. Otherwise the Qt::Core library will be publicly
# linked to the executable target by default.
function(qt_internal_add_executable name)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${__qt_internal_add_executable_optional_args}"
"${__qt_internal_add_executable_single_args}"
"${__qt_internal_add_executable_multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
set(arg_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}")
endif()
get_filename_component(arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
ABSOLUTE BASE_DIR "${QT_BUILD_DIR}")
if ("x${arg_INSTALL_DIRECTORY}" STREQUAL "x")
set(arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}")
endif()
_qt_internal_create_executable(${name})
if(ANDROID)
_qt_internal_android_executable_finalizer(${name})
endif()
if(arg_QT_APP AND QT_FEATURE_debug_and_release AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0")
set_property(TARGET "${name}"
PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:${QT_MULTI_CONFIG_FIRST_CONFIG}>>")
endif()
if (arg_VERSION)
if(arg_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")
# nothing to do
elseif(arg_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
set(arg_VERSION "${arg_VERSION}.0")
elseif(arg_VERSION MATCHES "[0-9]+\\.[0-9]+")
set(arg_VERSION "${arg_VERSION}.0.0")
elseif (arg_VERSION MATCHES "[0-9]+")
set(arg_VERSION "${arg_VERSION}.0.0.0")
else()
message(FATAL_ERROR "Invalid version format")
endif()
endif()
if(arg_DELAY_TARGET_INFO)
# Delay the setting of target info properties if requested. Needed for scope finalization
# of Qt apps.
set_target_properties("${name}" PROPERTIES
QT_DELAYED_TARGET_VERSION "${arg_VERSION}"
QT_DELAYED_TARGET_PRODUCT "${arg_TARGET_PRODUCT}"
QT_DELAYED_TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
QT_DELAYED_TARGET_COMPANY "${arg_TARGET_COMPANY}"
QT_DELAYED_TARGET_COPYRIGHT "${arg_TARGET_COPYRIGHT}"
)
else()
if(NOT arg_TARGET_DESCRIPTION)
set(arg_TARGET_DESCRIPTION "Qt ${name}")
endif()
qt_set_target_info_properties(${name} ${ARGN}
TARGET_DESCRIPTION ${arg_TARGET_DESCRIPTION}
TARGET_VERSION ${arg_VERSION})
endif()
if (WIN32 AND NOT arg_DELAY_RC)
_qt_internal_generate_win32_rc_file(${name})
endif()
qt_set_common_target_properties(${name})
qt_internal_add_repo_local_defines(${name})
if(ANDROID)
# The above call to qt_set_common_target_properties() sets the symbol
# visibility to hidden, but for Android, we need main() to not be hidden
# because it has to be loadable at runtime using dlopen().
set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
set_property(TARGET ${name} PROPERTY CXX_VISIBILITY_PRESET default)
endif()
qt_autogen_tools_initial_setup(${name})
qt_skip_warnings_are_errors_when_repo_unclean("${name}")
set(extra_libraries "")
if(arg_CORE_LIBRARY STREQUAL "Bootstrap")
list(APPEND extra_libraries ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap)
elseif(NOT arg_CORE_LIBRARY STREQUAL "None")
list(APPEND extra_libraries ${QT_CMAKE_EXPORT_NAMESPACE}::Core)
endif()
set(private_includes
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${arg_INCLUDE_DIRECTORIES}
)
if(arg_PUBLIC_LIBRARIES)
message(WARNING
"qt_internal_add_executable's PUBLIC_LIBRARIES option is deprecated, and will be "
"removed in a future Qt version. Use the LIBRARIES option instead.")
endif()
if(arg_NO_UNITY_BUILD)
set(arg_NO_UNITY_BUILD "NO_UNITY_BUILD")
else()
set(arg_NO_UNITY_BUILD "")
endif()
qt_internal_extend_target("${name}"
${arg_NO_UNITY_BUILD}
SOURCES ${arg_SOURCES}
NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES ${private_includes}
DEFINES ${arg_DEFINES}
LIBRARIES
${arg_LIBRARIES}
${arg_PUBLIC_LIBRARIES}
Qt::PlatformCommonInternal
${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}"
LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
WIN32_EXECUTABLE "${arg_GUI}"
MACOSX_BUNDLE "${arg_GUI}"
)
if(WASM)
# WASM unconditionally sets DISABLE_EXCEPTION_CATCHING=1
qt_internal_set_exceptions_flags("${name}" NO_EXCEPTIONS)
else()
qt_internal_set_exceptions_flags("${name}" ${arg_EXCEPTIONS})
endif()
if(WASM)
qt_internal_wasm_add_finalizers("${name}")
endif()
# Check if target needs to be excluded from all target. Also affects qt_install.
# Set by qt_exclude_tool_directories_from_default_target.
set(exclude_from_all FALSE)
if(__qt_exclude_tool_directories)
foreach(absolute_dir ${__qt_exclude_tool_directories})
string(FIND "${CMAKE_CURRENT_SOURCE_DIR}" "${absolute_dir}" dir_starting_pos)
if(dir_starting_pos EQUAL 0)
set(exclude_from_all TRUE)
set_target_properties("${name}" PROPERTIES EXCLUDE_FROM_ALL TRUE)
break()
endif()
endforeach()
endif()
if(NOT arg_NO_INSTALL)
set(additional_install_args "")
if(exclude_from_all)
list(APPEND additional_install_args EXCLUDE_FROM_ALL COMPONENT "ExcludedExecutables")
endif()
qt_get_cmake_configurations(cmake_configs)
foreach(cmake_config ${cmake_configs})
qt_get_install_target_default_args(
OUT_VAR install_targets_default_args
CMAKE_CONFIG "${cmake_config}"
ALL_CMAKE_CONFIGS "${cmake_configs}"
RUNTIME "${arg_INSTALL_DIRECTORY}"
LIBRARY "${arg_INSTALL_DIRECTORY}"
BUNDLE "${arg_INSTALL_DIRECTORY}")
# Make installation optional for targets that are not built by default in this config
if(NOT exclude_from_all AND arg_QT_APP AND QT_FEATURE_debug_and_release
AND NOT (cmake_config STREQUAL QT_MULTI_CONFIG_FIRST_CONFIG))
set(install_optional_arg "OPTIONAL")
else()
unset(install_optional_arg)
endif()
qt_install(TARGETS "${name}"
${additional_install_args} # Needs to be before the DESTINATIONS.
${install_optional_arg}
CONFIGURATIONS ${cmake_config}
${install_targets_default_args})
endforeach()
if(NOT exclude_from_all AND arg_QT_APP AND QT_FEATURE_debug_and_release)
set(separate_debug_info_executable_arg "QT_EXECUTABLE")
else()
unset(separate_debug_info_executable_arg)
endif()
qt_enable_separate_debug_info(${name} "${arg_INSTALL_DIRECTORY}"
${separate_debug_info_executable_arg}
ADDITIONAL_INSTALL_ARGS ${additional_install_args})
qt_internal_install_pdb_files(${name} "${arg_INSTALL_DIRECTORY}")
endif()
# If linking against Gui, make sure to also build the default QPA plugin.
# This makes the experience of an initial Qt configuration to build and run one single
# test / executable nicer.
get_target_property(linked_libs "${name}" LINK_LIBRARIES)
if("Qt::Gui" IN_LIST linked_libs AND TARGET qpa_default_plugins)
add_dependencies("${name}" qpa_default_plugins)
endif()
# For static plugins, we need to explicitly link to plugins we want to be
# loaded with the executable. User projects get that automatically, but
# for tools built as part of Qt, we can't use that mechanism because it
# would pollute the targets we export as part of an install and lead to
# circular dependencies. The logic here is a simpler equivalent of the
# more dynamic logic in QtPlugins.cmake.in, but restricted to only
# adding plugins that are provided by the same module as the module
# libraries the executable links to.
set(libs
${arg_LIBRARIES}
${arg_PUBLIC_LIBRARIES}
${extra_libraries}
Qt::PlatformCommonInternal
)
set(deduped_libs "")
foreach(lib IN LISTS libs)
if(NOT TARGET "${lib}")
continue()
endif()
# Normalize module by stripping any leading "Qt::", because properties are set on the
# versioned target (either Gui when building the module, or Qt6::Gui when it's
# imported).
if(lib MATCHES "Qt::([-_A-Za-z0-9]+)")
set(new_lib "${QT_CMAKE_EXPORT_NAMESPACE}::${CMAKE_MATCH_1}")
if(TARGET "${new_lib}")
set(lib "${new_lib}")
endif()
endif()
# Unalias the target.
get_target_property(aliased_target ${lib} ALIASED_TARGET)
if(aliased_target)
set(lib ${aliased_target})
endif()
list(APPEND deduped_libs "${lib}")
endforeach()
list(REMOVE_DUPLICATES deduped_libs)
foreach(lib IN LISTS deduped_libs)
string(MAKE_C_IDENTIFIER "${name}_plugin_imports_${lib}" out_file)
string(APPEND out_file .cpp)
# Initialize plugins that are built in the same repository as the Qt module 'lib'.
set(class_names_regular
"$<GENEX_EVAL:$<TARGET_PROPERTY:${lib},_qt_initial_repo_plugin_class_names>>")
# Initialize plugins that are built in the current Qt repository, but are associated
# with a Qt module from a different repository (qtsvg's QSvgPlugin associated with
# qtbase's QtGui).
string(MAKE_C_IDENTIFIER "${PROJECT_NAME}" current_project_name)
set(prop_prefix "_qt_repo_${current_project_name}")
set(class_names_current_project
"$<GENEX_EVAL:$<TARGET_PROPERTY:${lib},${prop_prefix}_plugin_class_names>>")
# Only add separator if first list is not empty, so we don't trigger the file generation
# when all lists are empty.
set(class_names_separator "$<$<NOT:$<STREQUAL:${class_names_regular},>>:;>" )
set(class_names
"${class_names_regular}${class_names_separator}${class_names_current_project}")
set(out_file_path "${CMAKE_CURRENT_BINARY_DIR}/${out_file}")
file(GENERATE OUTPUT "${out_file_path}" CONTENT
"// This file is auto-generated. Do not edit.
#include <QtPlugin>
Q_IMPORT_PLUGIN($<JOIN:${class_names},)\nQ_IMPORT_PLUGIN(>)
"
CONDITION "$<NOT:$<STREQUAL:${class_names},>>"
)
# CMake versions earlier than 3.18.0 can't find the generated file for some reason,
# failing at generation phase.
# Explicitly marking the file as GENERATED fixes the issue.
set_source_files_properties("${out_file_path}" PROPERTIES GENERATED TRUE)
target_sources(${name} PRIVATE
"$<$<NOT:$<STREQUAL:${class_names},>>:${out_file_path}>"
)
target_link_libraries(${name} PRIVATE
"$<TARGET_PROPERTY:${lib},_qt_initial_repo_plugins>"
"$<TARGET_PROPERTY:${lib},${prop_prefix}_plugins>")
endforeach()
endfunction()
# This function compiles the target at configure time the very first time and creates the custom
# ${target}_build that re-runs compilation at build time if necessary. The resulting executable is
# imported under the provided target name. This function should only be used to compile tiny
# executables with system dependencies only.
# One-value Arguments:
# CMAKELISTS_TEMPLATE
# The CMakeLists.txt templated that is used to configure the project
# for an executable. By default the predefined template from the Qt installation is used.
# INSTALL_DIRECTORY
# installation directory of the executable. Ignored if NO_INSTALL is set.
# OUTPUT_NAME
# the output name of an executable
# CONFIG
# the name of configuration that tool needs to be build with.
# Multi-value Arguments:
# PACKAGES
# list of system packages are required to successfully build the project.
# INCLUDES
# list of include directories are required to successfully build the project.
# DEFINES
# list of definitions are required to successfully build the project.
# COMPILE_OPTIONS
# list of compiler options are required to successfully build the project.
# LINK_OPTIONS
# list of linker options are required to successfully build the project.
# SOURCES
# list of project sources.
# CMAKE_FLAGS
# specify flags of the form -DVAR:TYPE=VALUE to be passed to the cmake command-line used to
# drive the test build.
# Options:
# WIN32
# reflects the corresponding add_executable argument.
# MACOSX_BUNDLE
# reflects the corresponding add_executable argument.
# NO_INSTALL
# avoids installing the tool.
function(qt_internal_add_configure_time_executable target)
set(one_value_args
CMAKELISTS_TEMPLATE
INSTALL_DIRECTORY
OUTPUT_NAME
CONFIG
)
set(multi_value_args
PACKAGES
INCLUDES
DEFINES
COMPILE_OPTIONS
LINK_OPTIONS
SOURCES
CMAKE_FLAGS
)
set(option_args WIN32 MACOSX_BUNDLE NO_INSTALL)
cmake_parse_arguments(PARSE_ARGV 1 arg
"${option_args}" "${one_value_args}" "${multi_value_args}")
set(target_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/configure_time_bins")
if(arg_CONFIG)
set(CMAKE_TRY_COMPILE_CONFIGURATION "${arg_CONFIG}")
endif()
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config AND CMAKE_TRY_COMPILE_CONFIGURATION)
set(configuration_path "${CMAKE_TRY_COMPILE_CONFIGURATION}/")
set(config_build_arg "--config" "${CMAKE_TRY_COMPILE_CONFIGURATION}")
endif()
set(configure_time_target "${target}")
if(arg_OUTPUT_NAME)
set(configure_time_target "${arg_OUTPUT_NAME}")
endif()
set(target_binary "${configure_time_target}${CMAKE_EXECUTABLE_SUFFIX}")
set(install_dir "${INSTALL_BINDIR}")
if(arg_INSTALL_DIRECTORY)
set(install_dir "${arg_INSTALL_DIRECTORY}")
endif()
set(output_directory "${QT_BUILD_DIR}/${install_dir}")
set(target_binary_path
"${output_directory}/${configuration_path}${target_binary}")
get_filename_component(target_binary_path "${target_binary_path}" ABSOLUTE)
if(NOT DEFINED arg_SOURCES)
message(FATAL_ERROR "No SOURCES given to target: ${target}")
endif()
set(sources "${arg_SOURCES}")
# Timestamp file is required because CMake ignores 'add_custom_command' if we use only the
# binary file as the OUTPUT.
set(timestamp_file "${target_binary_dir}/${target_binary}_timestamp")
add_custom_command(OUTPUT "${target_binary_path}" "${timestamp_file}"
COMMAND
${CMAKE_COMMAND} --build "${target_binary_dir}" --clean-first ${config_build_arg}
COMMAND
${CMAKE_COMMAND} -E touch "${timestamp_file}"
DEPENDS
${sources}
COMMENT
"Compiling ${target}"
VERBATIM
)
add_custom_target(${target}_build ALL
DEPENDS
"${target_binary_path}"
"${timestamp_file}"
)
set(should_build_at_configure_time TRUE)
if(EXISTS "${target_binary_path}")
set(last_ts 0)
foreach(source IN LISTS sources)
file(TIMESTAMP "${source}" ts "%s")
if(${ts} GREATER ${last_ts})
set(last_ts ${ts})
endif()
endforeach()
file(TIMESTAMP "${target_binary_path}" ts "%s")
if(${ts} GREATER_EQUAL ${last_ts})
set(should_build_at_configure_time FALSE)
endif()
endif()
if(should_build_at_configure_time)
foreach(arg IN LISTS multi_value_args)
string(TOLOWER "${arg}" template_arg_name)
set(${template_arg_name} "")
if(DEFINED arg_${arg})
set(${template_arg_name} "${arg_${arg}}")
endif()
endforeach()
foreach(arg IN LISTS option_args)
string(TOLOWER "${arg}" template_arg_name)
set(${template_arg_name} "")
if(arg_${arg})
set(${template_arg_name} "${arg}")
endif()
endforeach()
file(MAKE_DIRECTORY "${target_binary_dir}")
set(template "${QT_CMAKE_DIR}/QtConfigureTimeExecutableCMakeLists.txt.in")
if(DEFINED arg_CMAKELISTS_TEMPLATE)
set(template "${arg_CMAKELISTS_TEMPLATE}")
endif()
set(cmake_flags_arg)
if(arg_CMAKE_FLAGS)
set(cmake_flags_arg CMAKE_FLAGS "${arg_CMAKE_FLAGS}")
endif()
configure_file("${template}" "${target_binary_dir}/CMakeLists.txt" @ONLY)
try_compile(result
"${target_binary_dir}"
"${target_binary_dir}"
${target}
${cmake_flags_arg}
OUTPUT_VARIABLE try_compile_output
)
file(WRITE "${timestamp_file}" "")
if(NOT result)
message(FATAL_ERROR "Unable to build ${target}: ${try_compile_output}")
endif()
endif()
add_executable(${target} IMPORTED GLOBAL)
add_executable(${QT_CMAKE_EXPORT_NAMESPACE}::${target} ALIAS ${target})
set_target_properties(${target} PROPERTIES
_qt_internal_configure_time_target TRUE
IMPORTED_LOCATION "${target_binary_path}")
if(NOT arg_NO_INSTALL)
set_target_properties(${target} PROPERTIES
_qt_internal_configure_time_target_install_location
"${install_dir}/${target_binary}"
)
qt_path_join(target_install_dir ${QT_INSTALL_DIR} ${install_dir})
qt_install(PROGRAMS "${target_binary_path}" DESTINATION "${target_install_dir}")
endif()
endfunction()

1278
cmake/QtFeature.cmake Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
function(qt_feature_normalize_name name out_var)
# Normalize the feature name to something CMake can deal with.
if(name MATCHES "c\\+\\+")
string(REGEX REPLACE "[^a-zA-Z0-9_]" "x" name "${name}")
else()
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" name "${name}")
endif()
set(${out_var} "${name}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1 @@
@__qt_file_configure_content@

View File

@ -0,0 +1,535 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# This function recursively walks transitive link libraries of the given target
# and promotes those targets to be IMPORTED_GLOBAL if they are not.
#
# This is required for .prl file generation in top-level builds, to make sure that imported 3rd
# party library targets in any repo are made global, so there are no scoping issues.
#
# Only works if called from qt_find_package(), because the promotion needs to happen in the same
# directory scope where the imported target is first created.
#
# Uses __qt_internal_walk_libs.
function(qt_find_package_promote_targets_to_global_scope target)
__qt_internal_walk_libs("${target}" _discarded_out_var _discarded_out_var_2
"qt_find_package_targets_dict" "promote_global")
endfunction()
macro(qt_find_package)
# Get the target names we expect to be provided by the package.
set(find_package_options CONFIG NO_MODULE MODULE REQUIRED)
set(options ${find_package_options} MARK_OPTIONAL)
set(oneValueArgs MODULE_NAME QMAKE_LIB)
set(multiValueArgs PROVIDED_TARGETS COMPONENTS OPTIONAL_COMPONENTS)
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# If some Qt internal project calls qt_find_package(WrapFreeType), but WrapFreeType was already
# found as part of a find_dependency() call from a ModuleDependencies.cmake file (or similar),
# and the provided target is also found, that means this might have been an unnecessary
# qt_find_package() call, because the dependency was already found via some other transitive
# dependency. Return early, so that CMake doesn't fail with an error with trying to promote the
# targets to be global. This behavior is not enabled by default, because there are cases
# when a regular find_package() (non qt_) can find a package (Freetype -> PNG), and a subsequent
# qt_find_package(PNG PROVIDED_TARGET PNG::PNG) still needs to succeed and register the provided
# targets. To enable the debugging behavior, set QT_DEBUG_QT_FIND_PACKAGE to 1.
set(_qt_find_package_skip_find_package FALSE)
# Skip looking for packages that were not found on initial configuration, because they likely
# won't be found again, and only waste configuration time.
# Speeds up reconfiguration configuration for certain platforms and repos.
# Due to this behavior being different from what general CMake projects expect, it is only
# done for -developer-builds.
if(QT_INTERNAL_PREVIOUSLY_FOUND_PACKAGES AND
NOT "${ARGV0}" IN_LIST QT_INTERNAL_PREVIOUSLY_FOUND_PACKAGES)
set(_qt_find_package_skip_find_package TRUE)
endif()
if(QT_DEBUG_QT_FIND_PACKAGE AND ${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
set(_qt_find_package_skip_find_package TRUE)
foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
if(NOT TARGET ${qt_find_package_target_name})
set(_qt_find_package_skip_find_package FALSE)
endif()
endforeach()
if(_qt_find_package_skip_find_package)
message(AUTHOR_WARNING "qt_find_package(${ARGV0}) called even though the package "
"was already found. Consider removing the call.")
endif()
endif()
# When configure.cmake is included only to record summary entries, there's no point in looking
# for the packages.
if(__QtFeature_only_record_summary_entries)
set(_qt_find_package_skip_find_package TRUE)
endif()
# Get the version if specified.
set(package_version "")
if(${ARGC} GREATER_EQUAL 2)
if(${ARGV1} MATCHES "^[0-9\.]+$")
set(package_version "${ARGV1}")
endif()
endif()
if(arg_COMPONENTS)
# Re-append components to forward them.
list(APPEND arg_UNPARSED_ARGUMENTS "COMPONENTS;${arg_COMPONENTS}")
endif()
if(arg_OPTIONAL_COMPONENTS)
# Re-append optional components to forward them.
list(APPEND arg_UNPARSED_ARGUMENTS "OPTIONAL_COMPONENTS;${arg_OPTIONAL_COMPONENTS}")
endif()
# Don't look for packages in PATH if requested to.
if(QT_NO_USE_FIND_PACKAGE_SYSTEM_ENVIRONMENT_PATH)
set(_qt_find_package_use_system_env_backup "${CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH}")
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH "OFF")
endif()
if(NOT (arg_CONFIG OR arg_NO_MODULE OR arg_MODULE) AND NOT _qt_find_package_skip_find_package)
# Try to find a config package first in quiet mode
set(config_package_arg ${arg_UNPARSED_ARGUMENTS})
list(APPEND config_package_arg "CONFIG;QUIET")
find_package(${config_package_arg})
# Double check that in config mode the targets become visible. Sometimes
# only the module mode creates the targets. For example with vcpkg, the sqlite
# package provides sqlite3-config.cmake, which offers multi-config targets but
# in their own way. CMake has FindSQLite3.cmake and with the original
# qt_find_package(SQLite3) call it is our intention to use the cmake package
# in module mode.
unset(_qt_any_target_found)
unset(_qt_should_unset_found_var)
if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
foreach(expected_target ${arg_PROVIDED_TARGETS})
if (TARGET ${expected_target})
set(_qt_any_target_found TRUE)
break()
endif()
endforeach()
if(NOT _qt_any_target_found)
set(_qt_should_unset_found_var TRUE)
endif()
endif()
# If we consider the package not to be found, make sure to unset both regular
# and CACHE vars, otherwise CMP0126 set to NEW might cause issues with
# packages not being found correctly.
if(NOT ${ARGV0}_FOUND OR _qt_should_unset_found_var)
unset(${ARGV0}_FOUND)
unset(${ARGV0}_FOUND CACHE)
# Unset the NOTFOUND ${package}_DIR var that might have been set by the previous
# find_package call, to get rid of "not found" messages in the feature summary
# if the package is found by the next find_package call.
if(DEFINED CACHE{${ARGV0}_DIR} AND NOT ${ARGV0}_DIR)
unset(${ARGV0}_DIR CACHE)
endif()
endif()
endif()
# Ensure the options are back in the original unparsed arguments
foreach(opt IN LISTS find_package_options)
if(arg_${opt})
list(APPEND arg_UNPARSED_ARGUMENTS ${opt})
endif()
endforeach()
# TODO: Handle packages with components where a previous component is already found.
# E.g. find_package(Qt6 COMPONENTS BuildInternals) followed by
# qt_find_package(Qt6 COMPONENTS Core) doesn't end up calling find_package(Qt6Core).
if (NOT ${ARGV0}_FOUND AND NOT _qt_find_package_skip_find_package)
# Call original function without our custom arguments.
find_package(${arg_UNPARSED_ARGUMENTS})
endif()
if(QT_NO_USE_FIND_PACKAGE_SYSTEM_ENVIRONMENT_PATH)
if("${_qt_find_package_use_system_env_backup}" STREQUAL "")
unset(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH)
else()
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH "${_qt_find_package_use_system_env_backup}")
endif()
endif()
if(${ARGV0}_FOUND)
# Record that the package was found, so that future reconfigurations can be sped up.
set_property(GLOBAL APPEND PROPERTY _qt_previously_found_packages "${ARGV0}")
endif()
if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS AND NOT _qt_find_package_skip_find_package)
# If package was found, associate each target with its package name. This will be used
# later when creating Config files for Qt libraries, to generate correct find_dependency()
# calls. Also make the provided targets global, so that the properties can be read in
# all scopes.
foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
if(TARGET ${qt_find_package_target_name})
# Allow usage of aliased targets by setting properties on the actual target
get_target_property(aliased_target ${qt_find_package_target_name} ALIASED_TARGET)
if(aliased_target)
set(qt_find_package_target_name ${aliased_target})
endif()
set_target_properties(${qt_find_package_target_name} PROPERTIES
INTERFACE_QT_PACKAGE_NAME ${ARGV0}
INTERFACE_QT_PACKAGE_IS_OPTIONAL ${arg_MARK_OPTIONAL})
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()
if(arg_OPTIONAL_COMPONENTS)
string(REPLACE ";" " " components_as_string "${arg_OPTIONAL_COMPONENTS}")
set_property(TARGET ${qt_find_package_target_name}
PROPERTY INTERFACE_QT_PACKAGE_OPTIONAL_COMPONENTS
${components_as_string})
endif()
get_property(is_global TARGET ${qt_find_package_target_name} PROPERTY
IMPORTED_GLOBAL)
qt_internal_should_not_promote_package_target_to_global(
"${qt_find_package_target_name}" should_not_promote)
if(NOT is_global AND NOT should_not_promote)
__qt_internal_promote_target_to_global(${qt_find_package_target_name})
qt_find_package_promote_targets_to_global_scope(
"${qt_find_package_target_name}")
endif()
endif()
endforeach()
if(arg_MODULE_NAME AND arg_QMAKE_LIB
AND (NOT arg_QMAKE_LIB IN_LIST QT_QMAKE_LIBS_FOR_${arg_MODULE_NAME}))
set(QT_QMAKE_LIBS_FOR_${arg_MODULE_NAME}
${QT_QMAKE_LIBS_FOR_${arg_MODULE_NAME}};${arg_QMAKE_LIB} CACHE INTERNAL "")
set(QT_TARGETS_OF_QMAKE_LIB_${arg_QMAKE_LIB} ${arg_PROVIDED_TARGETS} CACHE INTERNAL "")
foreach(provided_target ${arg_PROVIDED_TARGETS})
set(QT_QMAKE_LIB_OF_TARGET_${provided_target} ${arg_QMAKE_LIB} CACHE INTERNAL "")
endforeach()
endif()
endif()
endmacro()
# Save found packages in the cache. They will be read on next reconfiguration to skip looking
# for packages that were not previously found.
# Only applies to -developer-builds by default.
# Can also be opted in or opted out via QT_INTERNAL_SAVE_PREVIOUSLY_FOUND_PACKAGES.
# Opting out will need two reconfigurations to take effect.
function(qt_internal_save_previously_found_packages)
if(DEFINED QT_INTERNAL_SAVE_PREVIOUSLY_FOUND_PACKAGES)
set(should_save "${QT_INTERNAL_SAVE_PREVIOUSLY_FOUND_PACKAGES}")
else()
if(FEATURE_developer_build OR QT_FEATURE_developer_build)
set(should_save ON)
else()
set(should_save OFF)
endif()
endif()
if(NOT should_save)
# When the value is flipped to OFF, remove any previously saved packages.
unset(QT_INTERNAL_PREVIOUSLY_FOUND_PACKAGES CACHE)
return()
endif()
get_property(_qt_previously_found_packages GLOBAL PROPERTY _qt_previously_found_packages)
if(_qt_previously_found_packages)
list(REMOVE_DUPLICATES _qt_previously_found_packages)
set(QT_INTERNAL_PREVIOUSLY_FOUND_PACKAGES "${_qt_previously_found_packages}" CACHE INTERNAL
"List of CMake packages found during configuration using qt_find_package.")
endif()
endfunction()
# Return qmake library name for the given target, e.g. return "vulkan" for "Vulkan::Vulkan".
function(qt_internal_map_target_to_qmake_lib target out_var)
set(${out_var} "${QT_QMAKE_LIB_OF_TARGET_${target}}" PARENT_SCOPE)
endfunction()
# This function records a dependency between ${main_target_name} and ${dep_package_name}.
# at the CMake package level.
# E.g. The Tools package that provides the qtwaylandscanner target
# needs to call find_package(WaylandScanner) (non-qt-package).
# main_target_name = qtwaylandscanner
# dep_package_name = WaylandScanner
function(qt_record_extra_package_dependency main_target_name dep_package_name dep_package_version)
if(NOT TARGET "${main_target_name}")
qt_get_tool_target_name(main_target_name "${main_target_name}")
endif()
if (TARGET "${main_target_name}")
get_target_property(extra_packages "${main_target_name}" QT_EXTRA_PACKAGE_DEPENDENCIES)
if(NOT extra_packages)
set(extra_packages "")
endif()
list(APPEND extra_packages "${dep_package_name}\;${dep_package_version}")
set_target_properties("${main_target_name}" PROPERTIES QT_EXTRA_PACKAGE_DEPENDENCIES
"${extra_packages}")
endif()
endfunction()
# This function records a dependency between ${main_target_name} and ${dep_target_name}
# at the CMake package level.
# E.g. Qt6CoreConfig.cmake needs to find_package(Qt6EntryPointPrivate).
# main_target_name = Core
# dep_target_name = EntryPointPrivate
# This is just a convenience function that deals with Qt targets and their associated packages
# instead of raw package names.
function(qt_record_extra_qt_package_dependency main_target_name dep_target_name
dep_package_version)
# EntryPointPrivate -> Qt6EntryPointPrivate.
qt_internal_qtfy_target(qtfied_target_name "${dep_target_name}")
qt_record_extra_package_dependency("${main_target_name}"
"${qtfied_target_name_versioned}" "${dep_package_version}")
endfunction()
# This function records a 'QtFooTools' package dependency for the ${main_target_name} target
# onto the ${dep_package_name} tools package.
# E.g. The QtWaylandCompositor package needs to call find_package(QtWaylandScannerTools).
# main_target_name = WaylandCompositor
# dep_package_name = Qt6WaylandScannerTools
function(qt_record_extra_main_tools_package_dependency
main_target_name dep_package_name dep_package_version)
if(NOT TARGET "${main_target_name}")
qt_get_tool_target_name(main_target_name "${main_target_name}")
endif()
if (TARGET "${main_target_name}")
get_target_property(extra_packages "${main_target_name}"
QT_EXTRA_TOOLS_PACKAGE_DEPENDENCIES)
if(NOT extra_packages)
set(extra_packages "")
endif()
list(APPEND extra_packages "${dep_package_name}\;${dep_package_version}")
set_target_properties("${main_target_name}" PROPERTIES QT_EXTRA_TOOLS_PACKAGE_DEPENDENCIES
"${extra_packages}")
endif()
endfunction()
# This function records a 'QtFooTools' package dependency for the ${main_target_name} target
# onto the ${dep_non_versioned_package_name} Tools package.
# main_target_name = WaylandCompositor
# dep_non_versioned_package_name = WaylandScannerTools
# This is just a convenience function to avoid hardcoding the qtified version in the dep package
# name.
function(qt_record_extra_qt_main_tools_package_dependency main_target_name
dep_non_versioned_package_name
dep_package_version)
# WaylandScannerTools -> Qt6WaylandScannerTools.
qt_internal_qtfy_target(qtfied_package_name "${dep_non_versioned_package_name}")
qt_record_extra_main_tools_package_dependency(
"${main_target_name}" "${qtfied_package_name_versioned}" "${dep_package_version}")
endfunction()
# Record an extra 3rd party target as a dependency for ${main_target_name}.
#
# Adds a find_package(${dep_target_package_name}) in ${main_target_name}Dependencies.cmake.
#
# Needed to record a dependency on the package that provides WrapVulkanHeaders::WrapVulkanHeaders.
# The package version, components, whether the package is optional, etc, are queried from the
# ${dep_target} target properties.
# Usually these are set at the qt_find_package() call site of a configure.cmake file e.g. using
# Qt's MARK_OPTIONAL option.
function(qt_record_extra_third_party_dependency main_target_name dep_target)
if(NOT TARGET "${main_target_name}")
qt_get_tool_target_name(main_target_name "${main_target_name}")
endif()
if(TARGET "${main_target_name}")
get_target_property(extra_deps "${main_target_name}" _qt_extra_third_party_dep_targets)
if(NOT extra_deps)
set(extra_deps "")
endif()
list(APPEND extra_deps "${dep_target}")
set_target_properties("${main_target_name}" PROPERTIES _qt_extra_third_party_dep_targets
"${extra_deps}")
endif()
endfunction()
# Sets out_var to TRUE if the non-namespaced ${lib} target is exported as part of Qt6Targets.cmake.
function(qt_internal_is_lib_part_of_qt6_package lib out_var)
if (lib STREQUAL "Platform"
OR lib STREQUAL "GlobalConfig"
OR lib STREQUAL "GlobalConfigPrivate"
OR lib STREQUAL "PlatformModuleInternal"
OR lib STREQUAL "PlatformPluginInternal"
OR lib STREQUAL "PlatformToolInternal"
OR lib STREQUAL "PlatformCommonInternal"
)
set(${out_var} "TRUE" PARENT_SCOPE)
else()
set(${out_var} "FALSE" PARENT_SCOPE)
endif()
endfunction()
# Try to get the CMake package version of a Qt target.
#
# Query the target's _qt_package_version property, or try to read it from the CMake package version
# variable set from calling find_package(Qt6${target}).
# Not all targets will have a find_package _VERSION variable, for example if the target is an
# executable.
# A heuristic is used to handle QtFooPrivate module targets.
# If no version can be found, fall back to ${PROJECT_VERSION} and issue a warning.
function(qt_internal_get_package_version_of_target target package_version_out_var)
qt_internal_is_lib_part_of_qt6_package("${target}" is_part_of_qt6)
if(is_part_of_qt6)
# When building qtbase, Qt6_VERSION is not set (unless examples are built in-tree,
# non-ExternalProject). Use the Platform target's version instead which would be the
# equivalent.
if(TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::Platform")
get_target_property(package_version
"${QT_CMAKE_EXPORT_NAMESPACE}::Platform" _qt_package_version)
endif()
if(NOT package_version)
set(package_version "${${QT_CMAKE_EXPORT_NAMESPACE}_VERSION}")
endif()
else()
# Try to get the version from the target.
# Try the Private target first and if it doesn't exist, try the non-Private target later.
if(TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::${target}")
get_target_property(package_version
"${QT_CMAKE_EXPORT_NAMESPACE}::${target}" _qt_package_version)
endif()
# Try to get the version from the corresponding package version variable.
if(NOT package_version)
set(package_version "${${QT_CMAKE_EXPORT_NAMESPACE}${target}_VERSION}")
endif()
# Try non-Private target.
if(NOT package_version AND target MATCHES "(.*)Private$")
set(target "${CMAKE_MATCH_1}")
endif()
if(NOT package_version AND TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::${target}")
get_target_property(package_version
"${QT_CMAKE_EXPORT_NAMESPACE}::${target}" _qt_package_version)
endif()
if(NOT package_version)
set(package_version "${${QT_CMAKE_EXPORT_NAMESPACE}${target}_VERSION}")
endif()
endif()
if(NOT package_version)
set(package_version "${PROJECT_VERSION}")
if(FEATURE_developer_build)
message(WARNING
"Could not determine package version of target ${target}. "
"Defaulting to project version ${PROJECT_VERSION}.")
endif()
endif()
set(${package_version_out_var} "${package_version}" PARENT_SCOPE)
endfunction()
# Get the CMake package name that contains / exported the Qt module target.
function(qt_internal_get_package_name_of_target target package_name_out_var)
qt_internal_is_lib_part_of_qt6_package("${target}" is_part_of_qt6)
if(is_part_of_qt6)
set(package_name "${INSTALL_CMAKE_NAMESPACE}")
else()
# Get the package name from the module's target property.
# If not set, fallback to a name based on the target name.
#
# TODO: Remove fallback once sufficient time has passed, aka all developers updated
# their builds not to contain stale FooDependencies.cmakes files without the
# _qt_package_name property.
set(package_name "")
set(package_name_default "${INSTALL_CMAKE_NAMESPACE}${target}")
set(target_namespaced "${QT_CMAKE_EXPORT_NAMESPACE}::${target}")
if(TARGET "${target_namespaced}")
get_target_property(package_name_from_prop "${target_namespaced}" _qt_package_name)
if(package_name_from_prop)
set(package_name "${package_name_from_prop}")
endif()
endif()
if(NOT package_name)
message(WARNING
"Could not find target ${target_namespaced} to query its package name. "
"Defaulting to package name ${package_name_default}. Consider re-arranging the "
"project structure to ensure the target exists by this point."
)
set(package_name "${package_name_default}")
endif()
endif()
set(${package_name_out_var} "${package_name}" PARENT_SCOPE)
endfunction()
# This function stores the list of Qt targets 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()
get_target_property(target_type ${target} TYPE)
set(lib_list ${public_libs})
set(target_is_shared FALSE)
set(target_is_static FALSE)
if(target_type STREQUAL "SHARED_LIBRARY")
set(target_is_shared TRUE)
elseif(target_type STREQUAL "STATIC_LIBRARY")
set(target_is_static TRUE)
endif()
# Record 'Qt::Foo'-like private dependencies of static library targets, this will be used to
# generate find_dependency() calls.
#
# Private static library dependencies will become $<LINK_ONLY:> dependencies in
# INTERFACE_LINK_LIBRARIES.
if(target_is_static)
list(APPEND lib_list ${private_libs})
endif()
foreach(lib IN LISTS lib_list)
if ("${lib}" MATCHES "^Qt::(.*)")
set(lib "${CMAKE_MATCH_1}")
qt_internal_get_package_name_of_target("${lib}" package_name)
qt_internal_get_package_version_of_target("${lib}" package_version)
list(APPEND target_deps "${package_name}\;${package_version}")
endif()
endforeach()
# Record 'Qt::Foo'-like shared private dependencies of shared library targets.
#
# Private shared library dependencies are listed in the target's
# IMPORTED_LINK_DEPENDENT_LIBRARIES and used in rpath-link calculation.
# See QTBUG-86533 for some details.
# We filter out static libraries and common platform targets, but include both SHARED and
# INTERFACE libraries. INTERFACE libraries in most cases will be FooPrivate libraries.
if(target_is_shared AND private_libs)
foreach(lib IN LISTS private_libs)
if ("${lib}" MATCHES "^Qt::(.*)")
set(lib_namespaced "${lib}")
set(lib "${CMAKE_MATCH_1}")
qt_internal_is_lib_part_of_qt6_package("${lib}" is_part_of_qt6)
get_target_property(lib_type "${lib_namespaced}" TYPE)
if(NOT lib_type STREQUAL "STATIC_LIBRARY" AND NOT is_part_of_qt6)
qt_internal_get_package_name_of_target("${lib}" package_name)
qt_internal_get_package_version_of_target("${lib}" package_version)
list(APPEND target_deps "${package_name}\;${package_version}")
endif()
endif()
endforeach()
endif()
set_target_properties("${target}" PROPERTIES _qt_target_deps "${target_deps}")
endfunction()
# Sets out_var to to TRUE if the target was marked to not be promoted to global scope.
function(qt_internal_should_not_promote_package_target_to_global target out_var)
get_property(should_not_promote TARGET "${target}" PROPERTY _qt_no_promote_global)
set("${out_var}" "${should_not_promote}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1 @@
@extra_cmake_code@

View File

@ -0,0 +1,90 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Creates an imported wrapper target that links against either a Qt bundled package
# or a system package.
#
# Used for consuming 3rd party libraries in Qt.
#
# Example: Creates WrapFreetype::WrapFreetype linking against either
# Qt6::BundledFreetype or WrapSystemFreetype::WrapSystemFreetype.
#
# The implementation has to use a unique prefix in each variable, otherwise when WrapFreetype
# find_package()s WrapPNG, the nested call would override the parent call variables, due to macros
# using the same scope.
macro(qt_find_package_system_or_bundled _unique_prefix)
set(_flags "")
set(_options
FRIENDLY_PACKAGE_NAME
WRAP_PACKAGE_TARGET
WRAP_PACKAGE_FOUND_VAR_NAME
BUNDLED_PACKAGE_NAME
BUNDLED_PACKAGE_TARGET
SYSTEM_PACKAGE_NAME
SYSTEM_PACKAGE_TARGET
)
set(_multioptions "")
cmake_parse_arguments("_qfwrap_${_unique_prefix}"
"${_flags}" "${_options}" "${_multioptions}" ${ARGN})
# 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 "${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}")
set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} ON)
return()
endif()
set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} OFF)
include("FindWrap${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}ConfigExtra" OPTIONAL)
if(NOT DEFINED "QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}")
message(FATAL_ERROR
"Can't find cache variable "
"QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET} "
"to decide whether to use bundled or system library.")
endif()
if("${QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}}")
set(${_unique_prefix}_qt_package_name_to_use
"Qt6${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}")
set(${_unique_prefix}_qt_package_target_to_use
"Qt6::${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}")
set(${_unique_prefix}_qt_package_success_message
"Using Qt bundled ${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}.")
set(${_unique_prefix}_qt_package_type "bundled")
else()
set(${_unique_prefix}_qt_package_name_to_use
"${_qfwrap_${_unique_prefix}_SYSTEM_PACKAGE_NAME}")
set(${_unique_prefix}_qt_package_target_to_use
"${_qfwrap_${_unique_prefix}_SYSTEM_PACKAGE_TARGET}")
set(${_unique_prefix}_qt_package_success_message
"Using system ${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}.")
set(${_unique_prefix}_qt_package_type "system")
endif()
if(NOT TARGET "${${_unique_prefix}_qt_package_target_to_use}")
find_package("${${_unique_prefix}_qt_package_name_to_use}")
endif()
if(TARGET "${${_unique_prefix}_qt_package_target_to_use}")
set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} ON)
message(STATUS "${${_unique_prefix}_qt_package_success_message}")
add_library("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}" INTERFACE IMPORTED)
target_link_libraries("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}"
INTERFACE
${${_unique_prefix}_qt_package_target_to_use})
set_target_properties("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}" PROPERTIES
INTERFACE_QT_3RD_PARTY_PACKAGE_TYPE
"${${_unique_prefix}_qt_package_type}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Wrap${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}
DEFAULT_MSG ${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME})
elseif(${_unique_prefix}_qt_package_type STREQUAL "bundled")
message(FATAL_ERROR "Can't find ${${_unique_prefix}_qt_package_target_to_use}.")
endif()
endmacro()

View File

@ -0,0 +1,31 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Finish a preliminary .pc file.
#
# - Appends to each requirement the proper configuration postfix.
# - Strips empty PkgConfig fields.
#
# This file is to be used in CMake script mode with the following variables set:
# IN_FILE: path to the step 2 preliminary .pc file.
# OUT_FILE: path to the .pc file that is going to be created.
# POSTFIX: postfix for each requirement (optional).
cmake_policy(SET CMP0057 NEW)
file(STRINGS "${IN_FILE}" lines)
set(content "")
set(emptied "Libs:" "Cflags:" "Requires:")
foreach(line ${lines})
if(POSTFIX)
if(line MATCHES "^Libs:")
string(REGEX REPLACE "( -lQt[^ ]+)" "\\1${POSTFIX}" line "${line}")
elseif(line MATCHES "^Requires:")
string(REGEX REPLACE "( Qt[^ ]+)" "\\1${POSTFIX}" line "${line}")
endif()
endif()
string(REGEX REPLACE " +$" "" line "${line}")
if(NOT line IN_LIST emptied)
string(APPEND content "${line}\n")
endif()
endforeach()
file(WRITE "${OUT_FILE}" "${content}")

Some files were not shown because too many files have changed in this diff Show More