| 1 |
project('qt6 qml build test', 'cpp', |
| 2 |
meson_version: '>= 1.7.0', |
| 3 |
# Qt6 requires C++ 17 support |
| 4 |
default_options : ['cpp_std=c++17'] |
| 5 |
) |
| 6 |
|
| 7 |
qt_modules = ['Core', 'Gui', 'Qml'] |
| 8 |
|
| 9 |
qtdep = dependency('qt6', modules : qt_modules, main : true, private_headers: true, required : false, method : get_option('method')) |
| 10 |
if not qtdep.found() |
| 11 |
error('MESON_SKIP_TEST qt6 not found.') |
| 12 |
endif |
| 13 |
|
| 14 |
qtmodule = import('qt6') |
| 15 |
fs = import('fs') |
| 16 |
|
| 17 |
qmlmodule1 = qtmodule.qml_module( |
| 18 |
'My.Module1', |
| 19 |
version: '1.0', |
| 20 |
qml_sources: files('Basic.qml', 'subdir/Thing.qml'), |
| 21 |
qml_singletons: files('QmlSingleton.qml'), |
| 22 |
qml_internals: files('Internal.qml'), |
| 23 |
moc_headers: files('QmlCppExposed.hpp', 'QmlCppOtherExposed.hpp'), |
| 24 |
designer_supported: true, |
| 25 |
dependencies: [qtdep], |
| 26 |
install: true |
| 27 |
) |
| 28 |
|
| 29 |
#with a different resource prefix |
| 30 |
qmlmodule2 = qtmodule.qml_module( |
| 31 |
'My.Module2', |
| 32 |
version: '1.0', |
| 33 |
qml_sources: ['Basic.qml', 'subdir/Thing.qml'], |
| 34 |
resources_prefix: '/test', |
| 35 |
dependencies: [qtdep], |
| 36 |
) |
| 37 |
|
| 38 |
#test with generated targets |
| 39 |
basic_copy = fs.copyfile('Basic.qml') |
| 40 |
thing_copy = fs.copyfile('subdir/Thing.qml') |
| 41 |
|
| 42 |
#build without cachegen |
| 43 |
qmlmodule3 = qtmodule.qml_module( |
| 44 |
'My.Module3', |
| 45 |
version: '1.10.42', |
| 46 |
qml_sources: [basic_copy, thing_copy], |
| 47 |
cachegen: false, |
| 48 |
dependencies: [qtdep], |
| 49 |
) |
| 50 |
|
| 51 |
#build without cachegen |
| 52 |
qmlmodule4 = qtmodule.qml_module( |
| 53 |
'My.Module4', |
| 54 |
qml_sources: files('Basic.qml', 'subdir/Thing.qml'), |
| 55 |
generate_qmldir: false, |
| 56 |
dependencies: [qtdep], |
| 57 |
) |
| 58 |
|
| 59 |
qmlmodule4_res = qtmodule.compile_resources( |
| 60 |
name : 'qmlmodule4_resource', |
| 61 |
sources : files(['custom_qmldir.qrc']), |
| 62 |
method : get_option('method') |
| 63 |
) |
| 64 |
|
| 65 |
#a module with only C++ classes |
| 66 |
cpponly_module = qtmodule.qml_module( |
| 67 |
'My.Module5', |
| 68 |
version: '1.0', |
| 69 |
moc_headers: files('subdir/SubdirHeader.hpp'), |
| 70 |
dependencies: [qtdep], |
| 71 |
install: true |
| 72 |
) |
| 73 |
|
| 74 |
#module as static library |
| 75 |
qmlmodule6 = qtmodule.qml_module( |
| 76 |
'My.Module6', |
| 77 |
version: '1.0', |
| 78 |
qml_sources: files('Basic.qml'), |
| 79 |
moc_headers: files('subdir/SubdirHeader.hpp'), |
| 80 |
cachegen: true, |
| 81 |
dependencies: [qtdep], |
| 82 |
) |
| 83 |
|
| 84 |
qmlmodule6_static = static_library( |
| 85 |
'Qmlmodule6Lib', |
| 86 |
sources: qmlmodule6, |
| 87 |
include_directories: include_directories('subdir'), |
| 88 |
dependencies: [qtdep], |
| 89 |
override_options: 'unity=off', |
| 90 |
) |
| 91 |
|
| 92 |
#qml entry point and qmldir dependecies |
| 93 |
qmlmodule0 = qtmodule.qml_module( |
| 94 |
'My.Module0', |
| 95 |
version: '1.0', |
| 96 |
qml_sources: files('Main.qml'), |
| 97 |
imports: ['QtQuick/2.0', 'My.Module1'], |
| 98 |
optional_imports: ['My.Module2/auto'], |
| 99 |
dependencies: [qtdep], |
| 100 |
) |
| 101 |
|
| 102 |
qmltest = executable( |
| 103 |
'qmlmodule', |
| 104 |
sources : [ |
| 105 |
'QmlMain.cpp', qmlmodule0, qmlmodule1, qmlmodule2, |
| 106 |
qmlmodule3, qmlmodule4, qmlmodule4_res, cpponly_module |
| 107 |
], |
| 108 |
link_with : qmlmodule6_static, |
| 109 |
dependencies : qtdep, |
| 110 |
# headers in subdirectory needs to have their include path explicitly |
| 111 |
# added for the code generated by by qmltyperegistrar. see QTBUG-87221 |
| 112 |
include_directories: include_directories('subdir'), |
| 113 |
#generated code doesn't support unity build |
| 114 |
override_options: 'unity=off', |
| 115 |
) |