PDA

View Full Version : To detect 32 bit or 64 bit platform in .pro file



rajji_saini
9th May 2011, 19:47
Hi,

I am trying to create a project to be built on both 64 bit and 32 bit Linux/Windows environment.
This is what I am doing to detect for architecture:

contains(QMAKE_TARGET.arch, x86_64):{
message( "Building for 64 bit")
}

!contains(QMAKE_TARGET.arch, x86_64):{
message( "Building for 32 bit")
}

I am using 64 bit machine with RHEL6, but it always go in to 32 bit. It doesnt detect that I am on 64 bit machine.

My qmake parameters are as follows:
qmake Test.pro -r -spec linux-g++-64 CONFIG+=debug

Am I doing anything wrong . Please suggest.
Or is there any other way of doing this ???

Thanks in advance for youe help.

Regards,
Raj

wysota
9th May 2011, 19:51
Try:
*-64 { ... }

rajji_saini
9th May 2011, 23:01
I just realized from this following link that QMAKE_TARGET.arch needs to be set somwhere.

http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compilin g_on_a_32_bit_or_a_64_bi

Violet Giraffe
5th July 2011, 16:24
How to set QMAKE_TARGET.arch? I have quite a problem telling win32 from win64.

rajji_saini
12th October 2011, 19:43
I set it in my Projects .pro file using an environment variable.

QMAKE_TARGET.arch = $$(BUILD_PROJ)

BUILD_PROJ can be set to x86_64 or x86 as envt variable.