Trying to make qmake PRINT the chars "<" and ">".
Hiho there,
I am trying to write a header file when qmake is executed and I can't make it write the characters "<" and ">".
More detailed, I would (simplified) like qmake to write following lines in a file called "test.hpp" for example!
As I am stuck at Qt4, I can't use the function "write_file", so my way would be to use "system()" instead, which works fine.
Code:
...
H = $$LITERAL_HASH
line01 = "$${H}ifndef TEST_HPP"
line02 = "$${H}define TEST_HPP"
line03 = "\n"
line04 = "$${H}include <QString>"
line05 = "\\n"
line06 = "$${H}endif //TEST_HPP"
...
system(echo $${line01} > test.hpp)
system(echo $${line02} >> test.hpp)
system(echo $${line03} >> test.hpp)
system(echo $${line04} >> test.hpp)
system(echo $${line05} >> test.hpp)
system(echo $${line06} >> test.hpp)
...
As long as I include those two characters, the file is not containing "line04".
The other minor problem is that I can't also create the empty line, as in "line03" and "line05". Backslash and double backslash doesn't work here!
But I could live without that if the include would work properly!
So, if you know the way, please enlighten me too... And if you know a better way of creating that file, please feel free to point this out.
Thanks in advance!
freeman_w
Re: Trying to make qmake PRINT the chars "<" and ">".
Have you tried:
Code:
system(echo "$${line01}" > test.hpp)
system(echo "$${line02}" >> test.hpp)
system(echo "$${line03}" >> test.hpp)
system(echo "$${line04}" >> test.hpp)
system(echo "$${line05}" >> test.hpp)
system(echo "$${line06}" >> test.hpp)
Re: Trying to make qmake PRINT the chars "<" and ">".
Didn't work when I tried it.
If you are trying to write, for example, an include file containing defines for stuff only the build system knows then you could look at QMAKE_SUBSTITUTES paired with template files:
Code:
// test.hpp.in
#ifndef TEST_HPP
#define TEST_HPP
#include <QString>
#define MYAPPVERSION '"$$VERSION"'
#define MYSPECIALVAR '"$$MY_SPECIAL_VAR"'
#endif //TEST_HPP
Code:
# test.pro
...
MY_SPECIAL_VAR = stuff
QMAKE_SUBSTITUTES += test.hpp.in
...
to get this file generated when qmake is run:
Code:
// test.hpp
#ifndef TEST_HPP
#define TEST_HPP
#include <QString>
#define MYAPPVERSION "1.0.0"
#define MYSPECIALVAR "stuff"
#endif //TEST_HPP