diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-07-16 18:22:35 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-07-22 15:56:37 +0200 |
commit | cd89b7b61976a5302a683998b60dc66c8bc3018d (patch) | |
tree | c7df1ce23b1d4a80f385db62875956e721d3d153 /src/corelib/Qt6CoreMacros.cmake | |
parent | 3a19c5b2e62b5c56fc0b4a424c1e62266493cf54 (diff) | |
download | qtbase-cd89b7b61976a5302a683998b60dc66c8bc3018d.tar.gz |
CMake: Fix Windows -debug-and-release builds with CMake 3.21.0
CMake 3.21.0 introduced a regression where per-config sources can't be
specified for object libs when building Qt with Ninja Multi-Config
and cross-config mode on.
We hit that in our Windows resource compiler handling.
To work around the issue, pass the config-specific sources directly to
the target rather than via an object library, when using CMake 3.20 or
later. The original issue of not being able to do that has been fixed
in 3.20.
Amends ba6175eb731927f2489cdd7d899616a9889aba67
Amends a1ccedeb440216dce87fad01746935a89fd8715e
Amends 657fa0462d552110e2ba14bcac46275e6066993f
Pick-to: 6.2
Fixes: QTBUG-95229
Change-Id: Idea6d5bcc54b3124c66c45538c2e06e92f288f5f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index f9393a2b07..42116cba69 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1361,10 +1361,24 @@ END # We would like to do the following: # target_sources(${target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>") - # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us. - # Work-around by compiling the resources in an object lib and linking that. - add_library(${target}_rc OBJECT "${output}") - target_link_libraries(${target} PRIVATE $<TARGET_OBJECTS:${target}_rc>) + # + # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us do that + # in CMake 3.19 and earlier. + # We can do it in CMake 3.20 and later. + # And we have to do it with CMake 3.21.0 to avoid a different issue + # https://gitlab.kitware.com/cmake/cmake/-/issues/22436 + # + # So use the object lib work around for <= 3.19 and target_sources directly for later + # versions. + set(use_obj_lib FALSE) + set(end_target "${target}") + if(CMAKE_VERSION VERSION_LESS 3.20) + set(use_obj_lib TRUE) + set(end_target "${target}_rc") + add_library(${target}_rc OBJECT "${output}") + target_link_libraries(${target} PRIVATE $<TARGET_OBJECTS:${target}_rc>) + endif() + while(outputs) list(POP_FRONT cfgs cfg) list(POP_FRONT outputs output) @@ -1373,7 +1387,7 @@ END DEPENDS "${input}" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}" ) - target_sources(${target}_rc PRIVATE "$<$<CONFIG:${cfg}>:${output}>") + target_sources(${end_target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>") endwhile() endif() endfunction() |