[Interest] [OS X] How to enable ARC for *.mm files (which qmake var)?

Till Oliver Knoll till.oliver.knoll at gmail.com
Fri Jan 17 00:07:07 CET 2014


Hi,

I want to enable ARC (Automatic Reference Counting) for my Objective-C++
sources (*.mm).

With which qmake variable do I set an additional compiler flag such as
"-fobjc-arc" such that it takes effect when compiling Objective-C++
source files (*.mm)?

I tried

  QMAKE_CXXFLAGS += -fobjc-arc
  QMAKE_CFLAGS_DEBUG += -fobjc-arc
  QMAKE_CFLAGS_RELEASE += -fobjc-arc

but the flag is only applied when clang++ is executed when compiling the
*.cpp C++ sources, but not when clang is executed, compiling my *.mm files.


E.g.

  SOURCES += foo.cpp
  OBJECTIVE_SOURCES += bar.mm

with the above CXX and C flags results in

/Applications/Xcode.app/.../bin/clang -c -pipe -g -gdwarf-2 ... bar.mm
/Applications/Xcode.app/.../bin/clang++ -c -pipe -fobjc-arc -g -gdwarf-2
... foo.cpp

That is, the expected -fobjc-arc flag is only applied for clang++.


So which other QMAKE_WHATEVERFLAGS variable would be the one for clang?
Doh... sorry for the stupid question, the answer must be right in front
of my eyes...


OS X 10.8 with Qt 5.2.0 (QMake version 3.0)


Cheers, Oliver



More information about the Interest mailing list