Qt funs
-
Let us share the fun moments associated with Qt.
From qmake language:
illusive include
@
defineTest(ws_in) {
include($$1)
}
......
ws_in(some_file)
@
all works? check variables in included file. they were left in local function contex.
Very fun.
Developers do you know principle of least astonishment? -
Hi and welcome to devnet,
If you would like to discuss this with Qt developers you should rather post this on the interest mailing. You'll find there Qt developers/maintainers (this forum is more user oriented)
However, it's not really surprising. It's a test function which should return true or false, it's not there that you take actions like include.
-
But i`m totally agree with you. qmake in this case is working properly, it processes the inserted file in the local context of the function. A bug in the creator. It should not show the file in the project. But I do not consider this a serious bug. This is a good demonstration of a bottleneck in the system interaction creator - qmake. I think the reason the majority of claims to the creator qmake from users is in the system of semantic analysis .pro files creator.
Yet from his qmake I got. Control variables i had to manual exported to global context use export function.
Perfect going projects subdirs, sud-subdirs, sub-sub-... and no problem finding the header files, and connecting parts.@defineTest(ar_include1) {
for(a, INCLUDEPATH_PRI){
exists( $${a}/$$1 ){
include( $${a}/$$1 )
#export all variables that you need
export(DESTDIR)
export(LIBS)
export(INCLUDEPATH)
export(HEADERS)
export(QT)
export(CONFIG)
export(EXAMPLE_FILES)
return(true)
}
}
message($$1 not found on path list $$INCLUDEPATH_PRI)
return(false)I really wanted to add error location. but this impossible
on this level. qmake I still want to rewrite.
but now it is clear why not all qmake build errors has location
}
defineTest(ar_include2) { # use export list file in found dir
for(a, INCLUDEPATH_PRI){
exists( $${a}/$$1 ){
include( $${a}/$$1 )
exists( $${a}/export.pri ){
include( $${a}/export.pri ) # use export list file
return(true)
}else{
message(export file $${a}/export.pri not found)
return(false)
}
}
}
message($$1 not found on path list $$INCLUDEPATH_PRI)
return(false)
}
defineTest(ar_include3) { # use export list file passed as second arg
!exists( $$2 ){
message(export file $$2 not found)
return(false)
}
for(a, INCLUDEPATH_PRI){
exists( $${a}/$$1 ){
include( $${a}/$$1 )
include( $$2 ) # export list file
return(true)
}
}
message($$1 not found on path list $$INCLUDEPATH_PRI)
return(false)
}@"test project":https://drive.google.com/file/d/0B1uNXXiz7FliT2NZaWRiQmRIRGs/edit?usp=sharing
Optimally shared c++ header files saved in directories of their projects, and to connect from other projects I have arranged a shared folder on one level higher than top subdirs projects, and recorded there header files such type:
#include "path to really header/header.h"Now then builder work how i like.
-
I almost forgot about. technically also include a test function. except for append code is completely identical to the function exists. Feeble capabilities built-in language even allow you to adjust the relative path to the source files defined in including pri file. Very interesting is why this functionality is not added. Probably because of the sensitive ecosystem framework?
-
That's a question you should rather ask on the interest mailing list. You'll find there Qt's developers/maintainers (this forum use more user oriented)