Qmake write_file () and system () don't want to make a file

I have strange qmake behavior when trying to write smth to another file. I have read all the possible guides and searched the internet but found nothing. Closer to the simplest possible code:

!system(echo 1 > d:\1.txt) {
  warning(Cant create a file)
}

      

It does not create a file and it does not display a warning, it means that the operation is complete. Another example:

var = test string
file = $$absolute_path(d:\1.txt)
message(Variable: $$var and filename: $$file)
!write_file($$pathBat, pathtowrite) {
  warning(Cant create a file)
}

      

This block produces output: Project MESSAGE: Variable: test string and filename: d:/1.txt

And it doesn't say anything about the file not being created.

I've already checked the directory write permissions: everything seems fine.

Can anyone help me with this?

UPD: I found something else: message($$system(echo 1 > 1.txt))

works fine. And it makes me cry because I really don't understand what's going on.

+3


source to share


1 answer


Ha! I found a solution and it might seem like buy yourself a brain. I thought it qmake

starts every time the project file changes (the output from the command message

confirmed my thoughts), but in fact it is not the same as in Qt.

I don't know how exactly, but it parses the .pro file, only does some necessary operations, and as I can see system()

(which is about to change some file) the commands write_file()

don't seem to be called.



THE SOLUTION is so simple: start qmake initially with Build - Launch qmake

.

+3


source







All Articles