-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_moc.prf
163 lines (138 loc) · 6.66 KB
/
fix_moc.prf
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# fix_moc.prf
# usage: add "include(fix_moc.prf)" in your .pro file
# This fix allows you to have QObject's of same class name in different
# namespaces, even if they have the same file name in different directories.
# It completes the object_parallel_to_source config option.
# Problem with the default moc rules:
# source/a/Foo.h -> build/moc_Foo.cpp
# source/b/Foo.h -> build/moc_Foo.cpp
# With this fix, you get:
# source/a/Foo.h -> build/a/moc_Foo.cpp
# source/b/Foo.h -> build/b/moc_Foo.cpp
# VERY VERY UGLY HACK
# Fool qmake: make it believe that it has already parsed Qt's moc.prf
# It actually disables the default moc compilers, so that our compilers are
# the only one that will parse the header files. Otherwise, there would be two
# rules for each header file.
QMAKE_INTERNAL_INCLUDED_FEATURES += $$[QT_HOST_DATA/src]/mkspecs/features/moc.prf
# New function to compute the relative path in the build directory
defineReplace(makeMocOutputDir) {
inputAbsolutePath = $$absolute_path($$1, $$OUT_PWD/$$MOC_DIR)
intputAbsoluteDir = $$dirname(inputAbsolutePath)
proAbsoluteDir = $$absolute_path($$_PRO_FILE_PWD_)
proAbsoluteDirEscaped = $$re_escape($$proAbsoluteDir)
strippedInputDir = $$replace(intputAbsoluteDir, $$proAbsoluteDirEscaped,)
absoluteOutputDir = $$OUT_PWD/$$MOC_DIR/$$strippedInputDir
relativeOutputDir = $$relative_path($$absoluteOutputDir, $$OUT_PWD/$$MOC_DIR)
return($$relativeOutputDir)
}
### *-* Copied from Qt BEGIN *-*
#global defaults
qtPrepareTool(QMAKE_MOC, 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
MOC_INCLUDEPATH =
for (inc, INCLUDEPATH): \
MOC_INCLUDEPATH += $$absolute_path($$inc, $$_PRO_FILE_PWD_)
!no_include_pwd:!isEqual(OUT_PWD, $$_PRO_FILE_PWD_): \
MOC_INCLUDEPATH += .
MOC_INCLUDEPATH = $$QMAKESPEC $$_PRO_FILE_PWD_ $$MOC_INCLUDEPATH $$QMAKE_DEFAULT_INCDIRS
# 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
WIN_INCLUDETEMP=
win32:count(MOC_INCLUDEPATH, 40, >) {
WIN_INCLUDETEMP = $$MOC_DIR/mocinclude.opt
WIN_INCLUDETEMP_CONT =
for (inc, MOC_INCLUDEPATH): \
WIN_INCLUDETEMP_CONT += -I$$inc
write_file($$absolute_path($$WIN_INCLUDETEMP, $$OUT_PWD), WIN_INCLUDETEMP_CONT)|error()
}
# QNX's compiler sets "gcc" config, but does not support the -dM option;
# UIKit builds are always multi-arch due to simulator_and_device (unless
# -sdk is used) so this feature cannot possibly work.
if(gcc|intel_icl|msvc):!rim_qcc:!uikit:!no_moc_predefs:if(!macos|count(QMAKE_APPLE_DEVICE_ARCHS, 1)) {
moc_predefs.name = "Generate moc_predefs.h"
moc_predefs.CONFIG = no_link
gcc: moc_predefs.commands = $$QMAKE_CXX $$QMAKE_CXXFLAGS -dM -E -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
else:intel_icl: moc_predefs.commands = $$QMAKE_CXX $$QMAKE_CXXFLAGS -QdM -P -Fi${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
else:msvc {
moc_predefs.commands += $$QMAKE_CXX -Bx$$shell_quote($$shell_path($$QMAKE_QMAKE)) $$QMAKE_CXXFLAGS \
-E ${QMAKE_FILE_IN} 2>NUL >${QMAKE_FILE_OUT}
} else: error("Oops, I messed up")
moc_predefs.output = $$MOC_DIR/moc_predefs.h
moc_predefs.input = MOC_PREDEF_FILE
silent: moc_predefs.commands = @echo generating $$moc_predefs.output$$escape_expand(\\n\\t)@$$moc_predefs.commands
QMAKE_EXTRA_COMPILERS += moc_predefs
MOC_PREDEF_FILE = $$[QT_HOST_DATA/src]/mkspecs/features/data/dummy.cpp
}
defineReplace(mocCmdBase) {
!isEmpty(WIN_INCLUDETEMP) {
incvar = @$$shell_quote($$WIN_INCLUDETEMP)
} else {
incvar =
for (inc, MOC_INCLUDEPATH): \
incvar += -I$$shell_quote($$inc)
incvar += $$QMAKE_FRAMEWORKPATH_FLAGS
}
RET = $$QMAKE_MOC $(DEFINES)
msvc: RET += --compiler-flavor=msvc
isEmpty(MOC_PREDEF_FILE): RET += $$join(QMAKE_COMPILER_DEFINES, " -D", -D)
else: RET += --include $$shell_quote($$absolute_path($$moc_predefs.output, $$OUT_PWD))
RET += $$incvar $$QMAKE_MOC_OPTIONS
return($$RET)
}
### *-* Copied from Qt END *-*
#moc headers
moc_header.CONFIG = moc_verify
moc_header.dependency_type = TYPE_C
moc_header.commands = ${QMAKE_FUNC_mocCmdBase} ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
moc_header.output = ${QMAKE_FUNC_makeMocOutputDir}/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_CPP)}
moc_header.input = HEADERS
moc_header.variable_out = SOURCES
moc_header.name = MOC ${QMAKE_FILE_IN}
moc_header.depends += $$WIN_INCLUDETEMP $$moc_predefs.output
silent:moc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_header.commands
QMAKE_EXTRA_COMPILERS += moc_header
INCREDIBUILD_XGE += moc_header
#moc objc headers
moc_objc_header.CONFIG = moc_verify
moc_objc_header.dependency_type = TYPE_C
moc_objc_header.commands = ${QMAKE_FUNC_mocCmdBase} ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
moc_objc_header.output = ${QMAKE_FUNC_makeMocOutputDir}/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_OBJCXX)}
moc_objc_header.input = OBJECTIVE_HEADERS
moc_objc_header.variable_out = SOURCES
moc_objc_header.name = MOC ${QMAKE_FILE_IN}
moc_objc_header.depends += $$WIN_INCLUDETEMP $$moc_predefs.output
silent:moc_objc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_objc_header.commands
QMAKE_EXTRA_COMPILERS += moc_objc_header
INCREDIBUILD_XGE += moc_objc_header
#moc sources
moc_source.CONFIG = no_link moc_verify
moc_source.dependency_type = TYPE_C
moc_source.commands = ${QMAKE_FUNC_mocCmdBase} ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
moc_source.output = ${QMAKE_FUNC_makeMocOutputDir}/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_IN_BASE}$${QMAKE_EXT_CPP_MOC}
moc_source.input = SOURCES
moc_source.name = MOC ${QMAKE_FILE_IN}
moc_source.depends += $$WIN_INCLUDETEMP $$moc_predefs.output
silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands
QMAKE_EXTRA_COMPILERS += moc_source
INCREDIBUILD_XGE += moc_source
### *-* Copied from Qt BEGIN *-*
#make sure we can include these files
INCLUDEPATH += $$absolute_path($$MOC_DIR, $$OUT_PWD)
#auto depend on moc
!no_mocdepend {
moc_source.depends += $$QMAKE_MOC_EXE
moc_header.depends += $$QMAKE_MOC_EXE
moc_objc_header.depends += $$QMAKE_MOC_EXE
}
#generate a mocclean
build_pass|isEmpty(BUILDS):mocclean.depends = compiler_moc_header_clean compiler_moc_objc_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_objc_header_make_all compiler_moc_source_make_all
else:mocables.CONFIG += recursive
QMAKE_EXTRA_TARGETS += mocables
### *-* Copied from Qt END *-*