aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scriptableapplication/scriptableapplication.pro
blob: 2719160f35f537ee47217f392d6931f55d7624a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
TEMPLATE = app
CONFIG += no_keywords # avoid clash with slots in Python.h
CONFIG += console force_debug_info
QT += widgets

include(pyside2.pri)

WRAPPED_HEADER = wrappedclasses.h
WRAPPER_DIR = $$OUT_PWD/AppLib
TYPESYSTEM_FILE = scriptableapplication.xml

QT_INCLUDEPATHS = -I$$[QT_INSTALL_HEADERS] -I$$[QT_INSTALL_HEADERS]/QtCore \
    -I$$[QT_INSTALL_HEADERS]/QtGui -I$$[QT_INSTALL_HEADERS]/QtWidgets

SHIBOKEN_OPTIONS = --generator-set=shiboken --enable-parent-ctor-heuristic \
    --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero \
    $$QT_INCLUDEPATHS -I$$PWD -T$$PWD -T$$PYSIDE2/typesystems --output-directory=$$OUT_PWD

# MSVC does not honor #define protected public...
win32:SHIBOKEN_OPTIONS += --avoid-protected-hack

# Prepare the shiboken tool
QT_TOOL.shiboken.binary = $$system_path($$PYSIDE2/shiboken2)
win32 {
    # Add the libclang/bin subdir to PATH.
    CLANG_PATH.name = PATH
    CLANG_PATH.value = $$CLANG_BIN_DIR
    CLANG_PATH.CONFIG += prepend
    exists($$CLANG_PATH.value): QT_TOOL_ENV = CLANG_PATH
}
qtPrepareTool(SHIBOKEN, shiboken)
QT_TOOL_ENV =

# Shiboken run that adds the module wrapper to GENERATED_SOURCES
shiboken.output = $$WRAPPER_DIR/applib_module_wrapper.cpp
shiboken.commands = $$SHIBOKEN $$SHIBOKEN_OPTIONS $$PWD/wrappedclasses.h ${QMAKE_FILE_IN}
shiboken.input = TYPESYSTEM_FILE
shiboken.dependency_type = TYPE_C
shiboken.variable_out = GENERATED_SOURCES

# A dummy command that pretends to produce the class wrappers from the headers
# depending on the module wrapper
WRAPPED_CLASSES = mainwindow.h
module_wrapper_dummy_command.output = $$WRAPPER_DIR/${QMAKE_FILE_BASE}_wrapper.cpp
module_wrapper_dummy_command.commands = echo ${QMAKE_FILE_IN}
module_wrapper_dummy_command.depends = $$WRAPPER_DIR/applib_module_wrapper.cpp
module_wrapper_dummy_command.input = WRAPPED_CLASSES
module_wrapper_dummy_command.dependency_type = TYPE_C
module_wrapper_dummy_command.variable_out = GENERATED_SOURCES

# Get the path component to the active config build folder
defineReplace(getOutDir) {
  out_dir = $$OUT_PWD
  CONFIG(release, debug|release): out_dir = $$out_dir/release
  else:out_dir = $$out_dir/debug
  return($$out_dir)
}

# Create hardlinks to the PySide2 shared libraries, so the example can be executed without manually
# setting the PATH.
win32 {
    out_dir = $$getOutDir()
    # no_link tell not to link to the output files, target_predeps forces the command to actually
    # execute, explicit_dependencies is a magic value that tells qmake not to run the commands
    # if the output files already exist.
    hard_link_libraries.CONFIG = no_link target_predeps explicit_dependencies
    hard_link_libraries.output = $$out_dir/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
    hard_link_libraries.commands = mklink /H $$shell_path($$out_dir/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}) $$shell_path(${QMAKE_FILE_IN})
    hard_link_libraries.input = PYSIDE2_SHARED_LIBRARIES
}

QMAKE_EXTRA_COMPILERS += shiboken module_wrapper_dummy_command
win32:QMAKE_EXTRA_COMPILERS += hard_link_libraries

INCLUDEPATH += $$WRAPPER_DIR

# fixme: Hack to find wrappers
PACKAGE_DIR = $$PWD/../../pyside_package/PySide2

INCLUDEPATH += $$PACKAGE_DIR/include/PySide2/QtWidgets \
    $$PACKAGE_DIR/include/PySide2/QtGui $$PACKAGE_DIR/include/PySide2/QtCore

SOURCES += \
    main.cpp \
    mainwindow.cpp \
    pythonutils.cpp

HEADERS += \
    mainwindow.h \
    pythonutils.h

OTHER_FILES += $$TYPESYSTEM_FILE $$WRAPPED_HEADER pyside2_config.py README.txt