aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/CMakeLists.txt
blob: c109b2e0eb2fe1c1ba3c8294a7bc259f4fce3cba (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
93
94
95
96
97
98
99
100
101
102
103
104
project(pyside2)

# Configure include based on platform
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in"
               "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h" @ONLY)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in"
               "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_config.py.in"
              "${CMAKE_CURRENT_BINARY_DIR}/_config.py" @ONLY)

# Use absolute path instead of relative path, to avoid ninja build errors due to
# duplicate file dependency inconsistency.
set(pyside_version_relative_path "${CMAKE_CURRENT_SOURCE_DIR}/../pyside_version.py")
get_filename_component(pyside_version_path ${pyside_version_relative_path} ABSOLUTE)
configure_file("${pyside_version_path}"
               "${CMAKE_CURRENT_BINARY_DIR}/_git_pyside_version.py" @ONLY)

# qt.conf needs to be placed next to QtWebEngineProcess so that the executable uses the correct
# Prefix location leading to an existing icu data file. It is needed on Windows, Linux, and macOS
# non-framework build. In framework build, instead of using qt.conf, Bundle querying is used.
if (WIN32 OR (UNIX AND NOT APPLE) OR (APPLE AND NOT QtCore_is_framework))

    if (WIN32)
        # On Windows, the QtWebEngineProcess is directly located in the Prefix, due to not using
        # a "Qt" subfolder like on the other platforms.
        set(QT_CONF_PREFIX ".")
    else()
        # On Linux and non-framework macOS, the QtWebEngineProcess is in ./libexec, so prefix is one
        # level higher.
        set(QT_CONF_PREFIX "..")
    endif()

    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.in"
                   "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" @ONLY)
endif()

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/__init__.py"
               "${CMAKE_CURRENT_BINARY_DIR}/support/__init__.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/__init__.py"
               "${CMAKE_CURRENT_BINARY_DIR}/support/signature/__init__.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/loader.py"
               "${CMAKE_CURRENT_BINARY_DIR}/support/signature/loader.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/mapping.py"
               "${CMAKE_CURRENT_BINARY_DIR}/support/signature/mapping.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/parser.py"
               "${CMAKE_CURRENT_BINARY_DIR}/support/signature/parser.py" COPYONLY)
if (PYTHON_VERSION_MAJOR EQUAL 3)
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/inspect.py"
                   "${CMAKE_CURRENT_BINARY_DIR}/support/signature/inspect.py" COPYONLY)
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/typing36.py"
                   "${CMAKE_CURRENT_BINARY_DIR}/support/signature/typing.py" COPYONLY)
else()
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/backport_inspect.py"
                   "${CMAKE_CURRENT_BINARY_DIR}/support/signature/backport_inspect.py" COPYONLY)
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/signature/typing27.py"
                   "${CMAKE_CURRENT_BINARY_DIR}/support/signature/typing.py" COPYONLY)
endif()

# now compile all modules.
file(READ "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h" pyside2_global_contents)

foreach(shortname IN LISTS all_module_shortnames)
    set(name "Qt5${shortname}")
    HAS_QT_MODULE(${name}_FOUND Qt${shortname})

    # Create a module header consisting of pyside2_global.h and the module
    # include. Note: The contents of pyside2_global.h must be copied instead of
    # just #including it since shiboken will otherwise generate an
    # #include <pyside2_global.h> for the the type entries originating from it
    # (cf AbstractMetaBuilderPrivate::setInclude()).
    set(module_header "${CMAKE_CURRENT_BINARY_DIR}/Qt${shortname}_global.h")
    set(module_header_content "")
    set(pre_header "${CMAKE_CURRENT_BINARY_DIR}/Qt${shortname}/Qt${shortname}_global.pre.h")
    if(EXISTS "${pre_header}")
        file(READ "${pre_header}" pre_header_content)
        set(module_header_content "${pre_header_content}")
    endif()
    set(module_header_content "${module_header_content}\n${pyside2_global_contents}")
    # AxContainer/AxServer from Active Qt do not have module headers
    if(NOT "${shortname}" STREQUAL "AxContainer")
        set(module_header_content "${module_header_content}\n#include <Qt${shortname}/Qt${shortname}>")
    endif()
    set(post_header "${CMAKE_CURRENT_BINARY_DIR}/Qt${shortname}/Qt${shortname}_global.post.h")
    if(EXISTS "${post_header}")
        file(READ "${post_header}" post_header_content)
        set(module_header_content "${module_header_content}\n${post_header_content}")
    endif()
    file(WRITE ${module_header} "${module_header_content}")
endforeach()

# install
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
        DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_config.py"
        DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_git_pyside_version.py"
        DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml
        DESTINATION share/PySide2${pyside_SUFFIX}/typesystems)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h
        DESTINATION include/${BINDING_NAME}${pyside2_SUFFIX})