-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossplatform.cmake
executable file
·93 lines (71 loc) · 3.3 KB
/
crossplatform.cmake
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
#
# Copyright (C) 2018-2024 QuasarApp.
# Distributed under the MIT software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
if(DEFINED CROSSPLATFORM_BUILD_TOOLCHAIN)
return()
else()
set(CROSSPLATFORM_BUILD_TOOLCHAIN 1)
endif()
# use TARGET_PLATFORM_TOOLCHAIN
# This module include crossplatform toolchains by target platform.
# To select target platform set the TARGET_PLATFORM_TOOLCHAIN define.
# Availabel platforms:
# * wasm32
# * win32-g++
# * win64-g++
#
# Note
# For add full support of the wasm32 build you shold use the initWasmSupport method. This method prepare static build for wasm executable and qt resources.
#
# initWasmSupport arguments:
# * name - This is name of your initialize targets. You can set it as a CMAKE_PROJECT
# * deployFile - This is path to the deploy file of the cqtdepoyer tool. Use it for deploy your site.
if (NOT DEFINED TARGET_PLATFORM_TOOLCHAIN)
message(STATUS "The crossplatform build is disabled")
return()
endif()
set(CROSSPLATFORM_BUILD_TOOLCHAIN_PATH ${CMAKE_CURRENT_LIST_DIR}/${CMAKE_HOST_SYSTEM_NAME}/${TARGET_PLATFORM_TOOLCHAIN}.cmake)
message("CROSSPLATFORM_BUILD_TOOLCHAIN_PATH = ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}")
if(EXISTS ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH})
message(STATUS "${TARGET_PLATFORM_TOOLCHAIN} exits in ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}")
include("${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}")
else(EXISTS ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH})
message(STATUS "${TARGET_PLATFORM_TOOLCHAIN} not exits in ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}")
endif()
if (DEFINED TARGET_PLATFORM_TOOLCHAIN)
if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
set(QA_WASM32 ON CACHE BOOL "Custom define that enabled only when wasm32 platform are used" FORCE)
endif(${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
endif(DEFINED TARGET_PLATFORM_TOOLCHAIN)
function(initWasmSupport name deployFile)
if(NOT TARGET ${name})
message("the ${name} target is not created!")
return()
endif(NOT TARGET ${name})
message("init support wasm build for target ${name}")
if (DEFINED TARGET_PLATFORM_TOOLCHAIN)
if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
message(added deploy step for site)
set_target_properties(${name} PROPERTIES OUTPUT_NAME "${name}.js")
addDeployFromFile(${deployFile})
include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../QtStaticCMake/QtStaticCMake.cmake)
qt_generate_plugin_import(${name} VERBOSE)
# EXTRA_PLUGIN are the one required by plugin loaded by qt_generate_plugin_import
# It's not automatic yet :( All this workflow might change in future version of qt
# with better and better cmake support
qt_generate_qml_plugin_import(${name}
QML_SRC ${CMAKE_CURRENT_SOURCE_DIR}
EXTRA_PLUGIN
QtQuickVirtualKeyboardPlugin
QtQuickVirtualKeyboardSettingsPlugin
QtQuickVirtualKeyboardStylesPlugin
QmlFolderListModelPlugin
QQuickLayoutsPlugin
VERBOSE
)
endif(${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
endif(DEFINED TARGET_PLATFORM_TOOLCHAIN)
endfunction()