summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/qt_module_config.prf
blob: d53862969d20d79dc6e0b984f6a88aa197b14a49 (plain)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
!no_qt_module_warning:!contains(QMAKE_INTERNAL_INCLUDED_FILES, .*qmodule\\.pri) {
    QMAKE_ACTUAL_PRO_FILE = $$basename(_PRO_FILE_)
    isEmpty(QMAKE_ACTUAL_PRO_FILE): QMAKE_ACTUAL_PRO_FILE=.pro
    warning("You should probably load(qt_build_config) first in $$QMAKE_ACTUAL_PRO_FILE for $$TARGET, as it also load()s qt_module_config.")
    message("Not doing so may lead to qt_module_config.prf overriding compiler/linker options in your .pro file.")
    message("Ignore this warning with CONFIG+=no_qt_module_warning if you know what you are doing.")
    unset(QMAKE_ACTUAL_PRO_FILE)
}
load(qt_build_config) # loads qmodule.pri if hasn't been loaded already

isEmpty(MODULE):MODULE = $$section($$list($$basename(_PRO_FILE_)), ., 0, 0)
isEmpty(TARGET):error("You must set TARGET before include()'ing $${_FILE_}")
isEmpty(VERSION):VERSION = $$QT_VERSION

ucmodule = $$upper($$MODULE)

MODULE_DEPENDS = $$replace(QT, -private$, )

# Find the module's source root dir.
MODULE_PROFILE_DIR = $$_PRO_FILE_PWD_
for(ever) {
    exists($$MODULE_PROFILE_DIR/sync.profile):break()
    nmpri = $$dirname(MODULE_PROFILE_DIR)
    equals(nmpri, $$MODULE_PROFILE_DIR):error("No sync.profile found. This does not look like a Qt module source tree.")
    MODULE_PROFILE_DIR = $$nmpri
    unset(nmpri)
}

isEmpty(MODULE_BASE_DIR): MODULE_BASE_DIR = $$MODULE_PROFILE_DIR
MODULE_BASE_OUTDIR = $$shadowed($$MODULE_BASE_DIR)
isEmpty(MODULE_QMAKE_OUTDIR): MODULE_QMAKE_OUTDIR = $$MODULE_BASE_OUTDIR

# This check will be removed soon. Weird indentation to avoid reindenting the code later.
!isEmpty(MODULE_PRI) {
    !build_pass:warning("$$_PRO_FILE_ still sets MODULE_PRI. Not auto-generating module .pri file.")
    MODULE_PRI = $$absolute_path($$MODULE_PRI, $$_PRO_FILE_PWD_)
    exists($$MODULE_PRI)|error("Specified module pri file $$MODULE_PRI does not exist.")
} else {

MODULE_PRI = $$MODULE_QMAKE_OUTDIR/mkspecs/modules-inst/qt_$${MODULE}.pri

!build_pass {

    # Create a module .pri file
    !isEmpty(QT_PRIVATE) {
        contains(QT_PRIVATE, .*-private$):error("QT_PRIVATE may not contain *-private.")
        module_privdep = "QT.$${MODULE}.private_depends = $$QT_PRIVATE"
    } else {
        module_privdep =
    }
    staticlib: \
        module_build_type = "QT.$${MODULE}.module_config = staticlib"
    else:mac:!static:contains(QT_CONFIG, qt_framework): \
        module_build_type = "QT.$${MODULE}.module_config = lib_bundle"
    else: \
        module_build_type =
    !isEmpty(MODULE_CONFIG): \
        module_config = "QT.$${MODULE}.CONFIG = $$MODULE_CONFIG"
    else: \
        module_config =
    contains(TARGET, QtAddOn.*): \
        MODULE_DEFINE = QT_ADDON_$${ucmodule}_LIB
    else: \
        MODULE_DEFINE = QT_$${ucmodule}_LIB
    MODULE_DEFINES = $$MODULE_DEFINE $$MODULE_DEFINES
    MODULE_PRI_CONT = \
        "QT.$${MODULE}.VERSION = $${VERSION}" \
        "QT.$${MODULE}.MAJOR_VERSION = $$section(VERSION, ., 0, 0)" \
        "QT.$${MODULE}.MINOR_VERSION = $$section(VERSION, ., 1, 1)" \
        "QT.$${MODULE}.PATCH_VERSION = $$section(VERSION, ., 2, 2)" \
        "" \
        "QT.$${MODULE}.name = $$TARGET" \
        "QT.$${MODULE}.bins = \$\$QT_MODULE_BIN_BASE" \
        "QT.$${MODULE}.includes = \$\$QT_MODULE_INCLUDE_BASE \$\$QT_MODULE_INCLUDE_BASE/$$TARGET" \
        "QT.$${MODULE}.private_includes = \$\$QT_MODULE_INCLUDE_BASE/$$TARGET/\$\$QT.$${MODULE}.VERSION" \
        "QT.$${MODULE}.sources = $$val_escape(_PRO_FILE_PWD_)" \
        "QT.$${MODULE}.libs = \$\$QT_MODULE_LIB_BASE" \
        "QT.$${MODULE}.plugins = \$\$QT_MODULE_PLUGIN_BASE" \
        "QT.$${MODULE}.imports = \$\$QT_MODULE_IMPORT_BASE" \
        "QT.$${MODULE}.depends =$$join(MODULE_DEPENDS, " ", " ")" \
        $$module_privdep \
        $$module_build_type \
        $$module_config \
        "QT.$${MODULE}.DEFINES = $$MODULE_DEFINES" \ # assume sufficient quoting
        "" \
        "QT_CONFIG += $$MODULE" # this is obsolete, but some code still depends on it
    write_file($$MODULE_PRI, MODULE_PRI_CONT)|error("Aborting.")

} # !build_pass

} # isEmpty(MODULE_PRI)

load(qt_module_fwdpri)

MODULE_INCLUDES = $$eval(QT.$${MODULE}.includes)
MODULE_PRIVATE_INCLUDES = $$eval(QT.$${MODULE}.private_includes)
INCLUDEPATH *= $$MODULE_INCLUDES
INCLUDEPATH *= $$MODULE_PRIVATE_INCLUDES
INCLUDEPATH *= $$MODULE_PRIVATE_INCLUDES/$$TARGET

load(qt_module_headers)

#other
TEMPLATE         = lib
DESTDIR          = $$eval(QT.$${MODULE}.libs)
win32:!wince*:DLLDESTDIR = $$[QT_INSTALL_PREFIX]/bin

CONFIG          += qt warn_on depend_includepath
CONFIG          += qmake_cache target_qt
CONFIG          -= fix_output_dirs

# If Qt was configured with -debug-and-release then build the module the same way
if(win32|mac):!wince*:!macx-xcode {
    contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
    contains(QT_CONFIG, build_all):CONFIG += build_all
}

linux*:QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF

QT += $$QT_PRIVATE
unset(QT_PRIVATE)

!isEmpty(DESTDIR):CONFIG += create_cmake

contains(TARGET, QtAddOn.*): \
    DEFINES += QT_BUILD_ADDON_$${ucmodule}_LIB
else: \
    DEFINES += QT_BUILD_$${ucmodule}_LIB

contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
contains(QT_CONFIG, largefile):CONFIG += largefile
contains(QT_CONFIG, separate_debug_info):CONFIG += separate_debug_info
contains(QT_CONFIG, separate_debug_info_nocopy):CONFIG += separate_debug_info_nocopy
contains(QT_CONFIG, c++11):CONFIG += c++11

#mac frameworks
mac:!static:contains(QT_CONFIG, qt_framework) {
   #QMAKE_FRAMEWORK_VERSION = 4.0
   CONFIG += lib_bundle qt_no_framework_direct_includes qt_framework
   CONFIG(release, debug|release) {
      !debug_and_release|build_pass {
          CONFIG -= qt_install_headers #no need to install these as well
          FRAMEWORK_HEADERS.version = Versions
          FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES
          FRAMEWORK_HEADERS.path = Headers
      }
      QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
   }
}

mac {
   CONFIG += explicitlib
   macx-g++ {
       QMAKE_CFLAGS += -fconstant-cfstrings
       QMAKE_CXXFLAGS += -fconstant-cfstrings
   }
}

win32:!shared:CONFIG += static

win32-borland {
    # Keep the size of the .tds file for the Qt library smaller than
    # 34 Mbytes to avoid linking problems
    QMAKE_CFLAGS_DEBUG += -vi -y-
    QMAKE_CXXFLAGS_DEBUG += -vi -y-
}

win32 {
    INCLUDEPATH += tmp
    !static: DEFINES+=QT_MAKEDLL
}
win32-borland:INCLUDEPATH += kernel

aix-g++* {
     QMAKE_CFLAGS   += -mminimal-toc
     QMAKE_CXXFLAGS += -mminimal-toc
}

!static:PRL_EXPORT_DEFINES += QT_SHARED

#install directives
load(qt_installs)

unix|win32-g++* {
   CONFIG += create_pc
   QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS/raw]
   QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS/raw]/$$TARGET
   QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS/raw]
   QMAKE_PKGCONFIG_DESTDIR = pkgconfig
   include_replace.match = $$[QT_INSTALL_HEADERS/get]
   include_replace.replace = $$[QT_INSTALL_HEADERS/raw]
   lib_replace.match = $$[QT_INSTALL_LIBS/get]
   lib_replace.replace = $$[QT_INSTALL_LIBS/raw]
   prefix_replace.match = $$QT_BUILD_TREE
   prefix_replace.replace = $$[QT_INSTALL_PREFIX/raw]
   QMAKE_PKGCONFIG_INSTALL_REPLACE += include_replace lib_replace prefix_replace
}

unix {
   CONFIG += create_libtool explicitlib
   QMAKE_PRL_LIBDIR = $$[QT_INSTALL_LIBS/raw] ### XXX
   QMAKE_PRL_INSTALL_REPLACE += include_replace lib_replace
   QMAKE_LIBTOOL_LIBDIR = $$[QT_INSTALL_LIBS/raw]
   QMAKE_LIBTOOL_INSTALL_REPLACE += include_replace lib_replace
}

unix|win32-g++* {
    for(i, QT):QMAKE_PKGCONFIG_REQUIRES += $$eval(QT.$${i}.name)
    isEmpty(QMAKE_PKGCONFIG_DESCRIPTION): \
        QMAKE_PKGCONFIG_DESCRIPTION = $$replace(TARGET, ^Qt, "Qt ") module
}

contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE
DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS
DEFINES *= QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code
DEFINES *= QT_USE_QSTRINGBUILDER
DEFINES *= QT_DEPRECATED_WARNINGS

TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end

load(qt_targets)

win32:DEFINES+=_USE_MATH_DEFINES