aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/cmake')
-rw-r--r--sources/pyside6/cmake/Macros/FindQt5Extra.cmake25
-rw-r--r--sources/pyside6/cmake/Macros/PySideModules.cmake223
-rw-r--r--sources/pyside6/cmake/Macros/icecc.cmake3
-rw-r--r--sources/pyside6/cmake/PySideHelpers.cmake275
-rw-r--r--sources/pyside6/cmake/PySideSetup.cmake243
5 files changed, 701 insertions, 68 deletions
diff --git a/sources/pyside6/cmake/Macros/FindQt5Extra.cmake b/sources/pyside6/cmake/Macros/FindQt5Extra.cmake
deleted file mode 100644
index 71846e48a..000000000
--- a/sources/pyside6/cmake/Macros/FindQt5Extra.cmake
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Try to find QtMultimedia
-# TODO: Remove this hack when cmake support QtMultimedia module
-# CT: maybe we can remove this.
-# For now, I just use the mapping to Qt5
-
-find_package(Qt${QT_MAJOR_VERSION}Multimedia)
-
-if (NOT Qt${QT_MAJOR_VERSION}Multimedia_FOUND)
- find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia
- PATHS ${QT_HEADERS_DIR}/QtMultimedia
- ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers
- NO_DEFAULT_PATH)
- find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
- if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY)
- set(QT_QTMULTIMEDIA_FOUND ON)
- else()
- #Replace this on documentation
- set(if_QtMultimedia "<!--")
- set(end_QtMultimedia "-->")
- endif()
-endif ()
-
-# Maemo is no longer supported
-# QtDeclarative is no longer supported
diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake
index 96fa33a99..fb279c60c 100644
--- a/sources/pyside6/cmake/Macros/PySideModules.cmake
+++ b/sources/pyside6/cmake/Macros/PySideModules.cmake
@@ -1,3 +1,6 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
include(CMakeParseArguments)
# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out
@@ -18,6 +21,34 @@ macro(unmake_path varname)
string(REPLACE "${PATH_SEP}" ";" ${varname} "${ARGN}")
endmacro()
+# Check for presence of QtOpenGL and modify module variables
+# accordingly
+macro(check_qt_opengl module include_var deps_var dropped_entries_var)
+ if (Qt${QT_MAJOR_VERSION}OpenGL_FOUND)
+ message(STATUS "Qt${QT_MAJOR_VERSION}${module}: Building with OpenGL")
+ list(APPEND ${include_var} ${Qt${QT_MAJOR_VERSION}OpenGL_INCLUDE_DIRS}
+ ${QtOpenGL_GEN_DIR})
+ list(APPEND ${deps_var} QtOpenGL)
+ else()
+ message(STATUS "Qt${QT_MAJOR_VERSION}${module}: Dropping OpenGL")
+ # This is a dummy entry creating a conditional typesystem keyword
+ list(APPEND ${dropped_entries_var} "QtOpenGL")
+ endif()
+endmacro()
+
+# set size optimization flags for pyside6
+macro(append_size_optimization_flags _module_name)
+ if(NOT QFP_NO_OVERRIDE_OPTIMIZATION_FLAGS)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ target_compile_options(${_module_name} PRIVATE /Gy /Gw /EHsc)
+ target_link_options(${_module_name} PRIVATE LINKER:/OPT:REF)
+ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|CLANG")
+ target_compile_options(${_module_name} PRIVATE -ffunction-sections -fdata-sections -fno-exceptions)
+ target_link_options(${_module_name} PRIVATE LINKER:--gc-sections)
+ endif()
+ endif()
+endmacro()
+
# Sample usage
# create_pyside_module(NAME QtGui
# INCLUDE_DIRS QtGui_include_dirs
@@ -35,7 +66,7 @@ macro(create_pyside_module)
"create_pyside_module" # Macro name
"" # Flags
"NAME;TYPESYSTEM_PATH;TYPESYSTEM_NAME" # Single value
- "INCLUDE_DIRS;LIBRARIES;DEPS;SOURCES;STATIC_SOURCES;DROPPED_ENTRIES;GLUE_SOURCES" # Multival
+ "INCLUDE_DIRS;LIBRARIES;DEPS;SOURCES;STATIC_SOURCES;DROPPED_ENTRIES;GLUE_SOURCES;ADDITIONAL_INCLUDE_DIRS" # Multival
${ARGN} # Number of arguments given when the macros is called
)
@@ -55,12 +86,6 @@ macro(create_pyside_module)
string(TOLOWER ${module_NAME} _module)
string(REGEX REPLACE ^qt "" _module ${_module})
- if(${module_DROPPED_ENTRIES})
- string(REPLACE ";" "\\;" dropped_entries "${${module_DROPPED_ENTRIES}}")
- else()
- set (dropped_entries "")
- endif()
-
if(${module_GLUE_SOURCES})
set (module_GLUE_SOURCES "${${module_GLUE_SOURCES}}")
else()
@@ -90,20 +115,53 @@ macro(create_pyside_module)
# Remove any possible duplicates.
list(REMOVE_DUPLICATES total_type_system_files)
- # Contains include directories to pass to shiboken's preprocessor.
- # Workaround: Added ${QT_INCLUDE_DIR}/QtCore until
- # qtdeclarative/8d560d1bf0a747bf62f73fad6b6774095442d9d2 has reached qt5.git
- string(REPLACE ";" ${PATH_SEP} core_includes "${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}")
- set(shiboken_include_dirs ${pyside6_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR}${PATH_SEP}${core_includes})
- set(shiboken_framework_include_dirs_option "")
- if(CMAKE_HOST_APPLE)
- set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}")
- make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs})
- set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}")
+ # Contains include directories to pass to shiboken's preprocessor (mkspec / global)
+ get_target_property(qt_platform_includes Qt${QT_MAJOR_VERSION}::Platform
+ INTERFACE_INCLUDE_DIRECTORIES)
+ # Add QtCore since include conventions are sometimes violated for its classes
+ get_target_property(qt_core_includes Qt${QT_MAJOR_VERSION}::Core
+ INTERFACE_INCLUDE_DIRECTORIES)
+ set(shiboken_include_dir_list ${pyside6_SOURCE_DIR} ${qt_platform_includes}
+ ${qt_core_includes})
+ if(module_ADDITIONAL_INCLUDE_DIRS)
+ list(APPEND shiboken_include_dir_list ${${module_ADDITIONAL_INCLUDE_DIRS}})
+ endif()
+
+ # Transform the path separators into something shiboken understands.
+ make_path(shiboken_include_dirs ${shiboken_include_dir_list})
+
+ set(force_process_system_include_paths_list "")
+ # When building against system Qt (as it happens with yocto / Boot2Qt), the Qt headers are
+ # considered system headers by clang_Location_isInSystemHeader, and thus shiboken will not
+ # process them.
+ #
+ # We do want to process them.
+ #
+ # Tell shiboken to consider them as special typesystem system include paths, which ensures
+ # the types are processed and extracted.
+ #
+ # This option is opt-in because it might cause problems if there are other system headers
+ # installed in the same location as the Qt ones, resulting in processing more non-Qt system
+ # types that might not be supported by shiboken.
+ if(PYSIDE_TREAT_QT_INCLUDE_DIRS_AS_NON_SYSTEM)
+ list(APPEND force_process_system_include_paths_list
+ ${qt_platform_includes}
+ ${qt_core_includes})
+ endif()
+
+ # Allow passing extra non system inlcude dirs.
+ if(SHIBOKEN_FORCE_PROCESS_SYSTEM_INCLUDE_PATHS)
+ list(APPEND force_process_system_include_paths_list
+ ${SHIBOKEN_FORCE_PROCESS_SYSTEM_INCLUDE_PATHS})
endif()
# Transform the path separators into something shiboken understands.
- make_path(shiboken_include_dirs ${shiboken_include_dirs})
+ make_path(force_process_system_include_paths ${force_process_system_include_paths_list})
+
+ if(force_process_system_include_paths)
+ set(force_process_system_include_paths
+ "--force-process-system-include-paths=${force_process_system_include_paths}")
+ endif()
get_filename_component(pyside_binary_dir ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY)
@@ -122,18 +180,66 @@ macro(create_pyside_module)
install(FILES ${module_GLUE_SOURCES} DESTINATION share/PySide6${pyside6_SUFFIX}/typesystems/glue)
endif()
+ shiboken_get_tool_shell_wrapper(shiboken tool_wrapper)
+
+ set(shiboken_command
+ ${tool_wrapper}
+ $<TARGET_FILE:Shiboken6::shiboken6>
+ ${GENERATOR_EXTRA_FLAGS}
+ "--include-paths=${shiboken_include_dirs}"
+ "${force_process_system_include_paths}"
+ "--typesystem-paths=${pyside_binary_dir}${PATH_SEP}${pyside6_SOURCE_DIR}${PATH_SEP}${${module_TYPESYSTEM_PATH}}"
+ --output-directory=${CMAKE_CURRENT_BINARY_DIR}
+ --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt
+ --lean-headers
+ --api-version=${SUPPORTED_QT_VERSION})
+
+ # check if building for Android with a macOS host
+ # This is not needed for Linux because OpenGLES2 development binaries in
+ # linux can be installed by installing 'libgles2-mesa-dev' package which
+ # comes as a default requirement for building PySide6. As such for
+ # cross-compiling in linux, we use the clang compiler from the installed
+ # libclang itself.
+ if(CMAKE_ANDROID_ARCH_LLVM_TRIPLE AND CMAKE_HOST_APPLE)
+ message(STATUS "Building for Android with arch ${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}")
+ list(APPEND shiboken_command "--clang-option=--target=${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}")
+
+ # CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX does not contain the ANDROID_PLATFORM i.e. it ends with
+ # the form 'aarch64-linux-android-'. Remove the last '-' and add the corresponding clang
+ # based on ANDROID_PLATFORM making it 'aarch64-linux-android26-clang++'
+
+ # Get the length of the string
+ string(LENGTH "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}" _length)
+
+ # Subtract 1 from the length to get the characters till '-'
+ math(EXPR _last_index "${_length} - 1")
+
+ # Get the substring from the start to the character before the last one
+ string(SUBSTRING "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}" 0 "${_last_index}"
+ SHIBOKEN_ANDROID_COMPILER_PREFIX)
+
+ # use the compiler from the Android NDK
+ list(APPEND shiboken_command
+ "--compiler-path=${SHIBOKEN_ANDROID_COMPILER_PREFIX}${CMAKE_ANDROID_API}-clang++")
+ endif()
+
+ if(CMAKE_HOST_APPLE)
+ set(shiboken_framework_include_dir_list ${QT_FRAMEWORK_INCLUDE_DIR})
+ make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dir_list})
+ list(APPEND shiboken_command "--framework-include-paths=${shiboken_framework_include_dirs}")
+ endif()
+
+ if(${module_DROPPED_ENTRIES})
+ list(JOIN ${module_DROPPED_ENTRIES} "\;" dropped_entries)
+ list(APPEND shiboken_command "\"--drop-type-entries=${dropped_entries}\"")
+ endif()
+
+ list(APPEND shiboken_command "${pyside6_BINARY_DIR}/${module_NAME}_global.h"
+ ${typesystem_path})
+
add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
BYPRODUCTS ${${module_SOURCES}}
- COMMAND Shiboken6::shiboken6 ${GENERATOR_EXTRA_FLAGS}
- "${pyside6_BINARY_DIR}/${module_NAME}_global.h"
- --include-paths=${shiboken_include_dirs}
- ${shiboken_framework_include_dirs_option}
- --typesystem-paths=${pyside_binary_dir}${PATH_SEP}${pyside6_SOURCE_DIR}${PATH_SEP}${${module_TYPESYSTEM_PATH}}
- --output-directory=${CMAKE_CURRENT_BINARY_DIR}
- --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt
- ${typesystem_path}
- --api-version=${SUPPORTED_QT_VERSION}
- --drop-type-entries="${dropped_entries}"
+ COMMAND ${shiboken_command}
DEPENDS ${total_type_system_files}
${module_GLUE_SOURCES}
${${module_NAME}_glue_dependency}
@@ -143,6 +249,11 @@ macro(create_pyside_module)
include_directories(${module_NAME} ${${module_INCLUDE_DIRS}} ${pyside6_SOURCE_DIR})
add_library(${module_NAME} MODULE ${${module_SOURCES}}
${${module_STATIC_SOURCES}})
+
+ append_size_optimization_flags(${module_NAME})
+
+ target_compile_definitions(${module_NAME} PRIVATE -DQT_LEAN_HEADERS=1)
+
set_target_properties(${module_NAME} PROPERTIES
PREFIX ""
OUTPUT_NAME "${module_NAME}${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}"
@@ -171,7 +282,17 @@ macro(create_pyside_module)
else()
set(ld_prefix_var_name "LD_LIBRARY_PATH")
endif()
- set(ld_prefix "${ld_prefix_var_name}=${pysidebindings_BINARY_DIR}/libpyside${PATH_SEP}${SHIBOKEN_SHARED_LIBRARY_DIR}")
+
+ set(ld_prefix_list "")
+ list(APPEND ld_prefix_list "${pysidebindings_BINARY_DIR}/libpyside")
+ list(APPEND ld_prefix_list "${pysidebindings_BINARY_DIR}/libpysideqml")
+ list(APPEND ld_prefix_list "${SHIBOKEN_SHARED_LIBRARY_DIR}")
+ if(WIN32)
+ list(APPEND ld_prefix_list "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}")
+ endif()
+
+ list(JOIN ld_prefix_list "${PATH_SEP}" ld_prefix_values_string)
+ set(ld_prefix "${ld_prefix_var_name}=${ld_prefix_values_string}")
# Append any existing ld_prefix values, so existing PATH, LD_LIBRARY_PATH, etc.
# On Windows it is needed because pyside modules import Qt,
@@ -196,26 +317,42 @@ macro(create_pyside_module)
string(APPEND ld_prefix ":${env_value}")
endif()
endif()
- set(generate_pyi_options ${module_NAME} --sys-path
- "${pysidebindings_BINARY_DIR}"
- "${SHIBOKEN_PYTHON_MODULE_DIR}/..") # use the layer above shiboken6
- if (QUIET_BUILD)
- list(APPEND generate_pyi_options "--quiet")
- endif()
+
+ qfp_strip_library("${module_NAME}")
# Add target to generate pyi file, which depends on the module target.
- add_custom_target("${module_NAME}_pyi" ALL
- COMMAND ${CMAKE_COMMAND} -E env ${ld_prefix}
- "${SHIBOKEN_PYTHON_INTERPRETER}"
- "${CMAKE_CURRENT_SOURCE_DIR}/../support/generate_pyi.py" ${generate_pyi_options})
- add_dependencies("${module_NAME}_pyi" ${module_NAME})
+ # Don't generate the files when cross-building because the target python can not be executed
+ # on the host machine (usually, unless you use some userspace qemu based mechanism).
+ # TODO: Can we do something better here to still get pyi files?
+ if(NOT (PYSIDE_IS_CROSS_BUILD OR DISABLE_PYI))
+ set(generate_pyi_options ${module_NAME} --sys-path
+ "${pysidebindings_BINARY_DIR}"
+ "${SHIBOKEN_PYTHON_MODULE_DIR}/..") # use the layer above shiboken6
+ if (QUIET_BUILD)
+ list(APPEND generate_pyi_options "--quiet")
+ endif()
+
+ add_custom_target("${module_NAME}_pyi" ALL
+ COMMAND
+ ${CMAKE_COMMAND} -E env ${ld_prefix}
+ "${SHIBOKEN_PYTHON_INTERPRETER}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../support/generate_pyi.py"
+ ${generate_pyi_options})
+ add_dependencies("${module_NAME}_pyi" ${module_NAME})
+
+ if(TARGET shibokenmodule)
+ add_dependencies("${module_NAME}_pyi" shibokenmodule)
+ endif()
+
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/../${module_NAME}.pyi"
+ DESTINATION "${PYTHON_SITE_PACKAGES}/PySide6")
+ endif()
+
# install
install(TARGETS ${module_NAME} LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/PySide6")
- file(GLOB hinting_stub_files RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/PySide6" "${CMAKE_CURRENT_BINARY_DIR}/PySide6/*.pyi")
- install(FILES ${hinting_stub_files}
- DESTINATION "${PYTHON_SITE_PACKAGES}/PySide6")
+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide6/${module_NAME}/pyside6_${lower_module_name}_python.h
DESTINATION include/PySide6${pyside6_SUFFIX}/${module_NAME}/)
diff --git a/sources/pyside6/cmake/Macros/icecc.cmake b/sources/pyside6/cmake/Macros/icecc.cmake
index b2bf071aa..fa8d3b7cf 100644
--- a/sources/pyside6/cmake/Macros/icecc.cmake
+++ b/sources/pyside6/cmake/Macros/icecc.cmake
@@ -1,3 +1,6 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
include (CMakeForceCompiler)
option(ENABLE_ICECC "Enable icecc checking, for distributed compilation")
if (ENABLE_ICECC)
diff --git a/sources/pyside6/cmake/PySideHelpers.cmake b/sources/pyside6/cmake/PySideHelpers.cmake
new file mode 100644
index 000000000..01c438107
--- /dev/null
+++ b/sources/pyside6/cmake/PySideHelpers.cmake
@@ -0,0 +1,275 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(pyside_internal_detect_if_cross_building)
+ if(CMAKE_CROSSCOMPILING OR QFP_SHIBOKEN_HOST_PATH)
+ set(is_cross_build TRUE)
+ else()
+ set(is_cross_build FALSE)
+ endif()
+ set(PYSIDE_IS_CROSS_BUILD "${is_cross_build}" PARENT_SCOPE)
+ message(STATUS "PYSIDE_IS_CROSS_BUILD: ${PYSIDE_IS_CROSS_BUILD}")
+endfunction()
+
+function(pyside_internal_set_up_extra_dependency_paths)
+ set(extra_root_path_vars
+ QFP_QT_TARGET_PATH
+ QFP_PYTHON_TARGET_PATH
+ QFP_SHIBOKEN_TARGET_PATH
+ )
+ foreach(root_path IN LISTS extra_root_path_vars)
+ set(new_root_path_value "${${root_path}}")
+ if(new_root_path_value)
+ set(new_prefix_path "${CMAKE_PREFIX_PATH}")
+ list(PREPEND new_prefix_path "${new_root_path_value}/lib/cmake")
+ set(CMAKE_PREFIX_PATH "${new_prefix_path}")
+ set(CMAKE_PREFIX_PATH "${new_prefix_path}" PARENT_SCOPE)
+
+ # Need to adjust the prefix and root paths so that find_package(Qt) and other 3rd
+ # party packages are found successfully when they are located outside of the
+ # default sysroot (whatever that maybe for the target platform).
+ if(PYSIDE_IS_CROSS_BUILD)
+ set(new_root_path "${CMAKE_FIND_ROOT_PATH}")
+ list(PREPEND new_root_path "${new_root_path_value}")
+ set(CMAKE_FIND_ROOT_PATH "${new_root_path}")
+ set(CMAKE_FIND_ROOT_PATH "${new_root_path}" PARENT_SCOPE)
+ endif()
+ endif()
+ endforeach()
+endfunction()
+
+function(pyside_internal_find_host_shiboken_tools)
+ set(find_package_extra_args)
+ if(QFP_SHIBOKEN_HOST_PATH)
+ list(APPEND find_package_extra_args PATHS "${QFP_SHIBOKEN_HOST_PATH}/lib/cmake")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${QFP_SHIBOKEN_HOST_PATH}")
+ endif()
+
+ # When doing a regular build, immediately mark the package as required.
+ if(NOT PYSIDE_IS_CROSS_BUILD)
+ list(APPEND "REQUIRED")
+ endif()
+
+ find_package(
+ Shiboken6Tools 6 CONFIG
+ ${find_package_extra_args}
+ )
+
+ # When cross building, we show a more helpful error message that
+ # QFP_SHIBOKEN_HOST_PATH should be provided instead of CMAKE_PREFIX_PATH (specifically
+ # for the host tools package).
+ if(PYSIDE_IS_CROSS_BUILD)
+ if(NOT Shiboken6Tools_DIR)
+ message(FATAL_ERROR
+ "Shiboken6Tools package was not found. "
+ "Please set QFP_SHIBOKEN_HOST_PATH to the location where the Shiboken6Tools "
+ "CMake package is installed.")
+ endif()
+ endif()
+endfunction()
+
+macro(collect_essential_modules)
+ # Collect all essential modules.
+ # note: the order of this list is relevant for dependencies.
+ # For instance: Qt5Printsupport must come before Qt5WebKitWidgets.
+ set(ALL_ESSENTIAL_MODULES
+ Core
+ Gui
+ Widgets
+ PrintSupport
+ Sql
+ Network
+ Test
+ Concurrent)
+endmacro()
+
+macro(collect_optional_modules)
+ # Collect all optional modules.
+ set(ALL_OPTIONAL_MODULES
+ DBus
+ Designer
+ Xml
+ Help Multimedia
+ MultimediaWidgets
+ OpenGL
+ OpenGLWidgets
+ Pdf
+ PdfWidgets
+ Positioning
+ Location
+ NetworkAuth
+ Nfc
+ Qml
+ Quick
+ Quick3D
+ QuickControls2
+ QuickTest
+ QuickWidgets
+ RemoteObjects
+ Scxml
+ Sensors
+ SerialPort
+ SerialBus
+ StateMachine
+ TextToSpeech
+ Charts
+ SpatialAudio
+ Svg
+ SvgWidgets
+ DataVisualization
+ Graphs
+ Bluetooth)
+ find_package(Qt${QT_MAJOR_VERSION}UiTools)
+ if(Qt${QT_MAJOR_VERSION}UiTools_FOUND)
+ list(APPEND ALL_OPTIONAL_MODULES UiTools)
+ else()
+ set(DISABLE_QtUiTools 1)
+ endif()
+ if(WIN32)
+ list(APPEND ALL_OPTIONAL_MODULES AxContainer)
+ endif()
+ list(APPEND ALL_OPTIONAL_MODULES WebChannel WebEngineCore WebEngineWidgets
+ WebEngineQuick WebSockets HttpServer)
+ list(APPEND ALL_OPTIONAL_MODULES 3DCore 3DRender 3DInput 3DLogic 3DAnimation 3DExtras)
+endmacro()
+
+macro(check_os)
+ set(ENABLE_UNIX "1")
+ set(ENABLE_MAC "0")
+ set(ENABLE_WIN "0")
+
+ # check if Android, if so, set ENABLE_UNIX=1
+ # this is needed to avoid including the wrapper specific to macOS when building for Android
+ # from a macOS host
+ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
+ if(CMAKE_HOST_APPLE)
+ set(ENABLE_MAC "1")
+ elseif(CMAKE_HOST_WIN32)
+ set(ENABLE_WIN "1")
+ set(ENABLE_UNIX "0")
+ elseif(NOT CMAKE_HOST_UNIX)
+ message(FATAL_ERROR "OS not supported")
+ endif()
+ endif()
+endmacro()
+
+macro(use_protected_as_public_hack)
+ # 2017-04-24 The protected hack can unfortunately not be disabled, because
+ # Clang does produce linker errors when we disable the hack.
+ # But the ugly workaround in Python is replaced by a shiboken change.
+ if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
+ message(STATUS "PySide6 will be generated avoiding the protected hack!")
+ set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
+ add_definitions(-DAVOID_PROTECTED_HACK)
+ else()
+ message(STATUS "PySide will be generated using the protected hack!")
+ endif()
+endmacro()
+
+macro(remove_skipped_modules)
+ # Removing from the MODULES list the items that were defined with
+ # -DSKIP_MODULES on command line
+ if(SKIP_MODULES)
+ foreach(s ${SKIP_MODULES})
+ list(REMOVE_ITEM MODULES ${s})
+ endforeach()
+ endif()
+
+ foreach(m ${MODULES})
+ collect_module_if_found(${m})
+ list(FIND all_module_shortnames ${m} is_module_collected)
+ # If the module was collected, remove it from disabled modules list.
+ if (NOT is_module_collected EQUAL -1)
+ list(REMOVE_ITEM DISABLED_MODULES ${m})
+ endif()
+ endforeach()
+endmacro()
+
+macro(collect_module_if_found shortname)
+ set(name "Qt${QT_MAJOR_VERSION}${shortname}")
+ set(_qt_module_name "${name}")
+ if ("${shortname}" STREQUAL "OpenGLFunctions")
+ set(_qt_module_name "Qt${QT_MAJOR_VERSION}Gui")
+ endif()
+ # Determine essential/optional/missing
+ set(module_state "missing")
+ list(FIND ALL_ESSENTIAL_MODULES "${shortname}" essentialIndex)
+ if(${essentialIndex} EQUAL -1)
+ list(FIND ALL_OPTIONAL_MODULES "${shortname}" optionalIndex)
+ if(NOT ${optionalIndex} EQUAL -1)
+ set(module_state "optional")
+ endif()
+ else()
+ set(module_state "essential")
+ endif()
+
+ # Silence warnings when optional packages are not found when doing a quiet build.
+ set(quiet_argument "")
+ if (QUIET_BUILD AND "${module_state}" STREQUAL "optional")
+ set(quiet_argument "QUIET")
+ endif()
+
+ find_package(${_qt_module_name} ${quiet_argument})
+ # If package is found, _name_found will be equal to 1
+ set(_name_found "${_qt_module_name}_FOUND")
+ # _name_dir will keep the path to the directory where the CMake rules were found
+ # e.g: ~/qt5.9-install/qtbase/lib/cmake/Qt5Core or /usr/lib64/cmake/Qt5Core
+ set(_name_dir "${_qt_module_name}_DIR")
+ # Qt5Core will set the base path to check if all the modules are on the same
+ # directory, to avoid CMake looking in another path.
+ # This will be saved in a global variable at the beginning of the modules
+ # collection process.
+ string(FIND "${name}" "Qt${QT_MAJOR_VERSION}Core" qtcore_found)
+ if(("${qtcore_found}" GREATER "0") OR ("${qtcore_found}" EQUAL "0"))
+ get_filename_component(_core_abs_dir "${${_name_dir}}/../" ABSOLUTE)
+ # Setting the absolute path where the Qt5Core was found
+ # e.g: ~/qt5.9-install/qtbase/lib/cmake or /usr/lib64/cmake
+ message(STATUS "CORE_ABS_DIR:" ${_core_abs_dir})
+ endif()
+
+ # Getting the absolute path for each module where the CMake was found, to
+ # compare it with CORE_ABS_DIR and check if they are in the same source directory
+ # e.g: ~/qt5.9-install/qtbase/lib/cmake/Qt5Script or /usr/lib64/cmake/Qt5Script
+ get_filename_component(_module_dir "${${_name_dir}}" ABSOLUTE)
+ string(FIND "${_module_dir}" "${_core_abs_dir}" found_basepath)
+
+ # If the module was found, and also the module path is the same as the
+ # Qt5Core base path, we will generate the list with the modules to be installed
+ set(looked_in_message ". Looked in: ${${_name_dir}}")
+ if("${${_name_found}}" AND (("${found_basepath}" GREATER "0") OR ("${found_basepath}" EQUAL "0")))
+ message(STATUS "${module_state} module ${name} found (${ARGN})${looked_in_message}")
+ # record the shortnames for the tests
+ list(APPEND all_module_shortnames ${shortname})
+ # Build Qt 5 compatibility variables
+ if(${QT_MAJOR_VERSION} GREATER_EQUAL 6 AND NOT "${shortname}" STREQUAL "OpenGLFunctions")
+ get_target_property(Qt6${shortname}_INCLUDE_DIRS Qt6::${shortname}
+ INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(Qt6${shortname}_PRIVATE_INCLUDE_DIRS
+ Qt6::${shortname}Private
+ INTERFACE_INCLUDE_DIRECTORIES)
+ set(Qt6${shortname}_LIBRARIES Qt::${shortname})
+ endif()
+ else()
+ if("${module_state}" STREQUAL "optional")
+ message(STATUS "optional module ${name} skipped${looked_in_message}")
+ elseif("${module_state}" STREQUAL "essential")
+ message(STATUS "skipped module ${name} is essential!\n"
+ " We do not guarantee that all tests are working.${looked_in_message}")
+ else()
+ message(FATAL_ERROR "module ${name} MISSING${looked_in_message}")
+ endif()
+ endif()
+endmacro()
+
+# resets the RELEASE CXX flags for size based optimization
+macro(override_release_flags_for_size_optimization)
+ if(NOT QFP_NO_OVERRIDE_OPTIMIZATION_FLAGS)
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ set(CMAKE_CXX_FLAGS_RELEASE "/O1 /DNDEBUG")
+ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
+ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
+ endif()
+ endif()
+endmacro()
diff --git a/sources/pyside6/cmake/PySideSetup.cmake b/sources/pyside6/cmake/PySideSetup.cmake
new file mode 100644
index 000000000..038dc1642
--- /dev/null
+++ b/sources/pyside6/cmake/PySideSetup.cmake
@@ -0,0 +1,243 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Don't ignore targets that do not exist, inside add_dependencies calls.
+cmake_policy(SET CMP0046 NEW)
+
+set(QT_MAJOR_VERSION 6)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../shiboken6/cmake")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Macros")
+
+# TODO: Don't directly include, ShibokenHelpers but rather pick it up from the installed Shiboken
+# package. Needs to support top-level build as well (Shiboken is not yet installed in that case).
+include(ShibokenHelpers)
+include(PySideHelpers)
+
+#does nothing if QFP_NO_OVERRIDE_OPTIMIZATION_FLAGS (no-size-optimization) flag is not set
+override_release_flags_for_size_optimization()
+
+# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
+if(QUIET_BUILD)
+ set(CMAKE_INSTALL_MESSAGE NEVER)
+endif()
+
+# Override message not to display info messages when doing a quiet build.
+if(QUIET_BUILD AND is_pyside6_superproject_build)
+ function(message)
+ list(GET ARGV 0 MessageType)
+ if(MessageType STREQUAL FATAL_ERROR OR
+ MessageType STREQUAL SEND_ERROR OR
+ MessageType STREQUAL WARNING OR
+ MessageType STREQUAL AUTHOR_WARNING)
+ list(REMOVE_AT ARGV 0)
+ _message(${MessageType} "${ARGV}")
+ endif()
+ endfunction()
+endif()
+
+
+pyside_internal_detect_if_cross_building()
+pyside_internal_set_up_extra_dependency_paths()
+pyside_internal_find_host_shiboken_tools()
+find_package(Shiboken6 6 CONFIG REQUIRED)
+
+if(is_pyside6_superproject_build)
+ shiboken_find_required_python()
+endif()
+
+set(BINDING_API_MAJOR_VERSION "${pyside_MAJOR_VERSION}")
+set(BINDING_API_MINOR_VERSION "${pyside_MINOR_VERSION}")
+set(BINDING_API_MICRO_VERSION "${pyside_MICRO_VERSION}")
+set(BINDING_API_PRE_RELEASE_VERSION_TYPE "${pyside_PRE_RELEASE_VERSION_TYPE}")
+set(BINDING_API_PRE_RELEASE_VERSION "${pyside_PRE_RELEASE_VERSION}")
+
+# Detect if the Python interpreter is actually PyPy
+execute_process(
+ COMMAND ${Python_EXECUTABLE} -c "if True:
+ pypy_version = ''
+ import sys
+ if hasattr(sys, 'pypy_version_info'):
+ pypy_version = '.'.join(map(str, sys.pypy_version_info[:3]))
+ print(pypy_version)
+ "
+ OUTPUT_VARIABLE PYPY_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if(WIN32)
+ set(PATH_SEP "\;")
+else()
+ set(PATH_SEP ":")
+endif()
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "${SHIBOKEN_BUILD_TYPE}" CACHE STRING "Build Type")
+endif()
+
+if(CMAKE_BUILD_TYPE STREQUAL "Release")
+ add_definitions("-DNDEBUG")
+endif()
+
+if(SHIBOKEN_PYTHON_LIMITED_API)
+ message(STATUS "******************************************************")
+ message(STATUS "** PySide6 Limited API enabled.")
+ message(STATUS "******************************************************")
+endif()
+
+# Need to ensure host Tools packages are found instead of target ones when cross-compiling.
+if(QFP_QT_HOST_PATH)
+ get_filename_component(__qt_host_path_absolute "${QFP_QT_HOST_PATH}" ABSOLUTE)
+ if(EXISTS "${__qt_host_path_absolute}")
+ set(QT_HOST_PATH "${__qt_host_path_absolute}")
+
+ set(__qt_candidate_host_path_cmake_dir "${QT_HOST_PATH}/lib/cmake")
+ if(EXISTS "${__qt_candidate_host_path_cmake_dir}")
+ set(QT_HOST_PATH_CMAKE_DIR "${__qt_candidate_host_path_cmake_dir}")
+ endif()
+ endif()
+endif()
+find_package(Qt6 REQUIRED COMPONENTS Core)
+
+add_definitions(${Qt${QT_MAJOR_VERSION}Core_DEFINITIONS})
+
+option(BUILD_TESTS "Build tests." TRUE)
+option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated files. This is used to allow multiples versions installed simultaneous." FALSE)
+set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
+set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
+if(CMAKE_HOST_APPLE)
+ set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "Deprecated. CMake now finds the proper include dir itself.")
+ set(OSX_USE_LIBCPP "OFF" CACHE BOOL "Explicitly link the libc++ standard library (useful for macOS deployment targets lower than 10.9.")
+ if(OSX_USE_LIBCPP)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ endif()
+endif()
+
+# Force usage of the C++17 standard
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# Obtain QT_INCLUDE_DIR from INTERFACE_INCLUDE_DIRECTORIES which returns a list
+# ../install-qt-6/include/QtCore;../install-qt-6/include
+set(QT_INCLUDE_DIR "")
+get_target_property(QT_INCLUDE_DIR_LIST Qt6::Core INTERFACE_INCLUDE_DIRECTORIES)
+foreach(_Q ${QT_INCLUDE_DIR_LIST})
+ if(NOT "${_Q}" MATCHES "QtCore$")
+ set(QT_INCLUDE_DIR "${_Q}")
+ endif()
+endforeach()
+if(QT_INCLUDE_DIR STREQUAL "")
+ message(FATAL_ERROR "Unable to obtain the Qt include directory")
+endif()
+
+# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
+get_target_property(QtCore_is_framework Qt${QT_MAJOR_VERSION}::Core FRAMEWORK)
+
+if(QtCore_is_framework)
+ # Get the path to the framework dir.
+ set(QT_FRAMEWORK_INCLUDE_DIR "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBS}")
+ message(STATUS "*** QT_FRAMEWORK_INCLUDE_DIR is ${QT_FRAMEWORK_INCLUDE_DIR}")
+ set(QT_INCLUDE_DIR "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_HEADERS}")
+endif()
+
+set_cmake_cxx_flags()
+
+message(STATUS "*** computed QT_INCLUDE_DIR as ${QT_INCLUDE_DIR}")
+
+set(BINDING_NAME PySide6)
+
+set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide6 version" FORCE)
+set(PYSIDE_SO_VERSION ${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION})
+if(BINDING_API_PRE_RELEASE_VERSION_TYPE STREQUAL "")
+ set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}"
+ CACHE STRING "PySide6 version [full]" FORCE)
+else()
+ set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}~${BINDING_API_PRE_RELEASE_VERSION_TYPE}${BINDING_API_PRE_RELEASE_VERSION}"
+ CACHE STRING "PySide6 version [full]" FORCE)
+endif()
+
+compute_config_py_values(BINDING_API_VERSION)
+
+include(PySideModules)
+
+# Set default values for pyside6_global.h
+set (Qt${QT_MAJOR_VERSION}Test_FOUND "0")
+set (Qt${QT_MAJOR_VERSION}Widgets_FOUND "0")
+
+collect_essential_modules()
+collect_optional_modules()
+
+# Modules to be built unless specified by -DMODULES on command line
+if(NOT MODULES)
+ set(MODULES "${ALL_ESSENTIAL_MODULES};${ALL_OPTIONAL_MODULES}")
+endif()
+
+# This will contain the set of modules for which bindings are not built.
+set(DISABLED_MODULES "${ALL_ESSENTIAL_MODULES};${ALL_OPTIONAL_MODULES}")
+
+remove_skipped_modules()
+
+# Mark all non-collected modules as disabled. This is used for disabling tests
+# that depend on the disabled modules.
+foreach(m ${DISABLED_MODULES})
+ set(DISABLE_Qt${m} 1)
+endforeach()
+
+# Whether to add libpysideqml
+find_package(Qt6 COMPONENTS Qml)
+
+string(REGEX MATCHALL "[0-9]+" qt_version_helper "${Qt${QT_MAJOR_VERSION}Core_VERSION}")
+
+list(GET qt_version_helper 0 QT_VERSION_MAJOR)
+list(GET qt_version_helper 1 QT_VERSION_MINOR)
+list(GET qt_version_helper 2 QT_VERSION_PATCH)
+unset(qt_version_helper)
+
+set(PYSIDE_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" CACHE STRING "Qt version used to compile PySide" FORCE)
+if(ENABLE_VERSION_SUFFIX)
+ set(pyside_SUFFIX "-${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}")
+endif()
+
+# no more supported: include(${QT_USE_FILE})
+
+# Configure OS support
+check_os()
+
+# Define supported Qt Version
+set(SUPPORTED_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
+
+
+# uninstall target
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+
+# When opening super project, prevent redefinition of uninstall target.
+if(NOT TARGET uninstall)
+ add_custom_target(uninstall "${CMAKE_COMMAND}"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+endif()
+
+if(NOT PYTHON_SITE_PACKAGES)
+ shiboken_internal_set_python_site_packages()
+endif()
+
+shiboken_get_debug_level(debug_level)
+
+set(GENERATOR_EXTRA_FLAGS
+ ${SHIBOKEN_GENERATOR_EXTRA_FLAGS}
+ ${debug_level}
+ --generator-set=shiboken
+ --enable-parent-ctor-heuristic
+ --enable-pyside-extensions
+ --enable-return-value-heuristic
+ --use-isnull-as-nb-bool)
+use_protected_as_public_hack()
+
+# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk.
+if(SANITIZE_ADDRESS AND NOT MSVC)
+ setup_sanitize_address()
+endif()
+
+find_package(Qt6 COMPONENTS Designer)
+