From ba6175eb731927f2489cdd7d899616a9889aba67 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 10 Nov 2020 12:50:21 +0100 Subject: CMake: Fix missing resources in Windows debug DLLs/EXEs When configuring a Windows build with NMC and "CMAKE_CONFIGURATION_TYPES=Release;Debug", then with CMake 3.18.4 only the targets of the main configuration would get the version resource compiled in. With 3.19.0 RC 2 the problem cannot be observed. Work-around the issue by revisiting our work-around of another CMake issue: use just one object library per target to embed win32 resources. This works with both tested CMake versions and seems cleaner anyways. Fixes: QTBUG-88267 Change-Id: I20f596ab669ae716c330d7aa60aa717b9e3e4aa7 Reviewed-by: Alexandru Croitor --- src/corelib/Qt6CoreMacros.cmake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index a48bc2580d..36382445cd 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1023,6 +1023,13 @@ END set(cfgs "${CMAKE_BUILD_TYPE}") set(outputs "${rc_file_output}") endif() + + # We would like to do the following: + # target_sources(${target} PRIVATE "$<$:${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 $) while(outputs) list(POP_FRONT cfgs cfg) list(POP_FRONT outputs output) @@ -1031,12 +1038,7 @@ END DEPENDS "${input}" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}" ) - - # We would like to do the following: - # target_sources(${target} PRIVATE "$<$:${output}>") - # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us. - add_library(${target}_${cfg}_rc OBJECT "${output}") - target_link_libraries(${target} PRIVATE "$<$:${target}_${cfg}_rc>") + target_sources(${target}_rc PRIVATE "$<$:${output}>") endwhile() endif() endfunction() -- cgit v1.2.3