aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/cmake')
-rw-r--r--sources/pyside6/cmake/Macros/PySideModules.cmake94
-rw-r--r--sources/pyside6/cmake/Macros/icecc.cmake3
-rw-r--r--sources/pyside6/cmake/PySideHelpers.cmake33
-rw-r--r--sources/pyside6/cmake/PySideSetup.cmake24
4 files changed, 128 insertions, 26 deletions
diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake
index cca66be8e..33b844f95 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,21 @@ 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)
@@ -48,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
)
@@ -105,10 +123,46 @@ macro(create_pyside_module)
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(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)
# Install module glue files.
@@ -133,12 +187,42 @@ macro(create_pyside_module)
$<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})
@@ -240,7 +324,7 @@ macro(create_pyside_module)
# 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)
+ 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
@@ -256,11 +340,7 @@ macro(create_pyside_module)
${generate_pyi_options})
add_dependencies("${module_NAME}_pyi" ${module_NAME})
- file(GLOB hinting_stub_files
- RELATIVE
- "${CMAKE_CURRENT_BINARY_DIR}/PySide6"
- "${CMAKE_CURRENT_BINARY_DIR}/PySide6/*.pyi")
- install(FILES ${hinting_stub_files}
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/../${module_NAME}.pyi"
DESTINATION "${PYTHON_SITE_PACKAGES}/PySide6")
endif()
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
index 31a1d97f3..01c438107 100644
--- a/sources/pyside6/cmake/PySideHelpers.cmake
+++ b/sources/pyside6/cmake/PySideHelpers.cmake
@@ -1,3 +1,6 @@
+# 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)
@@ -83,6 +86,7 @@ endmacro()
macro(collect_optional_modules)
# Collect all optional modules.
set(ALL_OPTIONAL_MODULES
+ DBus
Designer
Xml
Help Multimedia
@@ -92,12 +96,14 @@ macro(collect_optional_modules)
Pdf
PdfWidgets
Positioning
+ Location
NetworkAuth
Nfc
Qml
Quick
Quick3D
QuickControls2
+ QuickTest
QuickWidgets
RemoteObjects
Scxml
@@ -111,6 +117,7 @@ macro(collect_optional_modules)
Svg
SvgWidgets
DataVisualization
+ Graphs
Bluetooth)
find_package(Qt${QT_MAJOR_VERSION}UiTools)
if(Qt${QT_MAJOR_VERSION}UiTools_FOUND)
@@ -122,12 +129,7 @@ macro(collect_optional_modules)
list(APPEND ALL_OPTIONAL_MODULES AxContainer)
endif()
list(APPEND ALL_OPTIONAL_MODULES WebChannel WebEngineCore WebEngineWidgets
- WebEngineQuick WebSockets)
- if(NOT WIN32)
- # FIXME: Move to global once DELETE define clash is resolved.
- list(APPEND ALL_OPTIONAL_MODULES HttpServer)
- list(APPEND ALL_OPTIONAL_MODULES DBus)
- endif()
+ WebEngineQuick WebSockets HttpServer)
list(APPEND ALL_OPTIONAL_MODULES 3DCore 3DRender 3DInput 3DLogic 3DAnimation 3DExtras)
endmacro()
@@ -136,13 +138,18 @@ macro(check_os)
set(ENABLE_MAC "0")
set(ENABLE_WIN "0")
- 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")
+ # 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()
diff --git a/sources/pyside6/cmake/PySideSetup.cmake b/sources/pyside6/cmake/PySideSetup.cmake
index a4ec74d44..038dc1642 100644
--- a/sources/pyside6/cmake/PySideSetup.cmake
+++ b/sources/pyside6/cmake/PySideSetup.cmake
@@ -1,3 +1,6 @@
+# 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)
@@ -40,6 +43,10 @@ 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}")
@@ -48,7 +55,7 @@ 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:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
pypy_version = ''
import sys
if hasattr(sys, 'pypy_version_info'):
@@ -215,11 +222,16 @@ if(NOT PYTHON_SITE_PACKAGES)
shiboken_internal_set_python_site_packages()
endif()
-set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
- --enable-parent-ctor-heuristic
- --enable-pyside-extensions
- --enable-return-value-heuristic
- --use-isnull-as-nb_nonzero)
+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.