2019-10-05 15:28:00 +03:00
#
2024-12-30 22:37:58 +01:00
# Copyright (C) 2018-2025 QuasarApp.
2019-10-05 15:28:00 +03:00
# 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 ( )
2020-09-21 19:33:40 +03:00
# use TARGET_PLATFORM_TOOLCHAIN
2019-10-05 15:28:00 +03:00
2021-04-20 11:21:22 +03:00
# 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.
2019-10-05 15:28:00 +03:00
2021-04-20 11:30:01 +03:00
if ( NOT DEFINED TARGET_PLATFORM_TOOLCHAIN )
2021-04-20 11:38:35 +03:00
message ( STATUS "The crossplatform build is disabled" )
2021-04-20 11:30:01 +03:00
return ( )
2021-04-20 11:34:36 +03:00
endif ( )
2021-04-20 11:30:01 +03:00
2020-09-21 19:33:40 +03:00
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}" )
2019-10-05 15:28:00 +03:00
if ( EXISTS ${ CROSSPLATFORM_BUILD_TOOLCHAIN_PATH } )
2021-04-20 11:38:35 +03:00
message ( STATUS "${TARGET_PLATFORM_TOOLCHAIN} exits in ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}" )
2019-10-05 15:28:00 +03:00
2021-04-20 11:38:35 +03:00
include ( "${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}" )
2019-10-05 15:28:00 +03:00
else ( EXISTS ${ CROSSPLATFORM_BUILD_TOOLCHAIN_PATH } )
2021-04-20 11:30:01 +03:00
message ( STATUS "${TARGET_PLATFORM_TOOLCHAIN} not exits in ${CROSSPLATFORM_BUILD_TOOLCHAIN_PATH}" )
2019-10-05 15:28:00 +03:00
endif ( )
2022-06-05 13:38:39 +03:00
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 )
2020-09-23 15:41:57 +03:00
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 }
Q M L _ S R C $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
E X T R A _ P L U G I N
Q t Q u i c k V i r t u a l K e y b o a r d P l u g i n
Q t Q u i c k V i r t u a l K e y b o a r d S e t t i n g s P l u g i n
Q t Q u i c k V i r t u a l K e y b o a r d S t y l e s P l u g i n
Q m l F o l d e r L i s t M o d e l P l u g i n
Q Q u i c k L a y o u t s P l u g i n
V E R B O S E
)
endif ( ${ TARGET_PLATFORM_TOOLCHAIN } STREQUAL "wasm32" )
endif ( DEFINED TARGET_PLATFORM_TOOLCHAIN )
endfunction ( )