[Qt-interest] Qt 4.4, Snow Leopard & QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS
Dave Thorup
lists at kuwan.net
Thu Sep 3 22:46:03 CEST 2009
Does anyone know where QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS get defined?
I greped through the entire Qt 4.4.3 source tree and couldn't find a
definition anywhere. Although it appears in many of the Makefiles
that are created when building Qt from source I can't seem to find
where it's actually defined. The best I can find is in qt-mac-
commercial-src-4.4.3/mkspecs/features/mac/objective_c.prf:
-----------------------------------------
isEmpty(QMAKE_OBJECTIVE_CC):QMAKE_OBJECTIVE_CC = $$QMAKE_CC
isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap
QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS
QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
QMAKE_OBJECTIVE_CFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
QMAKE_OBJECTIVE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
QMAKE_OBJECTIVE_CFLAGS_X86 = $$QMAKE_CFLAGS_X86
QMAKE_OBJECTIVE_CFLAGS_PPC = $$QMAKE_CFLAGS_PPC
QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS
}
OBJECTIVE_C_OBJECTS_DIR = $$OBJECTS_DIR
isEmpty(OBJECTIVE_C_OBJECTS_DIR):OBJECTIVE_C_OBJECTS_DIR = .
isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .mm .m
objective_c.dependency_type = TYPE_C
objective_c.variables = QMAKE_OBJECTIVE_CFLAGS
objective_c.commands = $$QMAKE_OBJECTIVE_CC -c $
(QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS) $(DEFINES) $(INCPATH) $
{QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
objective_c.output = $$OBJECTIVE_C_OBJECTS_DIR/${QMAKE_FILE_BASE}$$
{first(QMAKE_EXT_OBJ)}
objective_c.input = OBJECTIVE_SOURCES
objective_c.name = Compile ${QMAKE_FILE_IN}
silent:objective_c.commands = @echo objective-c ${QMAKE_FILE_IN} && $
$objective_c.commands
QMAKE_EXTRA_COMPILERS += objective_c
-----------------------------------------
It is used here and there's a definition for QMAKE_OBJECTIVE_CFLAGS
but no definition for QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS.
The problem is that Snow Leopard (Mac OS X 10.6) changes the default
gcc version to be 4.2, but you can't use gcc 4.2 to build applications
that target Mac OS X 10.4. So when building Qt 4.4.3 under Snow
Leopard I can set the CC & CXX environment variables to gcc-4.0 & g+
+-4.0 respectively and this lets me build Qt with gcc 4.0. I also
need to set the Mac SDK to 10.4 to properly target it. Here is my Qt
configure command:
./configure -nomake demos -nomake examples -dwarf2 -sdk /Developer/
SDKs/MacOSX10.4u.sdk -universal -no-webkit -no-phonon -no-dbus
This properly sets the SDK when compiling C & C++ files, however there
are a few Objective-C++ files that are compiled by Qt and it appears
that the SDK is not set at all when building these files. For example
in qt-mac-commercial-src-4.4.3/src/gui/Makefile.Debug:1175 we have the
following:
gcc-4.0 -c $(QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS) $(DEFINES) $(INCPATH)
kernel/qcursor_mac.mm -o .obj/debug-shared/qcursor_mac.o
QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS is defined on line 879 as follows:
####### Custom Compiler Variables
QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS = -pipe \
-fconstant-cfstrings \
-g \
-gdwarf-2 \
-fvisibility=hidden \
-fvisibility-inlines-hidden \
-Wall \
-W \
-arch \
ppc \
-arch \
i386
You'll note that there is no SDK specified in
QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS. This causes compile errors when
building Qt on 10.6 because it appears that some of the 10.6 System
Headers require gcc 4.2 and won't work with gcc 4.0. The SDK is
properly used when building C & C++ files as these commands use the
CFLAGS & CXXFLAGS respectively which are defined at the top of the
file and include "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" in each
of them to properly specify the 10.4 SDK.
I was able to get around this issue by manually adding the 10.4 SDK to
the QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS definition in the few Makefiles
that actually build Objective-C++ sources. However I'd like to figure
out how to fix it properly so that there will be less hassle when I
need to build Qt 4.4.3 in the future on a different Snow Leopard
machine. Does anyone know where I could make a fix such that the SDK
is properly specified when Qt compiles Objective-C++ files?
Thanks for any help.
--
Dave Thorup
Software Engineer
http://bibblelabs.com
More information about the Qt-interest-old
mailing list