diff options
Diffstat (limited to 'mkspecs/features/create_cmake.prf')
-rw-r--r-- | mkspecs/features/create_cmake.prf | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index c9910dda53..fe9149b1c1 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,20 @@ 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} +# 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 +116,10 @@ win32:!static:!staticlib { static|staticlib:CMAKE_STATIC_TYPE = true +internal_module { + CMAKE_INTERNAL_MODULE = true +} + CMAKE_DEBUG_TYPE = CMAKE_RELEASE_TYPE = @@ -123,6 +141,24 @@ 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 +# 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. +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): \ @@ -211,18 +247,18 @@ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") 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 { - CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} + CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}_debug 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 } } |