summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/create_cmake.prf
diff options
context:
space:
mode:
Diffstat (limited to 'mkspecs/features/create_cmake.prf')
-rw-r--r--mkspecs/features/create_cmake.prf201
1 files changed, 139 insertions, 62 deletions
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index c9910dda53..24ed125f12 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -26,6 +26,10 @@ contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND
CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
+internal_module {
+ MODULE = "$${MODULE}_private"
+}
+
# Core, Network, an external module named Foo
CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE})
@@ -34,10 +38,23 @@ CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name)
# TARGET here is the one changed at the end of qt_module.prf,
# which already contains the Qt5 prefix and QT_LIBINFIX suffix :
-# Qt5Core_suffix, Qt5Network_suffix, Foo_suffix
-# (or QtCore_suffix, Foo_suffix on macos with -framework)
+# Qt5Core_{libinfix_suffix}, Qt5Network_{libinfix_suffix}, Foo_{libinfix_suffix}
+# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework).
CMAKE_QT_STEM = $${TARGET}
+# ANDROID_ABI is set by the android toolchain file, see https://developer.android.com/ndk/guides/cmake
+android: CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, "_$${QT_ARCH}", '_\$\{ANDROID_ABI\}')
+
+# On macOS when building just a debug configuration which is not part of debug_and_release,
+# $${TARGET} already contains a _debug suffix, as per the following call chain:
+# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix.
+# Remove the _debug suffix in the stem, to keep all further uses of CMAKE_QT_STEM consistent.
+# The _debug suffix is then re-added where needed regardless if it's a debug_and_release build
+# or just debug.
+darwin:!qt_framework:!debug_and_release:CONFIG(debug, debug|release) {
+ CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, _debug$, )
+}
+
!generated_privates {
isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \
CMAKE_NO_PRIVATE_INCLUDES = true
@@ -102,6 +119,10 @@ win32:!static:!staticlib {
static|staticlib:CMAKE_STATIC_TYPE = true
+internal_module {
+ CMAKE_INTERNAL_MODULE = true
+}
+
CMAKE_DEBUG_TYPE =
CMAKE_RELEASE_TYPE =
@@ -120,64 +141,123 @@ CMAKE_RELEASE_TYPE =
# the debug libraries at build time.
equals(QMAKE_HOST.os, Windows): CMAKE_BIN_SUFFIX = ".exe"
-if(build_all|CONFIG(debug, debug|release)): CMAKE_DEBUG_TYPE = debug
-if(build_all|CONFIG(release, debug|release)): CMAKE_RELEASE_TYPE = release
+if(debug_and_release:build_all)|CONFIG(debug, debug|release): CMAKE_DEBUG_TYPE = debug
+if(debug_and_release:build_all)|CONFIG(release, debug|release): CMAKE_RELEASE_TYPE = release
+
+# CMAKE_DEBUG_AND_RELEASE is used to tell the _populate_$${CMAKE_MODULE_NAME}_target_properties
+# functions whether a Configuration specific generator expression needs to be added to the values
+# of INTERFACE_LINK_LIBRARIES and INTERFACE_LINK_OPTIONS. For debug_and_release builds, we do need
+# configuration specific values. For singular builds (only release or only debug), we want the
+# values to be applied regardless of the configuration.
+# This would allow on Linux and macOS (and with a recent enough version of CMake on Windows) to
+# build a Debug configuration of an application, even if Qt was built in a Release configuration.
+#
+# All IMPORTED_LOCATION_<CONFIG> paths are automatically considered by CMake if there is no
+# <CONFIG> equivalent to the value specified by CMAKE_BUILD_TYPE.
+# This means that when Qt was built in a Release configuration, and the application in a Debug
+# configuration, IMPORTED_LOCATION_RELEASE will be used for the Qt libraries.
+#
+# Note that we need to check for the "debug_and_release" feature, and not the CONFIG value, because
+# the CONFIG value is always set to true on Windows in msvc-desktop.conf disregarding whether the
+# configure line specified just -debug or just -release.
+# This also means that if a user configures and builds Qt with -release, and then calls nmake debug
+# to build debug libraries of Qt, the generated CMake file won't know about debug libraries,
+# and will always link against the release libraries.
+qtConfig(debug_and_release) {
+ CMAKE_DEBUG_AND_RELEASE = TRUE
+} else {
+ CMAKE_DEBUG_AND_RELEASE = FALSE
+}
contains(CONFIG, plugin) {
- !isEmpty(PLUGIN_EXTENDS):!equals(PLUGIN_EXTENDS, -) {
- count(PLUGIN_EXTENDS, 1, greaterThan): \
- error("Plugin declares to extend multiple modules. We don't handle that ...")
- PLUGIN_MODULE_NAME = $$PLUGIN_EXTENDS
+ equals(PLUGIN_EXTENDS, -) {
+ CMAKE_PLUGIN_EXTENDS = -
} else {
- PLUGIN_MODULE_NAME =
- for (mod, QT_MODULES) {
- contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
- !isEmpty(PLUGIN_MODULE_NAME): \
- error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
- PLUGIN_MODULE_NAME = $$mod
- break()
- }
+ list_plugin_extends =
+ for (p, PLUGIN_EXTENDS) {
+ m = $$cmakeModuleName($$p)
+ list_plugin_extends += Qt::$$m
+ }
+ CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
+ }
+
+ PLUGIN_MODULE_NAME =
+ unique_qt_modules = $$unique(QT_MODULES) # In case modules appear in multiple places
+ for (mod, unique_qt_modules) {
+ contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
+ !isEmpty(PLUGIN_MODULE_NAME): \
+ error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
+ PLUGIN_MODULE_NAME = $$mod
}
- isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
}
+ isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
+
+ sorted_deps = $$sort_depends(QT_PLUGIN.$${CMAKE_QT_STEM}.DEPENDS, QT.)
+ mod_deps =
+ lib_deps =
+ aux_mod_deps =
+ aux_lib_deps =
+ for (dep, sorted_deps) {
+ cdep = $$cmakeModuleName($$dep)
+ mod_deps += $$cdep
+ lib_deps += Qt5::$$cdep
+ }
+ CMAKE_PLUGIN_MODULE_DEPS = $$join(mod_deps, ";")
+ CMAKE_PLUGIN_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_MODULE_NAME = $$cmakeModuleName($$PLUGIN_MODULE_NAME)
CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
+ CMAKE_PLUGIN_TYPE = $$PLUGIN_TYPE
+ CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _)
win32 {
+ !mingw|qtConfig(debug_and_release): debug_suffix="d"
+
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.prl
+
isEmpty(CMAKE_STATIC_TYPE) {
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.dll
} else:mingw {
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${debug_suffix}.a
} else { # MSVC static
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}$${debug_suffix}.lib
}
} else {
mac {
- isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
- else: CMAKE_PlUGIN_EXT = .a
+ isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .dylib
+ else: CMAKE_PLUGIN_EXT = .a
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug$${CMAKE_PLUGIN_EXT}
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug.prl
} else {
- isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
- else: CMAKE_PlUGIN_EXT = .a
+ isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .so
+ else: CMAKE_PLUGIN_EXT = .a
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
}
}
cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
+ cmake_qt5_plugin_import_file.input = $$PWD/data/cmake/Qt5ImportPlugin.cpp.in
+ cmake_qt5_plugin_import_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}_Import.cpp
- !build_pass:QMAKE_SUBSTITUTES += \
- cmake_target_file
+ !build_pass {
+ QMAKE_SUBSTITUTES += cmake_target_file
+ static|staticlib: QMAKE_SUBSTITUTES += cmake_qt5_plugin_import_file
+ }
cmake_qt5_plugin_file.files = $$cmake_target_file.output
+ static|staticlib: cmake_qt5_plugin_file.files += $$cmake_qt5_plugin_import_file.output
cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
INSTALLS += cmake_qt5_plugin_file
@@ -208,21 +288,27 @@ CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
+CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
+
+# Interface libraries have to have all properties starting with "INTERFACE_".
+CMAKE_FEATURE_PROPERTY_PREFIX = ""
+equals(TEMPLATE, aux): CMAKE_FEATURE_PROPERTY_PREFIX = "INTERFACE_"
mac {
!isEmpty(CMAKE_STATIC_TYPE) {
- CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a
+ CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a
CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
- CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.prl
CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
} else {
qt_framework {
+ # Intentionally there is no '_debug' infix for framework builds.
CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}
CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}
CMAKE_BUILD_IS_FRAMEWORK = "true"
} else {
- CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib
+ CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.$$eval(QT.$${MODULE}.VERSION).dylib
CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib
}
}
@@ -230,39 +316,30 @@ mac {
CMAKE_WINDOWS_BUILD = "true"
CMAKE_FIND_OTHER_LIBRARY_BUILD = "true"
- CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.dll
+ !mingw|qtConfig(debug_and_release): debug_suffix="d"
+
+ CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.dll
CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.dll
+ !isEmpty(CMAKE_STATIC_TYPE) {
+ CMAKE_STATIC_WINDOWS_BUILD = "true"
+
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.prl
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
+ }
+
mingw {
- CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a
+ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}$${debug_suffix}.a
CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a
- !isEmpty(CMAKE_STATIC_TYPE) {
- CMAKE_STATIC_WINDOWS_BUILD = "true"
- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
-
- CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.prl
- CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
- } else {
- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
- }
+ CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.a
+ CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
} else {
- CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib
+ CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}$${debug_suffix}.lib
CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib
- !isEmpty(CMAKE_STATIC_TYPE) {
- CMAKE_STATIC_WINDOWS_BUILD = "true"
- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
-
- CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
- CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
- } else {
- CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
- CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
- }
+ CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}$${debug_suffix}.lib
+ CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
}
} else {
!isEmpty(CMAKE_STATIC_TYPE) {
@@ -331,7 +408,7 @@ cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
# Other modules should either create proper tests in tests/auto/cmake or, as
# a temporary measure, disable the generation of cmake files
# with 'CONFIG -= create_cmake'
-!equals(CMAKE_MODULE_TESTS, -) {
+!internal_module:!equals(CMAKE_MODULE_TESTS, -) {
isEmpty(CMAKE_MODULE_TESTS): CMAKE_MODULE_TESTS = $$MODULE_BASE_INDIR/tests/auto/cmake
!exists($$CMAKE_MODULE_TESTS): \
error("Missing CMake tests. Either create tests in tests/auto/cmake," \