diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-03-17 13:30:54 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-07-07 13:45:19 +0200 |
| commit | 559fb65547236694dc04973f7fb6b39bac75d158 (patch) | |
| tree | 4166eb1db73960ee51b08fc1db6c49f9d6f8ce18 | |
| parent | d1d1abf334791febf3d5ddea39cdaa7a5a01b816 (diff) | |
Add a Python module for example assets
Task-number: PYSIDE-2206
Task-number: QTBUG-110428
Change-Id: I47b9ae8fa5357a9d7517d046ba47bd3baf3e91e3
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
| -rw-r--r-- | sources/pyside6/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | sources/pyside6/qtexampleicons/CMakeLists.txt | 52 | ||||
| -rw-r--r-- | sources/pyside6/qtexampleicons/module.c | 39 |
3 files changed, 93 insertions, 0 deletions
diff --git a/sources/pyside6/CMakeLists.txt b/sources/pyside6/CMakeLists.txt index 47e483c09..3d43ab6f7 100644 --- a/sources/pyside6/CMakeLists.txt +++ b/sources/pyside6/CMakeLists.txt @@ -33,3 +33,5 @@ if(BUILD_TESTS) endif() add_subdirectory(doc) + +add_subdirectory(qtexampleicons) diff --git a/sources/pyside6/qtexampleicons/CMakeLists.txt b/sources/pyside6/qtexampleicons/CMakeLists.txt new file mode 100644 index 000000000..1562f7b27 --- /dev/null +++ b/sources/pyside6/qtexampleicons/CMakeLists.txt @@ -0,0 +1,52 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.18) +cmake_policy(VERSION 3.18) + +project(QtExampleIcons) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTORCC ON) + +set(CMAKE_AUTOMOC ON) + +find_package(Qt6 COMPONENTS ExampleIconsPrivate) + +add_library(QtExampleIcons MODULE module.c) + +# See libshiboken/CMakeLists.txt +if(PYTHON_LIMITED_API) + target_compile_definitions(QtExampleIcons PRIVATE "-DPy_LIMITED_API=0x03050000") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(PYTHON_WITH_DEBUG) + target_compile_definitions(QtExampleIcons PRIVATE "-DPy_DEBUG") + endif() + if (PYTHON_WITH_COUNT_ALLOCS) + target_compile_definitions(QtExampleIcons PRIVATE "-DCOUNT_ALLOCS") + endif() +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + target_compile_definitions(QtExampleIcons PRIVATE "-DNDEBUG") +endif() + +target_include_directories(QtExampleIcons PRIVATE ${SHIBOKEN_PYTHON_INCLUDE_DIRS}) + +get_property(SHIBOKEN_PYTHON_LIBRARIES GLOBAL PROPERTY shiboken_python_libraries) + +target_link_libraries(QtExampleIcons PRIVATE + Qt::ExampleIconsPrivate + ${SHIBOKEN_PYTHON_LIBRARIES}) + +set_target_properties(QtExampleIcons PROPERTIES + PREFIX "" + OUTPUT_NAME "QtExampleIcons${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}" + LIBRARY_OUTPUT_DIRECTORY "${pyside6_BINARY_DIR}") + +if(WIN32) + set_property(TARGET QtExampleIcons PROPERTY SUFFIX ".pyd") +endif() + +install(TARGETS QtExampleIcons LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}/PySide6") diff --git a/sources/pyside6/qtexampleicons/module.c b/sources/pyside6/qtexampleicons/module.c new file mode 100644 index 000000000..4d0e67d5c --- /dev/null +++ b/sources/pyside6/qtexampleicons/module.c @@ -0,0 +1,39 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include <Python.h> + +#if defined _WIN32 +# define MODULE_EXPORT __declspec(dllexport) +#else +# define MODULE_EXPORT __attribute__ ((visibility("default"))) +#endif + +static PyMethodDef QtExampleIconsMethods[] = { + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef moduleDef = { + /* m_base */ PyModuleDef_HEAD_INIT, + /* m_name */ "QtExampleIcons", + /* m_doc */ NULL, + /* m_size */ -1, + /* m_methods */ QtExampleIconsMethods, + /* m_reload */ NULL, + /* m_traverse */ NULL, + /* m_clear */ NULL, + /* m_free */ NULL +}; + +MODULE_EXPORT PyObject *PyInit_QtExampleIcons(void) +{ + return PyModule_Create(&moduleDef); +} + +int main(int argc, char *argv[]) +{ + Py_SetProgramName(L"module-test"); + Py_Initialize(); + PyInit_QtExampleIcons(); + return 0; +} |
