diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-10 12:50:21 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-10 14:23:08 +0100 |
commit | ba6175eb731927f2489cdd7d899616a9889aba67 (patch) | |
tree | 295b03e76afed6daf59878ffc9d50b15ecbf72aa /src | |
parent | e990b649fa999fd55ccfb223991fce4bb3d6c0e3 (diff) |
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 <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 14 |
1 files changed, 8 insertions, 6 deletions
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 "$<$<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>) 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 "$<$<CONFIG:${cfg}>:${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 "$<$<CONFIG:${cfg}>:${target}_${cfg}_rc>") + target_sources(${target}_rc PRIVATE "$<$<CONFIG:${cfg}>:${output}>") endwhile() endif() endfunction() |