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>
This commit is contained in:
parent
e990b649fa
commit
ba6175eb73
@ -1023,6 +1023,13 @@ END
|
|||||||
set(cfgs "${CMAKE_BUILD_TYPE}")
|
set(cfgs "${CMAKE_BUILD_TYPE}")
|
||||||
set(outputs "${rc_file_output}")
|
set(outputs "${rc_file_output}")
|
||||||
endif()
|
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)
|
while(outputs)
|
||||||
list(POP_FRONT cfgs cfg)
|
list(POP_FRONT cfgs cfg)
|
||||||
list(POP_FRONT outputs output)
|
list(POP_FRONT outputs output)
|
||||||
@ -1031,12 +1038,7 @@ END
|
|||||||
DEPENDS "${input}"
|
DEPENDS "${input}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}"
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}"
|
||||||
)
|
)
|
||||||
|
target_sources(${target}_rc PRIVATE "$<$<CONFIG:${cfg}>:${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>")
|
|
||||||
endwhile()
|
endwhile()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user