diff options
| author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-10-13 14:43:06 +0200 |
|---|---|---|
| committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-11-02 10:36:55 +0100 |
| commit | 7cc5c139482d735c49002649d26bb524c92cc86b (patch) | |
| tree | 4af761eb45a3d777765b015f26ecfb84a1bd006c /sources/pyside6 | |
| parent | 8b7f7fa1eaa44fcaa3e6d494793b2d5a27590a06 (diff) | |
CMake: Tell shiboken to process Qt headers inside system include dirs
When building Qt For Python using yocto, the Qt headers are in a
sysroot which libclang considers as system headers. Shiboken skips
processing system headers.
To ensure Qt headers are still processed, introduce a new
--force-process-system-include-paths option to shiboken and two new
CMake variables: PYSIDE_TREAT_QT_INCLUDE_DIRS_AS_NON_SYSTEM and
SHIBOKEN_FORCE_PROCESS_SYSTEM_INCLUDE_PATHS.
When PYSIDE_TREAT_QT_INCLUDE_DIRS_AS_NON_SYSTEM is set to true, the
build system will pass the Qt include dirs to
--force-process-system-include-paths to ensure the Qt headers are
processed and their types extracted.
Similarly SHIBOKEN_FORCE_PROCESS_SYSTEM_INCLUDE_PATHS can be passed a
list of extra dir paths when creating non-Qt related bindings.
Sysroots usually contain headers other than Qt headers, so there's a
chance that a non-Qt-related system header fails to be be parsed and
will fail the shiboken execution.
To avoid breaking setups that previously worked because of the issue
described above, the new options are opt-in rather than opt-out.
In case one such an issue is encountered, the solution would be to
copy / move the Qt headers into a separate location and specify the
new location as both an include path and a force process system include
path (in case the copied headers are still somewhere under the
sysroot).
Pick-to: 6.6
Task-number: PYSIDE-1958
Change-Id: I1733478e9c6057f84de7864940c6150b378749cf
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6')
| -rw-r--r-- | sources/pyside6/cmake/Macros/PySideModules.cmake | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake index 463c60945..1288abd40 100644 --- a/sources/pyside6/cmake/Macros/PySideModules.cmake +++ b/sources/pyside6/cmake/Macros/PySideModules.cmake @@ -112,6 +112,39 @@ macro(create_pyside_module) # 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. @@ -136,6 +169,7 @@ 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 |
