[Qt-interest] qmake and per-file QMAKE_CXXFLAGS?
Rohan McGovern
rohan.mcgovern at nokia.com
Tue Feb 24 00:07:31 CET 2009
On Tuesday 24 February 2009, ext Dave Thorup wrote:
> I'm wondering if it's possible to define QMAKE_CXXFLAGS flags on
> a per- file basis instead of defining it for the entire project?
>
> For example, say we've got a bunch of .cpp files: foo.cpp,
> bar.cpp and baz.cpp. Then a few of these files contain
> SSE2-optimized code: fooSSE.cpp & barSSE.cpp. Now the problem is
> that I want all the normal files in the project - the ones
> without SSE2 - to be compiled with "QMAKE_CXXFLAGS += -msse".
> But, for all the SSE2 files I want them to be compiled with
> "QMAKE_CXXFLAGS += -msse2".
>
Though not particularly elegant, something like this ought to work.
Only tested on Linux and probably needs per-platform tweaking.
QMAKE_CXXFLAGS += -msse
# 'normal' sources
SOURCES += bar.cpp
# sources to be compiled with -msse2
FAST_SOURCES += foo.cpp
FAST_CXXFLAGS=-msse2
fast.name = Compiling (SSE2)
fast.input = FAST_SOURCES
fast.output = ${QMAKE_FILE_BASE}.o
# Compile FAST_SOURCES as usual but also add FAST_CXXFLAGS
fast.commands = \$(CXX) -c \$(CXXFLAGS) \$(INCPATH) $$FAST_CXXFLAGS -o ${QMAKE_FILE_BASE}.o ${QMAKE_FILE_IN}
QMAKE_EXTRA_COMPILERS += fast
--
Rohan McGovern
Qt Software, Nokia
More information about the Qt-interest-old
mailing list