August 16, 2011

jschmerge jschmerge
Lab Rat
3 posts

QMake - Architecture specific conditional compilation

 

Hi, I’m wondering how I would conditionally include files in a project file, based on the architecture i’m building for. What I’d like to do is something like the following:

  1. unix {
  2.   SOURCES += a.cpp
  3.   SOURCES += b.cpp
  4.  
  5.   LIBS += -lfoo
  6.  
  7.   x86 {
  8.      SOURCES += c_x86.cpp
  9.      LIBS  += -lbar
  10.   }
  11.   arm {
  12.      SOURCES += c_arm.cpp
  13.   }
  14. }

6 replies

August 16, 2011

peppe peppe
Ant Farmer
1025 posts

I’d try a scope with something like

  1. contains(QMAKE_TARGET.arch, x86)

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

August 16, 2011

jschmerge jschmerge
Lab Rat
3 posts

Unfortunately, that does not seem to work.

August 16, 2011

Alexandr Ekimov Alexandr Ekimov
Lab Rat
7 posts

  1. CONFIG+= arm11
  2. arm11 {

PS What means arm? arm7, arm9, arm11?

 Signature 

Ekimov Alexander,
http://www.ekimoff.com

August 16, 2011

peppe peppe
Ant Farmer
1025 posts

Wait a minute, are we talking about the architecture you’re (cross) compiling for or the host architecture?

Alexandr Ekimov wrote:
  1. CONFIG+= arm11
  2. arm11 {

PS What means arm? arm7, arm9, arm11?

The name of the specific ARM architecture.

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

August 16, 2011

jschmerge jschmerge
Lab Rat
3 posts

My compilation host will likely always be x86 or x86_64, but I’m working on code that needs to be compiled for both x86 and ARM

August 17, 2011

peppe peppe
Ant Farmer
1025 posts

Ok. What do QMAKE_HOST.arch and QMAKE_TARGET.arch contain for your setup?

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

 
  ‹‹ QtCreator - Need change Release/Debug on all open projects by one click      [Moved] Trouble migrating code from VS2008 to Qt ››

You must log in to post a reply. Not a member yet? Register here!