[qt-build] How to differentiate host and target in source code/qmake?
-
How to differentiate host and target in source code/qmake?
Both my host and target is linux-gcc, but with different versions.
I would like to add some compiler/linker flags for target.
For example, in order to use santizer, I have to add cc flags, and linker flags [to a proper place].However host toolchain version is different, which means that if I casually do something like this:
https://codereview.qt-project.org/#change,43420
Host tools build fails with unknown options.There are several problems here:
- I couldn't find a way to add target-only stuffs to qmake.
- I couldn't find a way to add linker flags to the designated place. (which is critical)
qmake bootstrap process is tricky and surprising, and linker flags are ordered as a side effect of this process.
In case of a native build, these problems is relatively easy to workaround.
However for a cross build, these problems become nasty. -
How to differentiate host and target in source code/qmake?
Both my host and target is linux-gcc, but with different versions.
I would like to add some compiler/linker flags for target.
For example, in order to use santizer, I have to add cc flags, and linker flags [to a proper place].However host toolchain version is different, which means that if I casually do something like this:
https://codereview.qt-project.org/#change,43420
Host tools build fails with unknown options.There are several problems here:
- I couldn't find a way to add target-only stuffs to qmake.
- I couldn't find a way to add linker flags to the designated place. (which is critical)
qmake bootstrap process is tricky and surprising, and linker flags are ordered as a side effect of this process.
In case of a native build, these problems is relatively easy to workaround.
However for a cross build, these problems become nasty.@myobyte
hi,take a look at the qmake variables especially the subsection
QMAKE_HOST
it will allow you to specify the host:.arch Host architecture .os Host OS .cpu_count Number of available cpus .name Host computer name .version Host OS version number .version_string Host OS version string
example from the docu:
win32-g++:contains(QMAKE_HOST.arch, x86_64):{ message("Host is 64bit") ... }
-
@myobyte
hi,take a look at the qmake variables especially the subsection
QMAKE_HOST
it will allow you to specify the host:.arch Host architecture .os Host OS .cpu_count Number of available cpus .name Host computer name .version Host OS version number .version_string Host OS version string
example from the docu:
win32-g++:contains(QMAKE_HOST.arch, x86_64):{ message("Host is 64bit") ... }
@J.Hilk said in [qt-build] How to differentiate host and target in source code/qmake?:
@myobyte
hi,take a look at the qmake variables especially the subsection
QMAKE_HOST
it will allow you to specify the host:I can't see how QMAKE_HOST can be used to add target-only flags in qmake.
-
Hi,
Something's not clear here, do you mean that your are "cross-compiling" for the same architecture but with a different version of the compiler ?
-
Hi,
Something's not clear here, do you mean that your are "cross-compiling" for the same architecture but with a different version of the compiler ?
@SGaist said in [qt-build] How to differentiate host and target in source code/qmake?:
Hi,
Something's not clear here, do you mean that your are "cross-compiling" for the same architecture but with a different version of the compiler ?
I use both native build and cross build.
The cross-compiling build is target=arm/arm64, while host=x86_x64.
The native build is x86_64.Besides, the cc/ld options is not something that could be put into platform conf and forget.
As far as I can recall, platform conf is loaded very early, and cc/ld options will appear at the begin of the gcc cmdline -- the wrong place that build will fail. -
Then you should use a scope matching your target. e.g.
linux-beagleboard-g++
if you are using the BBB mkspeclinux-beagleboard-g++ { message("BBB specifics") }