summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/create_cmake.prf
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-06-20 12:04:31 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-07-05 15:59:13 +0200
commit44602224bfae7bea08e5883768cfeef6629ac503 (patch)
tree8aaea989799ee5c89dd02583332f9f5614ca9cfd /mkspecs/features/create_cmake.prf
parent6ad08b9cad4efefc72e64deaa0b720a3aab0fa54 (diff)
CMake: Put the static dependencies into the relevant configuration
When adding the static dependencies for a module, they should be added to the debug|release configuration as appropriate, otherwise it ends up adding the debug version of the libraries to the release configuration as well as the release version of the libraries. Implementation wise, that means we have to use generator expressions of the form $<$<CONFIG:Configuration>:${dependencies}>, because INTERFACE_LINK_LIBRARIES does not have a INTERFACE_LINK_LIBRARIES_<CONFIG> equivalent that can be set per configuration. Note that the condition part of the generator expression can not explicitly check for Debug or for Release, because a user can configure their application without specifying CMAKE_BUILD_TYPE, which means that both Debug and Relase conditions would fail. So the actual condition has to be isDebug or isNotDebug. The same approach is used for INTERFACE_LINK_OPTIONS. For debug_and_release builds we use the isDebug and isNotDebug conditions for the generator expressions. For singular builds (only release or only debug), we set the generator expression condition to "1" aka always true. This means that the Qt libraries and link options will always be used regardless of the configuration with which the CMake application is configured with. Fixes: QTBUG-76337 Task-number: QTBUG-38913 Change-Id: I5369d8ba083359a4a92253dbd1dabe9d1efa34db Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'mkspecs/features/create_cmake.prf')
-rw-r--r--mkspecs/features/create_cmake.prf18
1 files changed, 18 insertions, 0 deletions
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 00da9bd33f..68e6b6d265 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -133,6 +133,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): \