summaryrefslogtreecommitdiff
path: root/mkspecs/features/qt_module.prf
blob: 36f632e8caa65a7ea98fd94483d5310061e45466 (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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#
#  W A R N I N G
#  -------------
#
# This file is not part of the Qt API.  It exists purely as an
# implementation detail.  It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#

isEmpty(MODULE):MODULE = $$section($$list($$basename(_PRO_FILE_)), ., 0, 0)
isEmpty(VERSION): VERSION = $$MODULE_VERSION
isEmpty(VERSION): error("Module does not define version.")

exists($$OUT_PWD/qt$${MODULE}-config.pri) {
    include($$OUT_PWD/qt$${MODULE}-config.pri)
    CONFIG += generated_privates
}

skip = $$eval(QT.$${MODULE}.skip)
isEmpty(skip): skip = false
requires(!$$skip)

# Compile as shared/DLL or static according to the option given to configure
# unless overridden. Host builds are always static
host_build|staticlib: CONFIG += static

host_build {
    QT -= gui   # no host module will ever use gui
    QMAKE_CFLAGS += $$QMAKE_CFLAGS_SPLIT_SECTIONS
    QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_SPLIT_SECTIONS
    force_bootstrap {
        !build_pass:qtConfig(release_tools): CONFIG += release
        contains(QT, core(-private)?|xml) {
            QT -= core core-private xml
            QT += bootstrap-private
        }
    } else {
        !build_pass:qtConfig(debug_and_release): CONFIG += release
    }
}

qtConfig(framework) {
    minimal_syncqt: \
        CONFIG += module_frameworks
    else: CONFIG(shared, static|shared): \
        CONFIG += module_frameworks lib_bundle
}

CONFIG += relative_qt_rpath  # Qt libraries should be relocatable

# Qt libraries should only use Application Extension safe APIs
darwin:!no_app_extension_api_only: CONFIG += app_extension_api_only

ucmodule = $$upper($$MODULE)

isEmpty(MODULE_INCNAME): MODULE_INCNAME = $$TARGET

internal_module: \
    MODULE_DEPENDS = $$replace(QT, -private$, _private)
else: \
    MODULE_DEPENDS = $$replace(QT, -private$, )
MODULE_DEPENDS = $$unique(MODULE_DEPENDS)
contains(MODULE_DEPENDS, $$MODULE): \
    error("$$TARGET depends on itself.")

contains(TARGET, QtAddOn.*): \
    MODULE_DEFINE = QT_ADDON_$${ucmodule}_LIB
else: \
    MODULE_DEFINE = QT_$${ucmodule}_LIB
MODULE_DEFINES = $$MODULE_DEFINE $$MODULE_DEFINES

# Make sure that the supporting runtime is linked into the application when
# the module is built with exceptions enabled.
integrity:CONFIG(exceptions, exceptions|exceptions_off): \
    MODULE_CONFIG += exceptions

load(qt_build_paths)

header_module {
    TEMPLATE     = aux
    CONFIG      += force_qt  # Needed for the headers_clean tests.
    !lib_bundle: \
        CONFIG  += qt_no_install_library
} else {
    TEMPLATE     = lib
}
DESTDIR          = $$MODULE_BASE_OUTDIR/lib
DLLDESTDIR       = $$MODULE_BASE_OUTDIR/bin

CONFIG          += qmake_cache target_qt

QMAKE_DOCS_TARGETDIR = qt$${MODULE}

load(qt_common)
!no_module_headers: load(qt_module_headers)
load(qt_module_pris)

INCLUDEPATH *= $$eval(QT.$${MODULE}.includes) $$eval(QT.$${MODULE}_private.includes)

# If Qt was configured with -debug-and-release then build the module the same way
# - unless this is a host library
!host_build:if(win32|mac):!macx-xcode {
    qtConfig(debug_and_release): CONFIG += debug_and_release
    qtConfig(build_all): CONFIG += build_all
}

QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF

QT_PRIVATE += $$QT_FOR_PRIVATE
unset(QT_FOR_PRIVATE)
QMAKE_USE_PRIVATE += $$QMAKE_USE_FOR_PRIVATE
unset(QMAKE_USE_FOR_PRIVATE)

!internal_module:CONFIG += create_cmake

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

# OS X and iOS frameworks
lib_bundle {
   # Set the CFBundleIdentifier prefix for Qt frameworks
   QMAKE_TARGET_BUNDLE_PREFIX = org.qt-project
   #QMAKE_FRAMEWORK_VERSION = 4.0
   CONFIG += sliced_bundle
   header_module {
        CONFIG += bundle
        QMAKE_BUNDLE_NAME = $$TARGET
        QMAKE_BUNDLE_EXTENSION = .framework
        QMAKE_INFO_PLIST = $$QMAKESPEC/Info.plist.lib
   }
   !build_all| \
           if(if(!debug_and_release|CONFIG(release, debug|release))) {
        FRAMEWORK_HEADERS.version = Versions
        FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES
        FRAMEWORK_HEADERS.path = Headers
        FRAMEWORK_PRIVATE_HEADERS.version = Versions
        FRAMEWORK_PRIVATE_HEADERS.files = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.INJECTED_PRIVATE_HEADER_FILES
        FRAMEWORK_PRIVATE_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/private
        FRAMEWORK_QPA_HEADERS.version = Versions
        FRAMEWORK_QPA_HEADERS.files = $$SYNCQT.QPA_HEADER_FILES
        FRAMEWORK_QPA_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/qpa
        QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS FRAMEWORK_PRIVATE_HEADERS FRAMEWORK_QPA_HEADERS
   }
}

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

   qtConfig(rpath): \
       QMAKE_SONAME_PREFIX = @rpath
   else: \
       CONFIG += absolute_library_soname
}

DEFINES += QT_BUILDING_QT
win32 {
    INCLUDEPATH += tmp
    CONFIG += skip_target_version_ext
    # If the code is really "unsafe" then it is unsafe on
    # other platforms as well; so fixing these warnings just
    # for MSVC builds, would clutter the code and wouldn't help
    # in fixing issues that might exist on other platforms.
    # Using the same functions across all supported platforms
    # keeps the code clean and helps in writing code that is
    # safe across all platforms.
    DEFINES *= _CRT_SECURE_NO_WARNINGS

    DEFINES += _USE_MATH_DEFINES
}

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

sse2:!contains(QT_CPU_FEATURES.$$QT_ARCH, sse2):!host_build:!if(static:qtConfig(shared)) {
    # If the compiler supports SSE2, enable it unconditionally in all of Qt shared libraries
    # (and only the libraries). This is not expected to be a problem because:
    # - on Windows, sharing of libraries is uncommon
    # - on Mac OS X, all x86 CPUs already have SSE2 support (we won't even reach here)
    # - on Linux, the dynamic loader can find the libraries on LIBDIR/sse2/
    # The last guarantee does not apply to executables and plugins, so we can't enable for them.
    QT_CPU_FEATURES.$$QT_ARCH += sse sse2
    QMAKE_CFLAGS += $$QMAKE_CFLAGS_SSE2
    QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE2
}

clang {
    apple_clang_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}
    reg_clang_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}
    !lessThan(apple_clang_ver, "5.1")|!lessThan(reg_clang_ver, "3.4"): \
        CONFIG += compiler_supports_fpmath
} else: gcc {
    CONFIG += compiler_supports_fpmath
}

equals(QT_ARCH, i386):contains(QT_CPU_FEATURES.$$QT_ARCH, sse2):compiler_supports_fpmath {
    # Turn on SSE-based floating-point math
    QMAKE_CFLAGS += -mfpmath=sse
    QMAKE_CXXFLAGS += -mfpmath=sse
}

android: CONFIG += qt_android_deps no_linker_version_script

!header_module:unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!no_linker_version_script:!static {
    verscript = $${TARGET}.version
    QMAKE_LFLAGS += $${QMAKE_LFLAGS_VERSION_SCRIPT}$$verscript

    internal_module {
        verscript_content = "Qt_$${QT_MAJOR_VERSION}_PRIVATE_API { *; };"
    } else {
        verscript_content = "Qt_$${QT_MAJOR_VERSION}_PRIVATE_API {" \
                            "    qt_private_api_tag*;"

        private_api_headers = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.QPA_HEADER_FILES

        for(header, private_api_headers): \
            verscript_content += "    @FILE:$${_PRO_FILE_PWD_}/$$header@"
        verscript_content += "};"

        current = Qt_$$QT_MAJOR_VERSION
        verscript_content += "$$current { *; };"
        isEmpty(QT_NAMESPACE): tag_symbol = qt_version_tag
        else:                  tag_symbol = qt_version_tag_$$QT_NAMESPACE

        for(i, 0..$$QT_MINOR_VERSION) {
            previous = $$current
            current = Qt_$${QT_MAJOR_VERSION}.$$i
            equals(i, $$QT_MINOR_VERSION): verscript_content += "$$current { $$tag_symbol; } $$previous;"
            else:                          verscript_content += "$$current {} $$previous;"
        }

        # Add a post-processing step to replace the @FILE:filename@
        verscript_in = $${verscript}.in
        verscriptprocess.name = linker version script ${QMAKE_FILE_BASE}
        verscriptprocess.input = verscript_in
        verscriptprocess.CONFIG += no_link target_predeps
        for(header, private_api_headers): \
            verscriptprocess.depends += $${_PRO_FILE_PWD_}/$$header
        verscriptprocess.output = $$verscript
        verscriptprocess.commands = perl $${PWD}/data/unix/findclasslist.pl < ${QMAKE_FILE_IN} > $@
        silent:verscriptprocess.commands = @echo creating linker version script ${QMAKE_FILE_BASE} && $$verscriptprocess.commands
        QMAKE_EXTRA_COMPILERS += verscriptprocess

        verscript = $$verscript_in
    }
    write_file($$OUT_PWD/$$verscript, verscript_content)|error()
    unset(current)
    unset(previous)
    unset(verscript)
    unset(verscript_content)
}

#install directives
load(qt_installs)

load(qt_targets)

# this builds on top of qt_common
!internal_module:!lib_bundle:if(unix|mingw) {
    CONFIG += create_pc
    QMAKE_PKGCONFIG_DESTDIR = pkgconfig
    host_build: \
        QMAKE_PKGCONFIG_LIBDIR = $$[QT_HOST_LIBS]
    else: \
        QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS/raw]
    QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS/raw]
    QMAKE_PKGCONFIG_CFLAGS = -I${includedir}/$$MODULE_INCNAME
    QMAKE_PKGCONFIG_NAME = $$replace(TARGET, ^Qt, "Qt$$QT_MAJOR_VERSION ")
    QMAKE_PKGCONFIG_FILE = $$replace(TARGET, ^Qt, Qt$$QT_MAJOR_VERSION)
    for(i, MODULE_DEPENDS): \
        QMAKE_PKGCONFIG_REQUIRES += $$replace(QT.$${i}.name, ^Qt, Qt$$section(QT.$${i}.VERSION, ., 0, 0))
    isEmpty(QMAKE_PKGCONFIG_DESCRIPTION): \
        QMAKE_PKGCONFIG_DESCRIPTION = $$replace(TARGET, ^Qt, "Qt ") module
    pclib_replace.match = $$lib_replace.match
    !isEmpty(lib_replace.replace): \
        pclib_replace.replace = $$QMAKE_PKGCONFIG_LIBDIR
    pclib_replace.CONFIG = path
    QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace
}
!lib_bundle:unix {
    CONFIG += create_libtool
    host_build: \
        QMAKE_LIBTOOL_LIBDIR = $$[QT_HOST_LIBS]
    else: \
        QMAKE_LIBTOOL_LIBDIR = "=$$[QT_INSTALL_LIBS/raw]"
    ltlib_replace.match = $$lib_replace.match
    !isEmpty(lib_replace.replace): \
        ltlib_replace.replace = $$QMAKE_LIBTOOL_LIBDIR
    ltlib_replace.CONFIG = path
    QMAKE_LIBTOOL_INSTALL_REPLACE += ltlib_replace
}

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

win32 {
    # On Windows, due to the way DLLs work, we need to export all functions,
    # including the inlines
    DEFINES *= QT_DISABLE_DEPRECATED_BEFORE=0x040800
} else {
    # On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
    DEFINES *= QT_DISABLE_DEPRECATED_BEFORE=0x050000
}

TARGET = $$qt5LibraryTarget($$TARGET$$QT_LIBINFIX)  # Do this towards the end