1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#global defaults
isEmpty(QMAKE_MOC) {
win32:QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe
else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
}
isEmpty(MOC_DIR):MOC_DIR = .
isEmpty(QMAKE_H_MOD_MOC):QMAKE_H_MOD_MOC = moc_
isEmpty(QMAKE_EXT_CPP_MOC):QMAKE_EXT_CPP_MOC = .moc
# On Windows, put the includes into a .inc file which moc will read, if the project
# has too many includes. We do this to overcome a command-line limit on Win < XP
INCLUDETEMP=
win32:count($$list($$INCPATH), 40, >) {
INCLUDETEMP = mocinclude.tmp
# Remove any existing mocinclude.tmp when qmake runs
WIN_OUT_PWD=$$OUT_PWD
WIN_OUT_PWD~=s,/,\,g
system($$QMAKE_DEL_FILE $$WIN_OUT_PWD\\$$INCLUDETEMP > NUL 2>&1)
EOC = $$escape_expand(\n\t)
if(contains(TEMPLATE, "vc.*")|contains(TEMPLATE_PREFIX, "vc")) {
# the VCPROJ generator will replace the \r\h with the coded \r\n: 

# No other generator understands the \h
if(win32-msvc.net|win32-msvc2*|wince*msvc*): EOC = $$escape_expand(\r\h)
else: EOC = $$escape_expand(\\)$$escape_expand(\n\t)
}
unset(INCFILELIST)
RET =
for(incfile, $$list($$INCPATH)) {
INCFILELIST = -I$$incfile
isEmpty(RET): RET += @echo $$INCFILELIST> $$INCLUDETEMP $$EOC
else: RET += @echo $$INCFILELIST>> $$INCLUDETEMP $$EOC
}
!isEmpty(INCFILELIST):RET += @echo $$INCFILELIST>> $$INCLUDETEMP $$EOC
build_pass|isEmpty(BUILDS) {
mocinclude.target = $$INCLUDETEMP
mocinclude.commands = $$RET
QMAKE_EXTRA_TARGETS += mocinclude
}
}
defineReplace(mocCmd) {
!isEmpty(INCLUDETEMP) {
return($$QMAKE_MOC $(DEFINES) @$$INCLUDETEMP $$join(QMAKE_COMPILER_DEFINES, " -D", -D) $$1 -o $$2)
}
return($$QMAKE_MOC $(DEFINES) $(INCPATH) $$join(QMAKE_COMPILER_DEFINES, " -D", -D) $$1 -o $$2)
}
#moc headers
moc_header.CONFIG = moc_verify
moc_header.dependency_type = TYPE_C
moc_header.commands = ${QMAKE_FUNC_mocCmd}
moc_header.output = $$MOC_DIR/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_CPP)}
moc_header.input = HEADERS
moc_header.variable_out = SOURCES
moc_header.name = MOC ${QMAKE_FILE_IN}
!isEmpty(INCLUDETEMP):moc_header.depends += $$INCLUDETEMP
silent:moc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_header.commands
QMAKE_EXTRA_COMPILERS += moc_header
INCREDIBUILD_XGE += moc_header
#moc sources
moc_source.CONFIG = no_link moc_verify
moc_source.dependency_type = TYPE_C
moc_source.commands = ${QMAKE_FUNC_mocCmd}
moc_source.output = $$MOC_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_EXT_CPP_MOC}
moc_source.input = SOURCES OBJECTIVE_SOURCES
moc_source.name = MOC ${QMAKE_FILE_IN}
!isEmpty(INCLUDETEMP):moc_source.depends += $$INCLUDETEMP
silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands
QMAKE_EXTRA_COMPILERS += moc_source
INCREDIBUILD_XGE += moc_source
#make sure we can include these files
moc_dir_short = $$MOC_DIR
win32:moc_dir_short ~= s,^.:,/,
contains(moc_dir_short, ^[/\\\\].*):INCLUDEPATH += $$MOC_DIR
else:INCLUDEPATH += $$OUT_PWD/$$MOC_DIR
# Backwards compatibility: Make shadow builds with default MOC_DIR work
# if the user did not add the source dir explicitly.
equals(MOC_DIR, .) {
CONFIG -= include_source_dir
CONFIG = include_source_dir $$CONFIG
}
#auto depend on moc
unix:!no_mocdepend {
moc_source.depends += $$first(QMAKE_MOC)
moc_header.depends += $$first(QMAKE_MOC)
!contains(TARGET, moc) { #auto build moc
isEmpty(QMAKE_MOC_SRC):QMAKE_MOC_SRC = "$(QTDIR)/src/tools/moc"
make_moc.target = $$first(QMAKE_MOC)
make_moc.commands = (cd $$QMAKE_MOC_SRC && $(MAKE))
QMAKE_EXTRA_TARGETS += make_moc
}
}
#generate a mocclean
build_pass|isEmpty(BUILDS):mocclean.depends = compiler_moc_header_clean compiler_moc_source_clean
else:mocclean.CONFIG += recursive
QMAKE_EXTRA_TARGETS += mocclean
#generate a mocables
build_pass|isEmpty(BUILDS):mocables.depends = compiler_moc_header_make_all compiler_moc_source_make_all
else:mocables.CONFIG += recursive
QMAKE_EXTRA_TARGETS += mocables
|