1#
2#  W A R N I N G
3#  -------------
4#
5# This file is not part of the Qt API.  It exists purely as an
6# implementation detail.  It may change from version to version
7# without notice, or even be removed.
8#
9# We mean it.
10#
11
12load(cmake_functions)
13
14# Several distros (ArchLinux, Fedora) have in the past installed libraries
15# in /lib(64)?, but are now moving to install libraries in /usr/lib(64)?/.
16# The /lib paths are made symlinks to the /usr/lib paths. If someone searching
17# for a Qt 5 package finds it in /lib/cmake/Qt5Core, although it has been
18# installed in /usr/lib/cmake/Qt5Core, relative paths to the includes and
19# executables will not work.
20# To work around this, we insert code into the generated config files to check
21# at cmake time whether package has been found via a symlink, and correct
22# that to an absolute path. This is only done for installations to
23# the /usr or / prefix.
24CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
25contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
26
27CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
28
29internal_module {
30    MODULE = "$${MODULE}_private"
31}
32
33# Core, Network, an external module named Foo
34CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE})
35
36# QtCore, QtNetwork, still Foo
37CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name)
38
39# TARGET here is the one changed at the end of qt_module.prf,
40# which already contains the Qt5 prefix and QT_LIBINFIX suffix :
41# Qt5Core_{libinfix_suffix}, Qt5Network_{libinfix_suffix}, Foo_{libinfix_suffix}
42# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework).
43CMAKE_QT_STEM = $${TARGET}
44
45# ANDROID_ABI is set by the android toolchain file, see https://developer.android.com/ndk/guides/cmake
46android: CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, "_$${QT_ARCH}", '_\$\{ANDROID_ABI\}')
47
48# On macOS when building just a debug configuration which is not part of debug_and_release,
49# $${TARGET} already contains a _debug suffix, as per the following call chain:
50# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix.
51# Remove the _debug suffix in the stem, to keep all further uses of CMAKE_QT_STEM consistent.
52# The _debug suffix is then re-added where needed regardless if it's a debug_and_release build
53# or just debug.
54darwin:!qt_framework:!debug_and_release:CONFIG(debug, debug|release) {
55    CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, _debug$, )
56}
57
58!generated_privates {
59    isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \
60        CMAKE_NO_PRIVATE_INCLUDES = true
61}
62split_incpath {
63    CMAKE_ADD_SOURCE_INCLUDE_DIRS = true
64    CMAKE_SOURCE_INCLUDES = \
65        $$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/$${CMAKE_INCLUDE_NAME})
66    CMAKE_SOURCE_PRIVATE_INCLUDES = \
67        $$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE/$${CMAKE_INCLUDE_NAME}/$$eval(QT.$${MODULE}.VERSION) \
68            $$QT_MODULE_INCLUDE_BASE/$${CMAKE_INCLUDE_NAME}/$$eval(QT.$${MODULE}.VERSION)/$${CMAKE_INCLUDE_NAME})
69
70    cmake_extra_source_includes.input = $$PWD/data/cmake/ExtraSourceIncludes.cmake.in
71    cmake_extra_source_includes.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/ExtraSourceIncludes.cmake
72
73    !build_pass:QMAKE_SUBSTITUTES += \
74        cmake_extra_source_includes
75
76    cmake_qt5_module_files.files = \
77        $$cmake_extra_source_includes.output
78}
79
80CMAKE_INCLUDE_DIR = $$cmakeRelativePath($$[QT_INSTALL_HEADERS], $$[QT_INSTALL_PREFIX])
81contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*")|freebsd {
82    CMAKE_INCLUDE_DIR = $$[QT_INSTALL_HEADERS]/
83    CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
84}
85
86CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
87contains(CMAKE_LIB_DIR,"^\\.\\./.*")|freebsd {
88    CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
89    CMAKE_LIB_DIR_IS_ABSOLUTE = True
90} else {
91    CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
92    # We need to go up another two levels because the CMake files are
93    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
94    CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
95}
96
97CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
98contains(CMAKE_BIN_DIR, "^\\.\\./.*")|freebsd {
99    CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
100    CMAKE_BIN_DIR_IS_ABSOLUTE = True
101}
102
103CMAKE_PLUGIN_DIR = $$cmakeRelativePath($$[QT_INSTALL_PLUGINS], $$[QT_INSTALL_PREFIX])
104contains(CMAKE_PLUGIN_DIR, "^\\.\\./.*")|freebsd {
105    CMAKE_PLUGIN_DIR = $$[QT_INSTALL_PLUGINS]/
106    CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
107}
108
109win32:!static:!staticlib {
110    CMAKE_DLL_DIR = $$cmakeRelativePath($$[QT_INSTALL_BINS], $$[QT_INSTALL_PREFIX])
111    contains(CMAKE_DLL_DIR, "^\\.\\./.*") {
112        CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
113        CMAKE_DLL_DIR_IS_ABSOLUTE = True
114    }
115} else {
116    CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
117    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
118}
119
120static|staticlib:CMAKE_STATIC_TYPE = true
121
122internal_module {
123    CMAKE_INTERNAL_MODULE = true
124}
125
126CMAKE_DEBUG_TYPE =
127CMAKE_RELEASE_TYPE =
128
129# Requirements:
130# * If Qt is configured with -debug, we're creating debug libraries and not
131#   release libraries, regardless of whether we're on a platform where
132#   debug_and_release is true.
133# * If Qt is configured with -release, we're creating release libraries and not
134#   debug libraries, regardless of whether we're on a platform where
135#   debug_and_release is true.
136# * If Qt is configured with neither -debug nor -release, and we are on a
137#   platform where debug_and_release is true, we're creating both
138#   debug and release libraries.
139# * If Qt is configured with -debug on a platform where debug_and_release is
140#   true, and 'make release' is subsequently invoked, CMake is only aware of
141#   the debug libraries at build time.
142
143equals(QMAKE_HOST.os, Windows): CMAKE_BIN_SUFFIX = ".exe"
144if(debug_and_release:build_all)|CONFIG(debug, debug|release): CMAKE_DEBUG_TYPE = debug
145if(debug_and_release:build_all)|CONFIG(release, debug|release): CMAKE_RELEASE_TYPE = release
146
147# CMAKE_DEBUG_AND_RELEASE is used to tell the _populate_$${CMAKE_MODULE_NAME}_target_properties
148# functions whether a Configuration specific generator expression needs to be added to the values
149# of INTERFACE_LINK_LIBRARIES and INTERFACE_LINK_OPTIONS. For debug_and_release builds, we do need
150# configuration specific values. For singular builds (only release or only debug), we want the
151# values to be applied regardless of the configuration.
152# This would allow on Linux and macOS (and with a recent enough version of CMake on Windows) to
153# build a Debug configuration of an application, even if Qt was built in a Release configuration.
154#
155# All IMPORTED_LOCATION_<CONFIG> paths are automatically considered by CMake if there is no
156# <CONFIG> equivalent to the value  specified by CMAKE_BUILD_TYPE.
157# This means that when Qt was built in a Release configuration, and the application in a Debug
158# configuration, IMPORTED_LOCATION_RELEASE will be used for the Qt libraries.
159#
160# Note that we need to check for the "debug_and_release" feature, and not the CONFIG value, because
161# the CONFIG value is always set to true on Windows in msvc-desktop.conf disregarding whether the
162# configure line specified just -debug or just -release.
163# This also means that if a user configures and builds Qt with -release, and then calls nmake debug
164# to build debug libraries of Qt, the generated CMake file won't know about debug libraries,
165# and will always link against the release libraries.
166qtConfig(debug_and_release) {
167    CMAKE_DEBUG_AND_RELEASE = TRUE
168} else {
169    CMAKE_DEBUG_AND_RELEASE = FALSE
170}
171
172contains(CONFIG, plugin) {
173    equals(PLUGIN_EXTENDS, -) {
174        CMAKE_PLUGIN_EXTENDS = -
175    } else {
176        list_plugin_extends =
177        for (p, PLUGIN_EXTENDS) {
178            m = $$cmakeModuleName($$p)
179            list_plugin_extends += Qt::$$m
180        }
181        CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
182    }
183
184    PLUGIN_MODULE_NAME =
185    unique_qt_modules = $$unique(QT_MODULES)   # In case modules appear in multiple places
186    for (mod, unique_qt_modules) {
187        contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
188            !isEmpty(PLUGIN_MODULE_NAME): \
189                error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
190            PLUGIN_MODULE_NAME = $$mod
191        }
192    }
193    isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
194
195    sorted_deps = $$sort_depends(QT_PLUGIN.$${CMAKE_QT_STEM}.DEPENDS, QT.)
196    mod_deps =
197    lib_deps =
198    aux_mod_deps =
199    aux_lib_deps =
200    for (dep, sorted_deps) {
201        cdep = $$cmakeModuleName($$dep)
202        mod_deps += $$cdep
203        lib_deps += Qt5::$$cdep
204    }
205    CMAKE_PLUGIN_MODULE_DEPS = $$join(mod_deps, ";")
206    CMAKE_PLUGIN_QT5_MODULE_DEPS = $$join(lib_deps, ";")
207
208    CMAKE_MODULE_NAME = $$cmakeModuleName($$PLUGIN_MODULE_NAME)
209
210    CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
211    CMAKE_PLUGIN_TYPE = $$PLUGIN_TYPE
212    CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _)
213
214    win32 {
215        !mingw|qtConfig(debug_and_release): debug_suffix="d"
216
217        CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
218        CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.prl
219
220        isEmpty(CMAKE_STATIC_TYPE) {
221            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll
222            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.dll
223        } else:mingw {
224            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a
225            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${debug_suffix}.a
226        } else {                         # MSVC static
227            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib
228            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.lib
229        }
230    } else {
231        mac {
232            isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .dylib
233            else: CMAKE_PLUGIN_EXT = .a
234
235            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
236            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug$${CMAKE_PLUGIN_EXT}
237            CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
238            CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug.prl
239        } else {
240            isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .so
241            else: CMAKE_PLUGIN_EXT = .a
242
243            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
244            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
245            CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
246            CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
247        }
248    }
249    cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
250    cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
251    cmake_qt5_plugin_import_file.input = $$PWD/data/cmake/Qt5ImportPlugin.cpp.in
252    cmake_qt5_plugin_import_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}_Import.cpp
253
254    !build_pass {
255        QMAKE_SUBSTITUTES += cmake_target_file
256        static|staticlib: QMAKE_SUBSTITUTES += cmake_qt5_plugin_import_file
257    }
258
259    cmake_qt5_plugin_file.files = $$cmake_target_file.output
260    static|staticlib: cmake_qt5_plugin_file.files += $$cmake_qt5_plugin_import_file.output
261    cmake_qt5_plugin_file.path = $$[QT_INSTALL_PREFIX]/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
262    INSTALLS += cmake_qt5_plugin_file
263
264    return()
265}
266
267CMAKE_MKSPEC = $$[QMAKE_XSPEC]
268
269sorted_deps = $$sort_depends(QT.$${MODULE}.depends, QT.)
270mod_deps =
271lib_deps =
272aux_mod_deps =
273aux_lib_deps =
274# Until CMake 3.0 is the minimum requirement of Qt 5, we need to filter
275# out header-only modules from dependencies.  CMake 3.0 provides INTERFACE
276# libraries which are equivalent to header-only modules.
277for (dep, sorted_deps) {
278    cdep = $$cmakeModuleName($$dep)
279    !contains(QT.$${dep}.module_config, no_link) {
280        mod_deps += $$cdep
281        lib_deps += Qt5::$$cdep
282    } else {
283        aux_mod_deps += $$cdep
284        aux_lib_deps += Qt5::$$cdep
285    }
286}
287CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
288CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
289CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
290CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
291CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
292
293# Interface libraries have to have all properties starting with "INTERFACE_".
294CMAKE_FEATURE_PROPERTY_PREFIX = ""
295equals(TEMPLATE, aux): CMAKE_FEATURE_PROPERTY_PREFIX = "INTERFACE_"
296
297mac {
298    !isEmpty(CMAKE_STATIC_TYPE) {
299        CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a
300        CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
301
302        CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.prl
303        CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
304    } else {
305        qt_framework {
306            # Intentionally there is no '_debug' infix for framework builds.
307            CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}
308            CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}
309            CMAKE_BUILD_IS_FRAMEWORK = "true"
310        } else {
311            CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.$$eval(QT.$${MODULE}.VERSION).dylib
312            CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib
313        }
314    }
315} else:win32 {
316    CMAKE_WINDOWS_BUILD = "true"
317    CMAKE_FIND_OTHER_LIBRARY_BUILD = "true"
318
319    !mingw|qtConfig(debug_and_release): debug_suffix="d"
320
321    CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.dll
322    CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.dll
323
324    !isEmpty(CMAKE_STATIC_TYPE) {
325        CMAKE_STATIC_WINDOWS_BUILD = "true"
326
327        CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.prl
328        CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
329    }
330
331    mingw {
332        CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}$${debug_suffix}.a
333        CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a
334
335        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.a
336        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
337    } else {
338        CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}$${debug_suffix}.lib
339        CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib
340
341        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.lib
342        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
343    }
344} else {
345    !isEmpty(CMAKE_STATIC_TYPE) {
346        CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a
347        CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
348        CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.prl
349        CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
350    } else:unversioned_libname {
351        CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.so
352        CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.so
353        CMAKE_LIB_SONAME = lib$${CMAKE_QT_STEM}.so
354    } else {
355        CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.so.$$eval(QT.$${MODULE}.VERSION)
356        CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.so.$$eval(QT.$${MODULE}.VERSION)
357        CMAKE_LIB_SONAME = lib$${CMAKE_QT_STEM}.so.$$section(QT.$${MODULE}.VERSION, ., 0, 0)
358    }
359}
360
361INSTALLS += cmake_qt5_module_files
362
363cmake_config_file.input = $$PWD/data/cmake/Qt5BasicConfig.cmake.in
364cmake_config_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}Config.cmake
365
366CMAKE_PACKAGE_VERSION = $$eval(QT.$${MODULE}.VERSION)
367
368cmake_config_version_file.input = $$PWD/data/cmake/Qt5ConfigVersion.cmake.in
369cmake_config_version_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake
370
371!build_pass:QMAKE_SUBSTITUTES += \
372    cmake_config_file \
373    cmake_config_version_file
374
375cmake_qt5_module_files.files = \
376    $$cmake_config_file.output \
377    $$cmake_config_version_file.output
378
379cmake_extras_file.input = $$_PRO_FILE_PWD_/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake.in
380exists($$cmake_extras_file.input) {
381
382    CMAKE_MODULE_EXTRAS = "true"
383    cmake_extras_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake
384
385    !build_pass:QMAKE_SUBSTITUTES += cmake_extras_file
386
387    cmake_qt5_module_files.files += \
388        $$cmake_extras_file.output
389}
390
391cmake_macros_file.input = $$_PRO_FILE_PWD_/Qt5$${CMAKE_MODULE_NAME}Macros.cmake
392exists($$cmake_macros_file.input) {
393    CMAKE_MODULE_MACROS = "true"
394
395    cmake_macros_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}Macros.cmake
396    cmake_macros_file.CONFIG = verbatim
397
398    !build_pass:QMAKE_SUBSTITUTES += cmake_macros_file
399
400    cmake_qt5_module_files.files += $$cmake_macros_file.output
401}
402
403cmake_qt5_module_files.path = $$[QT_INSTALL_PREFIX]/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
404
405# We are generating cmake files. Most developers of Qt are not aware of cmake,
406# so we require automatic tests to be available. The only module which should
407# set CMAKE_MODULE_TESTS to '-' is enginio because that is known to be broken.
408# Other modules should either create proper tests in tests/auto/cmake or, as
409# a temporary measure, disable the generation of cmake files
410# with 'CONFIG -= create_cmake'
411!internal_module:!equals(CMAKE_MODULE_TESTS, -) {
412    isEmpty(CMAKE_MODULE_TESTS): CMAKE_MODULE_TESTS = $$MODULE_BASE_INDIR/tests/auto/cmake
413    !exists($$CMAKE_MODULE_TESTS): \
414        error("Missing CMake tests. Either create tests in tests/auto/cmake," \
415              "or disable cmake config file creation with CONFIG-=create_cmake.")
416}
417