Instead of blindly searching in PATH, use Qt5Dependency.compilers_detect() (same for qt4) to get moc/uic/rcc. This is much more robust, and it improves the chances that the correct ones will be found. We still manually verify for now because the fallback in dependencies.py for searching is stll to look in PATH for backwards-compat, and because people probably have setups like that. Also sync the qt4 module with the qt5 module w.r.t. resource compilation and make the compiled qrc.cpp file unique in terms of the framework version used (4 vs 5). This is needed for the test to work properly, which now covers both Qt4 and 5.pull/1010/head
parent
a72740a0d1
commit
19a06d9033
3 changed files with 78 additions and 68 deletions
@ -1,41 +1,45 @@ |
||||
project('qt5 build test', 'cpp') |
||||
project('qt4 and 5 build test', 'cpp') |
||||
|
||||
qt5 = import('qt5') |
||||
qt5dep = dependency('qt5', modules : ['Core', 'Gui', 'Widgets']) |
||||
foreach qt : ['qt4', 'qt5'] |
||||
qtdep = dependency(qt, modules : ['Core', 'Gui', 'Widgets'], required : qt == 'qt5') |
||||
if qtdep.found() |
||||
qtmodule = import(qt) |
||||
|
||||
# The following has two resource files because having two in one target |
||||
# requires you to do it properly or you get linker symbol clashes. |
||||
# The following has two resource files because having two in one target |
||||
# requires you to do it properly or you get linker symbol clashes. |
||||
|
||||
prep = qt5.preprocess( |
||||
moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. |
||||
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. |
||||
qresources : ['stuff.qrc', 'stuff2.qrc'], # Resource file for rcc compiler. |
||||
) |
||||
prep = qtmodule.preprocess( |
||||
moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. |
||||
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. |
||||
qresources : ['stuff.qrc', 'stuff2.qrc'], # Resource file for rcc compiler. |
||||
) |
||||
|
||||
q5exe = executable('qt5app', |
||||
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. |
||||
prep], |
||||
dependencies : qt5dep) |
||||
qexe = executable(qt + 'app', |
||||
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. |
||||
prep], |
||||
dependencies : qtdep) |
||||
|
||||
# We need a console test application because some test environments |
||||
# do not have an X server. |
||||
# We need a console test application because some test environments |
||||
# do not have an X server. |
||||
|
||||
qt5core = dependency('qt5', modules : 'Core') |
||||
qtcore = dependency(qt, modules : 'Core') |
||||
|
||||
qt5coreapp = executable('q5core', 'q5core.cpp', |
||||
dependencies : qt5core) |
||||
qtcoreapp = executable(qt + 'core', 'q5core.cpp', |
||||
dependencies : qtcore) |
||||
|
||||
test('qt5test', qt5coreapp) |
||||
test(qt + 'test', qtcoreapp) |
||||
|
||||
# The build system needs to include the cpp files from |
||||
# headers but the user must manually include moc |
||||
# files from sources. |
||||
manpreprocessed = qt5.preprocess( |
||||
moc_sources : 'manualinclude.cpp', |
||||
moc_headers : 'manualinclude.h') |
||||
# The build system needs to include the cpp files from |
||||
# headers but the user must manually include moc |
||||
# files from sources. |
||||
manpreprocessed = qtmodule.preprocess( |
||||
moc_sources : 'manualinclude.cpp', |
||||
moc_headers : 'manualinclude.h') |
||||
|
||||
q5maninclude = executable('q5maninclude', |
||||
sources : ['manualinclude.cpp', manpreprocessed], |
||||
dependencies : qt5core) |
||||
qtmaninclude = executable(qt + 'maninclude', |
||||
sources : ['manualinclude.cpp', manpreprocessed], |
||||
dependencies : qtcore) |
||||
|
||||
test('q5maninclude', q5maninclude) |
||||
test(qt + 'maninclude', qtmaninclude) |
||||
endif |
||||
endforeach |
||||
|
Loading…
Reference in new issue